mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
Merge pull request #17953 from zeertzjq/vim-8.2.4660
vim-patch:8.2.4660: cursorcolumn is sometimes not correct
This commit is contained in:
@@ -390,9 +390,13 @@ static void insert_enter(InsertState *s)
|
|||||||
trigger_modechanged();
|
trigger_modechanged();
|
||||||
stop_insert_mode = false;
|
stop_insert_mode = false;
|
||||||
|
|
||||||
// Need to recompute the cursor position, it might move when the cursor is
|
// Need to recompute the cursor position, it might move when the cursor
|
||||||
// on a TAB or special character.
|
// is on a TAB or special character.
|
||||||
|
// ptr2cells() treats a TAB character as double-width.
|
||||||
|
if (ptr2cells(get_cursor_pos_ptr()) > 1) {
|
||||||
|
curwin->w_valid &= ~VALID_VIRTCOL;
|
||||||
curs_columns(curwin, true);
|
curs_columns(curwin, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Enable langmap or IME, indicated by 'iminsert'.
|
// Enable langmap or IME, indicated by 'iminsert'.
|
||||||
// Note that IME may enabled/disabled without us noticing here, thus the
|
// Note that IME may enabled/disabled without us noticing here, thus the
|
||||||
|
@@ -597,6 +597,28 @@ func Test_cursorline_with_visualmode()
|
|||||||
call delete('Xtest_cursorline_with_visualmode')
|
call delete('Xtest_cursorline_with_visualmode')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_cursorcolumn_insert_on_tab()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, ['123456789', "a\tb"])
|
||||||
|
set cursorcolumn
|
||||||
|
call cursor(2, 2)
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xcuc_insert_on_tab')
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S Xcuc_insert_on_tab', #{rows: 8})
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_1', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, 'i')
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_2', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xcuc_insert_on_tab')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_cursorcolumn_callback()
|
func Test_cursorcolumn_callback()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
CheckFeature timers
|
CheckFeature timers
|
||||||
|
@@ -1306,14 +1306,48 @@ describe('CursorLine and CursorLineNr highlights', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('CursorColumn highlight', function()
|
describe('CursorColumn highlight', function()
|
||||||
before_each(clear)
|
local screen
|
||||||
it('is updated if cursor is moved from timer', function()
|
before_each(function()
|
||||||
local screen = Screen.new(50, 8)
|
clear()
|
||||||
|
screen = Screen.new(50, 8)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[1] = {background = Screen.colors.Gray90}, -- CursorColumn
|
[1] = {background = Screen.colors.Gray90}, -- CursorColumn
|
||||||
[2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
|
[2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
|
||||||
|
[3] = {bold = true}, -- ModeMsg
|
||||||
})
|
})
|
||||||
screen:attach()
|
screen:attach()
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('is updated when pressing "i" on a TAB character', function()
|
||||||
|
exec([[
|
||||||
|
call setline(1, ['123456789', "a\tb"])
|
||||||
|
set cursorcolumn
|
||||||
|
call cursor(2, 2)
|
||||||
|
]])
|
||||||
|
screen:expect([[
|
||||||
|
1234567{1:8}9 |
|
||||||
|
a ^ b |
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('i')
|
||||||
|
screen:expect([[
|
||||||
|
1{1:2}3456789 |
|
||||||
|
a^ b |
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{2:~ }|
|
||||||
|
{3:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('is updated if cursor is moved from timer', function()
|
||||||
exec([[
|
exec([[
|
||||||
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
|
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
|
||||||
set cursorcolumn
|
set cursorcolumn
|
||||||
|
@@ -256,6 +256,40 @@ describe('Screen', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
end) -- a region of text (implicit concealing)
|
end) -- a region of text (implicit concealing)
|
||||||
|
|
||||||
|
it("cursor position is correct when entering Insert mode with cocu=ni #13916", function()
|
||||||
|
insert([[foobarfoobarfoobar]])
|
||||||
|
-- move to end of line
|
||||||
|
feed("$")
|
||||||
|
command("set concealcursor=ni")
|
||||||
|
command("syn match Foo /foobar/ conceal cchar=&")
|
||||||
|
screen:expect([[
|
||||||
|
{1:&&&}^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed("i")
|
||||||
|
-- cursor should stay in place, not jump to column 16
|
||||||
|
screen:expect([[
|
||||||
|
{1:&&&}^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{4:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end) -- match and conceal
|
end) -- match and conceal
|
||||||
|
|
||||||
describe("let the conceal level be", function()
|
describe("let the conceal level be", function()
|
||||||
|
Reference in New Issue
Block a user