mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-10 18:53:47 -05:00
Do not break undo sequence when moving cursor
This commit is contained in:
@@ -1429,12 +1429,13 @@ function! s:PlaceDelimitersAndInsBetween() abort
|
|||||||
" Otherwise, use 'i'.
|
" Otherwise, use 'i'.
|
||||||
let insert = col('.') > strlen(getline('.')) ? 'a' : 'i'
|
let insert = col('.') > strlen(getline('.')) ? 'a' : 'i'
|
||||||
" 2. Insert comment delimiters.
|
" 2. Insert comment delimiters.
|
||||||
" 3. Move the cursor to the left of the closing delimiter.
|
" 3. Move the cursor to the left of the closing delimiter, without
|
||||||
|
" breaking undo sequence.
|
||||||
" 4. Enter insert normal mode again without changing the cursor position.
|
" 4. Enter insert normal mode again without changing the cursor position.
|
||||||
" This ensures that returning to the insert mode after finishing the
|
" This ensures that returning to the insert mode after finishing the
|
||||||
" script execution does not move the cursor.
|
" script execution does not move the cursor.
|
||||||
" ( 1 ) ( 2 ) ( 3 ) ( 4 )
|
" ( 1 ) ( 2 ) ( 3 ) ( 4 )
|
||||||
execute 'normal!' insert . left . right . repeat("\<Left>", strchars(right)) . "\<C-\>\<C-O>"
|
execute 'normal!' insert . left . right . repeat("\<C-G>U\<Left>", strchars(right)) . "\<C-\>\<C-O>"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:RemoveDelimiters(left, right, line)
|
" Function: s:RemoveDelimiters(left, right, line)
|
||||||
|
|||||||
Reference in New Issue
Block a user