Skip to content

Commit 26e8c8d

Browse files
authored
Merge pull request #362 from KapJI/fix-undo
Fix undo hunk
2 parents 98c693f + fb4d1e1 commit 26e8c8d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

autoload/sy/repo.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function! s:undo_hunk(sy, vcs, diff) abort
413413
return
414414
endif
415415

416-
let [_old_line, _old_count, new_line, _new_count] = sy#sign#parse_hunk(header)
416+
let [_old_line, _old_count, new_line, new_count] = sy#sign#parse_hunk(header)
417417

418418
for line in hunk
419419
let op = line[0]
@@ -425,7 +425,7 @@ function! s:undo_hunk(sy, vcs, diff) abort
425425
endif
426426
let new_line += 1
427427
elseif op == '-'
428-
call append(new_line-1, text)
428+
call append(new_count == 0 ? new_line : new_line - 1, text)
429429
let new_line += 1
430430
elseif op == '+'
431431
if text != getline(new_line)

0 commit comments

Comments
 (0)