Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Implement operator-pending mode #58

Closed

Description

@stuartmemo

Currently change, delete and yank in tag doesn't work. The "i" is interpreted as a normal insert command.

Great work with this btw!

Activity

  1. graywh commented on Feb 27, 2014

    @graywh

    Sounds like Atom needs an operator-pending mode.

  2. bashcoder commented on Feb 27, 2014

    @bashcoder

    Yes, that might allow for other vim compatibility fixes such as daw, caw and the like.

  3. bashcoder commented on Feb 27, 2014

    @bashcoder

    Another example is ctX, where "X" is the variable character marking the end of the change zone.

  4. keyneston commented on Feb 27, 2014

    @keyneston
    Contributor

    In addition there is the tX and fX along with all of its variations: dtX, yfX, etc.

  5. stuartmemo commented on Feb 27, 2014

    @stuartmemo
    Author

    I'm happy to close this if someone wants to create a new ticket with a better description that incorporates all these things?

  6. mcolyer commented on Feb 28, 2014

    @mcolyer
    Contributor

    👍 to the operator pending mode, also feel free to edit the issue description/title. Usually I shy away from editing issue descriptions and titles but I think it's fine in a case like this.

  7. jroes commented on Feb 28, 2014

    @jroes
    Contributor

    There is some semblance of operator pending going on with the @complete instance variable in operators.coffee, but I think an operator pending mode might make it more explicit and potentially simplify some code. These are the only operators vim officially considers operators - c, d, y, ~, g~, gu, gU, !, =, gq, g?, >, <, zf, g@ I think operators.coffee has a few outliers that we might be able to move to commands.coffee.

    If we ever want to implement those multi-character operators, I think we need to start doing timeout stuff. It would actually be awesome if we had direct support for this in atom. For example, I've always bound jk to Esc, and binding j k in my local keymap causes issues in vim-mode :(.

  8. stuartmemo commented on Feb 28, 2014

    @stuartmemo
    Author

    Have updated title to "Implement operator-pending mode".

  9. mcolyer commented on Feb 28, 2014

    @mcolyer
    Contributor

    @jroes 👍 on a more correct operator pending mode and making things generally more correct.

    As for the timeout stuff that's honestly what stopped the progress on these more complex commands. Atom's keybinding infrastructure was never really intended to have multiple separate key presses (ie keypresses are considered independently, not within a state machine). I think we can get it there but it just hasn't been a priority.

  10. jroes commented on Mar 1, 2014

    @jroes
    Contributor

    I'm off to a slow start guys, this is a little challenging (but fun!) :)

    So far what I've done:

    • I created a TextObject subclass of Motion for storing all of our new text objects, and an InnerWord subclass of TextObject that selects the current word under the cursor like vim's iw
    • I implemented an operator-pending mode that looks pretty much exactly like the other modes.
    • I copied a bunch of keymaps into the operator-pending mode map. This felt like a lot of duplication, maybe there is a better way to handle this.
    • I spent some time trying to see if I needed to make any changes to the meaty part of how the operator stack works. After a lot of toying around, I think I found that we are probably going to need this stack, but the name was confusing me a bit. I renamed several spots from operator to operation to better communicate that this is a stack of operations that are being performed, these operations may be operators, motions, text objects, or something else. The way I'm thinking of opStack is as an internal representation of something like "d2w". I documented this for future code spelunkers. I hope this is in line with the overall project vision.
    • I was able to bind i w on its own in visual-mode with no special help there since i isn't already bound. However, I noticed that in vim you can type iw a bunch of times in visual mode and it'll work like w after the first time. I was going to leave that as a future exercise outside of whatever pull request I make for operator-mode

    So I think this is a small toe-dip in the waters. From here we should be able to implement aw and several other things simply because the mode has its own context for key bindings and won't interfere with the other bindings. I still think we are going to hit problems where we'll need timeouts though. Hopefully that gets into Atom sooner or later.

    Here's a compare for my current branch: jroes/vim-mode@atom:master...jroes:operator-pending
    @mcolyer, everyone - what do you think, does this line up with your thinking? At this point all tests pass, so I could make a PR to stop this from turning into a really really big PR, and then we can all make some successive PRs for various text objects and things that should happen in operator-pending mode.

  11. jroes commented on Mar 1, 2014

    @jroes
    Contributor

    Oh, forgot to mention -- I'm actually not putting us into operator-pending mode for every valid operator yet. I thought it would be better to do that one at a time as we need it. Doing it all at once brings with it a ton of test failures that will take some time to dig through.

  12. ElDeveloper commented on Mar 1, 2014

    @ElDeveloper

    Just adding a note about vip see #111.

  13. jroes commented on Mar 4, 2014

    @jroes
    Contributor

    ping -- anyone have a chance to offer some feedback on my comments above?

  14. bhuga commented on Mar 8, 2014

    @bhuga
    Contributor

    @jroes, can you make a pull request out of your branch? That will make it a little easier to talk about.

  15. jroes commented on Mar 9, 2014

    @jroes
    Contributor

    Will do @bhuga. It has drifted a bit. I've rebased, but there are some test failures now that I'll have to look through and address.

  16. bhuga commented on May 11, 2014

    @bhuga
    Contributor

    Added in #152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions