diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-28 07:47:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-28 07:47:22 +0800 |
commit | d82e105727475aa18720bd0b12103c23600e7ca0 (patch) | |
tree | a993ebb7b9bbc678ad57ecb51ed30e087103e3f9 /test | |
parent | 7f9fc2fbf03e18c1e4033763be4905707d7a84e7 (diff) | |
download | rneovim-d82e105727475aa18720bd0b12103c23600e7ca0.tar.gz rneovim-d82e105727475aa18720bd0b12103c23600e7ca0.tar.bz2 rneovim-d82e105727475aa18720bd0b12103c23600e7ca0.zip |
vim-patch:9.0.2187: Visual not drawn with 'breakindent' when line doesn't fit (#26765)
Problem: Visual selection isn't drawn with 'breakindent' when the line
doesn't fit in the window (Jaehwang Jung)
Solution: Adjust wlv->fromcol also for 'breakindent' (zeertzjq)
closes: vim/vim#13767
closes: vim/vim#13768
https://github.com/vim/vim/commit/23627722d36b49e38ba6f8dc6bb3ebe19c98a83b
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/breakindent_spec.lua | 64 | ||||
-rw-r--r-- | test/old/testdir/test_breakindent.vim | 23 |
2 files changed, 83 insertions, 4 deletions
diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua index 5e3ce27f91..8bf08bca7f 100644 --- a/test/functional/legacy/breakindent_spec.lua +++ b/test/functional/legacy/breakindent_spec.lua @@ -26,6 +26,7 @@ describe('breakindent', function() eval repeat('x', &columns - leftcol - 1)->setline(1) eval 'second line'->setline(2) ]]) + feed('AX') screen:expect([[ {1: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX| @@ -41,20 +42,75 @@ describe('breakindent', function() screen:expect_unchanged() -- The first line now wraps because of "eol" in 'listchars'. command('setlocal list') - screen:expect{grid=[[ + screen:expect([[ {1: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX| {1: } {0:+^$} | {1: }second line{0:$} | {0:~ }|*2 {2:-- INSERT --} | - ]]} + ]]) command('setlocal nobreakindent') - screen:expect{grid=[[ + screen:expect([[ {1: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX| {1: }{0:+^$} | {1: }second line{0:$} | {0:~ }|*2 {2:-- INSERT --} | - ]]} + ]]) + end) + + -- oldtest: Test_visual_starts_before_skipcol() + it('Visual selection that starts before skipcol shows correctly', function() + local screen = Screen.new(75, 6) + exec([[ + 1new + setlocal breakindent + call setline(1, "\t" .. join(range(100))) + ]]) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {background = Screen.colors.LightGrey}, -- Visual + [2] = {bold = true, reverse = true}, -- StatusLine + [3] = {reverse = true}, -- StatusLineNC + [4] = {bold = true}, -- ModeMsg + }) + screen:attach() + + feed('v$') + screen:expect([[ + {0:<<<} {1: 93 94 95 96 97 98 99}^ | + {2:[No Name] [+] }| + | + {0:~ }| + {3:[No Name] }| + {4:-- VISUAL --} | + ]]) + command('setlocal showbreak=+++') + screen:expect([[ + {0:+++}{1: 90 91 92 93 94 95 96 97 98 99}^ | + {2:[No Name] [+] }| + | + {0:~ }| + {3:[No Name] }| + {4:-- VISUAL --} | + ]]) + command('setlocal breakindentopt+=sbr') + screen:expect([[ + {0:+++} {1: 93 94 95 96 97 98 99}^ | + {2:[No Name] [+] }| + | + {0:~ }| + {3:[No Name] }| + {4:-- VISUAL --} | + ]]) + command('setlocal nobreakindent') + screen:expect([[ + {0:+++}{1: 98 99}^ | + {2:[No Name] [+] }| + | + {0:~ }| + {3:[No Name] }| + {4:-- VISUAL --} | + ]]) end) end) diff --git a/test/old/testdir/test_breakindent.vim b/test/old/testdir/test_breakindent.vim index 301e2d0e40..426f8ab278 100644 --- a/test/old/testdir/test_breakindent.vim +++ b/test/old/testdir/test_breakindent.vim @@ -963,6 +963,29 @@ func Test_cursor_position_with_showbreak() call StopVimInTerminal(buf) endfunc +func Test_visual_starts_before_skipcol() + CheckScreendump + + let lines =<< trim END + 1new + setlocal breakindent + call setline(1, "\t" .. join(range(100))) + END + call writefile(lines, 'XvisualStartsBeforeSkipcol', 'D') + let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6}) + + call term_sendkeys(buf, "v$") + call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {}) + call term_sendkeys(buf, "\<Esc>:setlocal showbreak=+++\<CR>gv") + call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {}) + call term_sendkeys(buf, "\<Esc>:setlocal breakindentopt+=sbr\<CR>gv") + call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_3', {}) + call term_sendkeys(buf, "\<Esc>:setlocal nobreakindent\<CR>gv") + call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_4', {}) + + call StopVimInTerminal(buf) +endfunc + func Test_no_spurious_match() let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50)) call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls') |