diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/eval/special_vars_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/legacy/packadd_spec.lua | 23 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 38 | ||||
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 95 |
4 files changed, 154 insertions, 14 deletions
diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua index b5773a5529..97a12d490d 100644 --- a/test/functional/eval/special_vars_spec.lua +++ b/test/functional/eval/special_vars_spec.lua @@ -174,5 +174,17 @@ describe('Special values', function() command('let count = []') -- v:count is readonly eq(1, eval('count is# g:["count"]')) end) + it('v:errmsg is distinct from errmsg', function() + command('let errmsg = 1') + eq(1, eval('errmsg is# g:["errmsg"]')) + end) + it('v:shell_error is distinct from shell_error', function() + command('let shell_error = []') -- v:shell_error is readonly + eq(1, eval('shell_error is# g:["shell_error"]')) + end) + it('v:this_session is distinct from this_session', function() + command('let this_session = []') + eq(1, eval('this_session is# g:["this_session"]')) + end) end) end) diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index fb308475c0..67f6006d1d 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -58,6 +58,24 @@ describe('packadd', function() call assert_fails("packadd", 'E471:') endfunc + func Test_packadd_start() + let plugdir = expand(s:topdir . '/pack/mine/start/other') + call mkdir(plugdir . '/plugin', 'p') + set rtp& + let rtp = &rtp + filetype on + + exe 'split ' . plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 24') + wq + + packadd other + + call assert_equal(24, g:plugin_works) + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ (escape(plugdir, '\') . '\($\|,\)')) + endfunc + func Test_packadd_noload() call mkdir(s:plugdir . '/plugin', 'p') call mkdir(s:plugdir . '/syntax', 'p') @@ -286,6 +304,11 @@ describe('packadd', function() expected_empty() end) + it('loads packages from "start" directory', function() + call('Test_packadd_start') + expected_empty() + end) + describe('command line completion', function() local Screen = require('test.functional.ui.screen') local screen diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index d71d8cf3a8..c40b2210ff 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -73,6 +73,7 @@ local helpers = require('test.functional.helpers')(nil) local request, run, uimeths = helpers.request, helpers.run, helpers.uimeths +local eq = helpers.eq local dedent = helpers.dedent local Screen = {} @@ -389,12 +390,21 @@ function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info) end function Screen:_handle_clear() + -- the first implemented UI protocol clients (python-gui and builitin TUI) + -- allowed the cleared region to be restricted by setting the scroll region. + -- this was never used by nvim tough, and not documented and implemented by + -- newer clients, to check we remain compatible with both kind of clients, + -- ensure the scroll region is in a reset state. + local expected_region = { + top = 1, bot = self._height, left = 1, right = self._width + } + eq(expected_region, self._scroll_region) self:_clear_block(1, self._height, 1, self._width) end function Screen:_handle_grid_clear(grid) assert(grid == 1) - self:_handle_clear() + self:_clear_block(1, self._height, 1, self._width) end function Screen:_handle_eol_clear() @@ -446,22 +456,30 @@ function Screen:_handle_scroll(count) local bot = self._scroll_region.bot local left = self._scroll_region.left local right = self._scroll_region.right + self:_handle_grid_scroll(1, top-1, bot, left-1, right, count, 0) +end + +function Screen:_handle_grid_scroll(grid, top, bot, left, right, rows, cols) + top = top+1 + left = left+1 + assert(grid == 1) + assert(cols == 0) local start, stop, step - if count > 0 then + if rows > 0 then start = top - stop = bot - count + stop = bot - rows step = 1 else start = bot - stop = top - count + stop = top - rows step = -1 end -- shift scroll region for i = start, stop, step do local target = self._rows[i] - local source = self._rows[i + count] + local source = self._rows[i + rows] for j = left, right do target[j].text = source[j].text target[j].attrs = source[j].attrs @@ -470,19 +488,11 @@ function Screen:_handle_scroll(count) end -- clear invalid rows - for i = stop + step, stop + count, step do + for i = stop + step, stop + rows, step do self:_clear_row_section(i, left, right) end end -function Screen:_handle_grid_scroll(grid, top, bot, left, right, rows, cols) - assert(grid == 1) - assert(cols == 0) - -- TODO: if we truly believe we should translate the other way - self:_handle_set_scroll_region(top,bot-1,left,right-1) - self:_handle_scroll(rows) -end - function Screen:_handle_hl_attr_define(id, rgb_attrs, cterm_attrs, info) self._attr_table[id] = {rgb_attrs, cterm_attrs} self._hl_info[id] = info diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 75a2d4978d..957d8c0915 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -354,6 +354,101 @@ local function screen_tests(newgrid) {0:~ }| | ]]) + + feed(':echo "'..string.rep('x\\n', 12)..'"<cr>') + screen:expect([[ + x | + x | + x | + x | + x | + x | + x | + x | + x | + x | + x | + x | + | + {7:Press ENTER or type command to continue}^ | + ]]) + + feed('<cr>') + screen:expect([[ + {4: [No Name] }{2: [No Name] }{3: }{4:X}| + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + end) + + it('redraws properly with :tab split right after scroll', function() + feed('30Ofoo<esc>gg') + + command('vsplit') + screen:expect([[ + ^foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + {1:[No Name] [+] }{3:[No Name] [+] }| + | + ]]) + + feed('<PageDown>') + screen:expect([[ + ^foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + foo {3:│}foo | + {1:[No Name] [+] }{3:[No Name] [+] }| + | + ]]) + + command('tab split') + screen:expect([[ + {4: }{5:2}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| + ^foo | + foo | + foo | + foo | + foo | + foo | + foo | + foo | + foo | + foo | + foo | + foo | + | + ]]) end) end) |