guillermooo / Vintageous

Vi/Vim emulation for Sublime Text 3
http://guillermooo.bitbucket.org/Vintageous/
Other
1.64k stars 115 forks source link

Quick fix for cursor position after Redo. #1000

Open jordwalke opened 8 years ago

jordwalke commented 8 years ago

I've filed this other long standing issue for cursor position after redo: https://github.com/guillermooo/Vintageous/issues/302

Until that is fixed the current behavior is a little stranger than it needs to be. When opening a new line, entering some text, and then redoing that text, the cursor is positioned after the final character - on the newline itself. This is strange and Vim would never do this so coming from Vim, it's rather jarring. Until issue #302 is resolved, would it be too much to ask that the cursor be never be positioned after a final character (on the hidden newline char)?

guillermooo commented 8 years ago

Because this is issue #1000, I think it deserves special attention.

jordwalke commented 8 years ago

:balloon:

jordwalke commented 8 years ago

Related to this issue: https://github.com/guillermooo/Vintageous/issues/1001

jordwalke commented 8 years ago

Seems to be working great!

jordwalke commented 8 years ago

This actually doesn't seem to be working :( I was mistaken. (And shouldn't it always correct after almost every command that leaves you in normal mode - not just redo?)

guillermooo commented 8 years ago

No, just redo.

jordwalke commented 8 years ago

This is what I did to create a much better editing experience that is never messed up when hitting undo/redo (or even cmd+z etc): I'm using the "ChainOfCommand" plugin to achieve sequential commands below. Basically, any of the built in commands will mess up Vintageous undo/redo, so I made them all redirect to Vintageous. Also, after every redo, I just force pressing escape! These are hacks, but I thought I'd shared them as stop gap solutions.

  // Overide the default copy/paste/cut/undo/redo as it messes up undo in Vintageous.
  {"keys": ["super+x"], "command": "press_key", "args": {"key": "x"}, "context": [{"key": "vi_command_mode_aware"}]},
    {"keys": ["super+c"], "command": "press_key", "args": {"key": "y"}, "context": [{"key": "vi_command_mode_aware"}]},
    {"keys": ["super+v"], "command": "press_key", "args": {"key": "p"}, "context": [{"key": "vi_command_mode_aware"}]},

    // When undoing/redoing, sometimes sublime will leave selection highlighted which is devastating,
    // because accidental pressing of "u" will ruin the undo stack!
    {"keys": ["ctrl+r"], "command": "chain", "args": {
          "commands": [
                ["press_key", {"key": "<C-r>"}],
                ["press_key", {"key": "<esc>"}]
          ]
        },
        "context": [{"key": "vi_command_mode_aware"},   {"key": "vi_use_ctrl_keys"}]
    },
    {"keys": ["super+shift+z"], "command": "chain", "args": {
          "commands": [
                ["press_key", {"key": "<C-r>"}],
                ["press_key", {"key": "<esc>"}]
          ]
        },
        "context": [{"key": "vi_command_mode_aware"},   {"key": "vi_use_ctrl_keys"}]
    },
    {"keys": ["u"], "command": "chain", "args": {
          "commands": [
                ["press_key", {"key": "u"}],
                ["press_key", {"key": "<esc>"}]
          ]
        },
        "context": [{"key": "vi_command_mode_aware"},   {"key": "vi_use_ctrl_keys"}]
    },
    {"keys": ["super+z"], "command": "chain", "args": {
          "commands": [
                ["press_key", {"key": "<C-r>"}],
                ["press_key", {"key": "<esc>"}]
          ]
        },
        "context": [{"key": "vi_command_mode_aware"},   {"key": "vi_use_ctrl_keys"}]
    },
guillermooo commented 8 years ago

BTW, the caret xpos should be handled by the relevant command. Any issues like that should be reported separately. (I've fixed de, for example.)