t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 112 forks source link

last cursor position not preserved when clearMultipleCursorsOnEscapeInsertMode is true #899

Closed kentor closed 4 years ago

kentor commented 7 years ago

Check list

Saw this https://github.com/t9md/atom-vim-mode-plus/issues/562 but seems to not work. Check out the gif:

t9md commented 7 years ago

If you can reproduce it, give me complete set of

kentor commented 7 years ago

this is with clearMultipleCursorsOnEscapeInsertMode: true

sample text:

aaaa bbbb
aaaa bbbb

put cursor on top row b (any one, they all behave the same) keystrokes:

cmd+d
cmd+d
c
cccc
escape

final text:

aaaa cccc
aaaa cccc

cursor will be on last c of last row expect cursor to be on last c of first row

t9md commented 7 years ago

cursor will be on last c of last row expect cursor to be on last c of first row

Cursor should be at 2nd(=last row) c, this is designed behavior. Last cursor is the cursor added most recently(thus, 2nd row in this case), see where autocomplete-plus's popup shows up.(It would be shows up at 2nd bbb position in this case).

So IMO, you have wrong expectation what last cursor is.

kentor commented 7 years ago

hmm interesting that the autocomplete-plus shows up on the 2nd cursor

but i would still expect the cursor to go back to where you originally started the multiple cursors with cmd+d, and i have two cases for why:

if you turn off vim-mode-plus, and repeat the same thing with

cmd+d
cmd+d
cccc
escape

the cursor will be on the first row.

this is also the behavior that i am used to on sublime text's vim mode + multiple cursors and vscode's vscodevim + multiple cursors

t9md commented 7 years ago

For specific scenario you explained above, I understand your request.

But that behavior is based on behavior Atom-core not respect last-cursor position when merging multiple-cursor(or selections). I intentionally avoid using that atom-core's behavior, it might be good in some scenario(like you explained), but bad for many other scenarios.

I can add this as opt-in-by-config feature(not so motivated though for me). Will keep open for a while to collect feedback from others.

trkoch commented 6 years ago

My expectations align with @kentor. With clearMultipleCursorsOnEscapeInsertMode enabled I'd expect the first added cursor's position to be respected.

In terms of tests found in vim-state-spec.coffee this is the expected behaviour.

describe "clearMultipleCursorsOnEscapeInsertMode setting", ->
  beforeEach ->
    set
      text: 'abc'
      cursor: [[0, 1], [0, 2]]

  describe "when enabled, clear multiple cursors on escaping insert-mode", ->
    beforeEach ->
      settings.set('clearMultipleCursorsOnEscapeInsertMode', true)
    it "clear multiple cursors by respecting first added cursor's position", ->
      ensure 'escape', mode: 'normal', numCursors: 1, cursor: [0, 0]

    it "clear multiple cursors by respecting first added cursor's position", ->
      set cursor: [[0, 2], [0, 1]]
      ensure 'escape', mode: 'normal', numCursors: 1, cursor: [0, 1]
trkoch commented 6 years ago

By the way, I should add this (reversed) behaviour aligns with default Atom when adding cursors with cmd+d, making changes and finally clearing cursors with esc. Currently my workaround is to clear multiple cursors while in insert mode.