diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/api/window_spec.lua | 106 | ||||
| -rw-r--r-- | test/functional/legacy/display_spec.lua | 103 |
2 files changed, 150 insertions, 59 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 901d24327c..7c65cf9c37 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -15,25 +15,6 @@ local command = helpers.command local pcall_err = helpers.pcall_err local assert_alive = helpers.assert_alive --- check if str is visible at the beginning of some line -local function is_visible(str) - local slen = string.len(str) - local nlines = eval("&lines") - for i = 1,nlines do - local iseq = true - for j = 1,slen do - if string.byte(str,j) ~= eval("screenchar("..i..","..j..")") then - iseq = false - break - end - end - if iseq then - return true - end - end - return false -end - describe('API/win', function() before_each(clear) @@ -79,27 +60,61 @@ describe('API/win', function() end) it('updates the screen, and also when the window is unfocused', function() + local screen = Screen.new(30, 9) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, + [2] = {bold = true, reverse = true}; + [3] = {reverse = true}; + }) + screen:attach() + insert("prologue") feed('100o<esc>') insert("epilogue") local win = curwin() feed('gg') - poke_eventloop() -- let nvim process the 'gg' command + screen:expect{grid=[[ + ^prologue | + | + | + | + | + | + | + | + | + ]]} -- cursor position is at beginning eq({1, 0}, window('get_cursor', win)) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) -- move cursor to end window('set_cursor', win, {101, 0}) - eq(false, is_visible("prologue")) - eq(true, is_visible("epilogue")) + screen:expect{grid=[[ + | + | + | + | + | + | + | + ^epilogue | + | + ]]} -- move cursor to the beginning again window('set_cursor', win, {1, 0}) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^prologue | + | + | + | + | + | + | + | + | + ]]} -- move focus to new window nvim('command',"new") @@ -107,18 +122,45 @@ describe('API/win', function() -- sanity check, cursor position is kept eq({1, 0}, window('get_cursor', win)) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + prologue | + | + | + {3:[No Name] [+] }| + | + ]]} -- move cursor to end window('set_cursor', win, {101, 0}) - eq(false, is_visible("prologue")) - eq(true, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + | + | + epilogue | + {3:[No Name] [+] }| + | + ]]} -- move cursor to the beginning again window('set_cursor', win, {1, 0}) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + prologue | + | + | + {3:[No Name] [+] }| + | + ]]} -- curwin didn't change back neq(win, curwin()) diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua index f0ffaf2c48..9160129a02 100644 --- a/test/functional/legacy/display_spec.lua +++ b/test/functional/legacy/display_spec.lua @@ -9,6 +9,7 @@ local command = helpers.command describe('display', function() before_each(clear) + -- oldtest: Test_display_scroll_at_topline() it('scroll when modified at topline vim-patch:8.2.1488', function() local screen = Screen.new(20, 4) screen:attach() @@ -26,6 +27,7 @@ describe('display', function() ]]) end) + -- oldtest: Test_display_scroll_update_visual() it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function() local screen = Screen.new(60, 8) screen:attach() @@ -56,8 +58,8 @@ describe('display', function() ]]) end) - it('@@@ in the last line shows correctly in a narrow window vim-patch:8.2.4718', function() - local screen = Screen.new(60, 10) + local function run_test_display_lastline(euro) + local screen = Screen.new(75, 10) screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText [2] = {bold = true, reverse = true}, -- StatusLine @@ -65,39 +67,86 @@ describe('display', function() }) screen:attach() exec([[ - call setline(1, ['aaa', 'b'->repeat(100)]) + call setline(1, ['aaa', 'b'->repeat(200)]) set display=truncate + vsplit 100wincmd < ]]) - screen:expect([[ - ^a│aaa | - a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| - a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | - b│{1:~ }| - b│{1:~ }| - b│{1:~ }| - b│{1:~ }| - {1:@}│{1:~ }| - {2:< }{3:[No Name] [+] }| - | - ]]) + local fillchar = '@' + if euro then + command('set fillchars=lastline:€') + fillchar = '€' + end + screen:expect((([[ + ^a│aaa | + a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + b│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + b│{1:~ }| + b│{1:~ }| + b│{1:~ }| + {1:@}│{1:~ }| + {2:< }{3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + command('set display=lastline') screen:expect_unchanged() + command('100wincmd >') - screen:expect([[ - ^aaa │a| - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │a| - {1:~ }│b| - {1:~ }│b| - {1:~ }│b| - {1:~ }│b| - {1:~ }│{1:@}| - {2:[No Name] [+] }{3:<}| - | - ]]) + screen:expect((([[ + ^aaa │a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │b| + {1:~ }│b| + {1:~ }│b| + {1:~ }│b| + {1:~ }│{1:@}| + {2:[No Name] [+] }{3:<}| + | + ]]):gsub('@', fillchar))) + command('set display=truncate') screen:expect_unchanged() + + command('close') + command('3split') + screen:expect((([[ + ^aaa | + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {1:@@@ }| + {2:[No Name] [+] }| + aaa | + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + {3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + + command('close') + command('2vsplit') + screen:expect((([[ + ^aa│aaa | + a │bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + bb│{1:~ }| + bb│{1:~ }| + bb│{1:~ }| + {1:@@}│{1:~ }| + {2:< }{3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + end + + -- oldtest: Test_display_lastline() + it('display "lastline" works correctly', function() + run_test_display_lastline() + end) + it('display "lastline" works correctly with multibyte fillchar', function() + run_test_display_lastline(true) end) end) |