guillermooo / Vintageous

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

Visual indent leaves cursor at incorrect location #183

Closed jordwalke closed 11 years ago

jordwalke commented 11 years ago

Insert:

one
two
three

Place your cursor in normal mode on the three. Press V for linewise visual mode. Move up to the one to select all three lines. Then press >. Your cursor should remain at the top on line one - this is what vim does. The current cursor behavior of jumping back down messes up the repeat command.

I notice that when selecting from the top down, and shifting with >, everything works.

The Vim behavior seems to be: Always leave the cursor at the topmost part of the selection, regardless of where the selection began. Strange but works well and is engrained into my muscle memory.

guillermooo commented 11 years ago

It seems Vim normalizes motions to always be top-down. That makes sense. This one looks like a big feature.

BTW, if you try repeating in line 'three', you do get the expecter result, right?

guillermooo commented 11 years ago

Potential fix:

The first run of a command including downward motions would run normally. When repeating, we'd include an 'is_repeating' flag so 'vi_run' knows it must reverse the motion. I suppose that means we'd need to define antonyms for each downward motion too. This should work for visual line mode; not so sure about visual mode.

guillermooo commented 11 years ago

Then again, I haven't double-checked with Vim wether the reversal occurs in every mode. I suspect it might be only in visual line mode, which would be geat news.

jordwalke commented 11 years ago

I believe that if I try repeating at line three it does the correct thing (but I have to move my cursor there - it doesn't even remain at three when selecting bottom up - indenting moves my cursor down one extra line oddly)

guillermooo commented 11 years ago

This one seems pretty tough to solve. I need to think longer about how to reverse the motion's direction when repeating commands.