monaco-vim
monaco-vim copied to clipboard
Paste in visual mode does not replace last character
When pasting in visual mode, the last character in the selection (the character under the cursor) is not replaced. To reproduce, enter into visual mode, make a selection, press yank, make the same selection again, and then paste.
I tried to dig into this a bit and noticed that, when yanking, there is a one character offset added to either the head or the anchor (see makeCmSelection
, L3116 to L3119). This doesn't happen when pasting. I came up with a naive solution by adding 1
to selectionEnd.ch
after L2597:
var selectionEnd = selectedArea[1];
// Added the following two lines
selectionEnd.ch += 1;
cm.setSelection(selectionStart, selectionEnd)
var selectedText = cm.getSelection();
It would be great to get this behavior fixed so that it mimics vim :) Thanks so much!
Likely related: https://github.com/googlecolab/colabtools/issues/2748