Skip to content

Commit

Permalink
Merge pull request #25022 from neovim/backport-25021-to-release-0.9
Browse files Browse the repository at this point in the history
[Backport release-0.9] vim-patch:9.0.1866: undo is synced after character find
  • Loading branch information
zeertzjq committed Sep 4, 2023
2 parents 6490d93 + 4728f2d commit 3a13777
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nvim/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ static void normal_get_additional_char(NormalState *s)
// because if it's put back with vungetc() it's too late to apply
// mapping.
no_mapping--;
while (lang && (s->c = vpeekc()) > 0
while ((s->c = vpeekc()) > 0
&& (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) {
s->c = plain_vgetc();
if (!utf_iscomposing(s->c)) {
Expand All @@ -827,7 +827,9 @@ static void normal_get_additional_char(NormalState *s)
// but when replaying a recording the next key is already in the
// typeahead buffer, so record a <Nop> before that to prevent the
// vpeekc() above from applying wrong mappings when replaying.
no_u_sync++;
gotchars_nop();
no_u_sync--;
}
}
no_mapping--;
Expand Down
10 changes: 10 additions & 0 deletions test/old/testdir/test_undo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -801,5 +801,15 @@ func Test_undo_after_write()
call delete('Xtestfile.txt')
endfunc

func Test_undo_range_normal()
new
call setline(1, ['asa', 'bsb'])
let &l:undolevels = &l:undolevels
%normal dfs
call assert_equal(['a', 'b'], getline(1, '$'))
undo
call assert_equal(['asa', 'bsb'], getline(1, '$'))
bwipe!
endfunc

" vim: shiftwidth=2 sts=2 expandtab

0 comments on commit 3a13777

Please sign in to comment.