mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
vim-patch:8.1.1552: cursor position is wrong after sign column changes
Problem: Cursor position is wrong after sign column appears or disappears.
(Yegappan Lakshmanan)
Solution: Call changed_line_abv_curs() instead of changed_cline_bef_curs().
f85e40afc2
This commit is contained in:
@@ -198,7 +198,7 @@ static void insert_sign(
|
|||||||
// column for signs.
|
// column for signs.
|
||||||
if (buf->b_signlist == NULL) {
|
if (buf->b_signlist == NULL) {
|
||||||
redraw_buf_later(buf, NOT_VALID);
|
redraw_buf_later(buf, NOT_VALID);
|
||||||
changed_cline_bef_curs();
|
changed_line_abv_curs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// first sign in signlist
|
// first sign in signlist
|
||||||
@@ -495,11 +495,11 @@ linenr_T buf_delsign(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When deleted the last sign needs to redraw the windows to remove the
|
// When deleting the last sign the cursor position may change, because the
|
||||||
// sign column.
|
// sign columns no longer shows. And the 'signcolumn' may be hidden.
|
||||||
if (buf->b_signlist == NULL) {
|
if (buf->b_signlist == NULL) {
|
||||||
redraw_buf_later(buf, NOT_VALID);
|
redraw_buf_later(buf, NOT_VALID);
|
||||||
changed_cline_bef_curs();
|
changed_line_abv_curs();
|
||||||
}
|
}
|
||||||
|
|
||||||
return lnum;
|
return lnum;
|
||||||
@@ -572,7 +572,7 @@ void buf_delete_signs(buf_T *buf, char_u *group)
|
|||||||
// When deleting the last sign need to redraw the windows to remove the
|
// When deleting the last sign need to redraw the windows to remove the
|
||||||
// sign column. Not when curwin is NULL (this means we're exiting).
|
// sign column. Not when curwin is NULL (this means we're exiting).
|
||||||
if (buf->b_signlist != NULL && curwin != NULL) {
|
if (buf->b_signlist != NULL && curwin != NULL) {
|
||||||
changed_cline_bef_curs();
|
changed_line_abv_curs();
|
||||||
}
|
}
|
||||||
|
|
||||||
lastp = &buf->b_signlist;
|
lastp = &buf->b_signlist;
|
||||||
|
@@ -4,6 +4,8 @@ if !has('signs')
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
source screendump.vim
|
||||||
|
|
||||||
func Test_sign()
|
func Test_sign()
|
||||||
new
|
new
|
||||||
call setline(1, ['a', 'b', 'c', 'd'])
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
@@ -1652,3 +1654,31 @@ func Test_sign_jump_func()
|
|||||||
sign undefine sign1
|
sign undefine sign1
|
||||||
enew! | only!
|
enew! | only!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for correct cursor position after the sign column appears or disappears.
|
||||||
|
func Test_sign_cursor_position()
|
||||||
|
if !CanRunVimInTerminal()
|
||||||
|
throw 'Skipped: cannot make screendumps'
|
||||||
|
endif
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
|
||||||
|
call cursor(2,1)
|
||||||
|
sign define s1 texthl=Search text==>
|
||||||
|
redraw
|
||||||
|
sign place 10 line=2 name=s1
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XtestSigncolumn')
|
||||||
|
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
|
||||||
|
call VerifyScreenDump(buf, 'Test_sign_cursor_01', {})
|
||||||
|
|
||||||
|
" update cursor position calculation
|
||||||
|
call term_sendkeys(buf, "lh")
|
||||||
|
call term_sendkeys(buf, ":sign unplace 10\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_sign_cursor_02', {})
|
||||||
|
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XtestSigncolumn')
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user