Skip to content

Commit 5e4e1b1

Browse files
committed
patch 8.0.0205: wrong behavior after :undojoin
Problem: After :undojoin some commands don't work properly, such as :redo. (Matthew Malcomson) Solution: Don't set curbuf->b_u_curhead. (closes #1390)
1 parent eb46f8f commit 5e4e1b1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/testdir/test_undo.vim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,17 @@ func Test_undojoin()
176176
call assert_equal(['aaaa', 'bbbb', 'cccc'], getline(2, '$'))
177177
call feedkeys("u", 'xt')
178178
call assert_equal(['aaaa'], getline(2, '$'))
179-
close!
179+
bwipe!
180+
endfunc
181+
182+
func Test_undojoin_redo()
183+
new
184+
call setline(1, ['first line', 'second line'])
185+
call feedkeys("ixx\<Esc>", 'xt')
186+
call feedkeys(":undojoin | redo\<CR>", 'xt')
187+
call assert_equal('xxfirst line', getline(1))
188+
call assert_equal('second line', getline(2))
189+
bwipe!
180190
endfunc
181191

182192
func Test_undo_write()

src/undo.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,11 +3136,8 @@ ex_undojoin(exarg_T *eap UNUSED)
31363136
if (get_undolevel() < 0)
31373137
return; /* no entries, nothing to do */
31383138
else
3139-
{
3140-
/* Go back to the last entry */
3141-
curbuf->b_u_curhead = curbuf->b_u_newhead;
3142-
curbuf->b_u_synced = FALSE; /* no entries, nothing to do */
3143-
}
3139+
/* Append next change to the last entry */
3140+
curbuf->b_u_synced = FALSE;
31443141
}
31453142

31463143
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
205,
767769
/**/
768770
204,
769771
/**/

0 commit comments

Comments
 (0)