aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-05-08 15:43:45 +0300
committerZyX <kp-pav@yandex.ru>2017-05-08 15:43:45 +0300
commit09f849b60000c2d401d82f2b2fb2badde5583658 (patch)
tree662d17ea2e905f4136abef2d003014cb7dc914d4 /test/functional/ui
parent1d7fde39a6927d01de74aefb540ad445bfdfbfda (diff)
parenta9605bb4aff76a934a4c39fbda093ee8fc8a1c71 (diff)
downloadrneovim-09f849b60000c2d401d82f2b2fb2badde5583658.tar.gz
rneovim-09f849b60000c2d401d82f2b2fb2badde5583658.tar.bz2
rneovim-09f849b60000c2d401d82f2b2fb2badde5583658.zip
Merge branch 'master' into luaviml'/lua
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/cursor_spec.lua284
-rw-r--r--test/functional/ui/highlight_spec.lua45
-rw-r--r--test/functional/ui/inccommand_spec.lua25
-rw-r--r--test/functional/ui/mode_spec.lua227
-rw-r--r--test/functional/ui/screen.lua35
-rw-r--r--test/functional/ui/screen_basic_spec.lua131
-rw-r--r--test/functional/ui/tabline_spec.lua57
-rw-r--r--test/functional/ui/wildmode_spec.lua21
8 files changed, 541 insertions, 284 deletions
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 02e9422781..e6036a6b79 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -18,138 +18,155 @@ describe('ui/cursor', function()
end)
it("'guicursor' is published as a UI event", function()
- local expected_cursor_style = {
- cmdline_hover = {
- mouse_shape = 0,
- short_name = 'e' },
- cmdline_insert = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 25,
- cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 47,
- mouse_shape = 0,
- short_name = 'ci' },
- cmdline_normal = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ local expected_mode_info = {
+ [1] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ name = 'normal',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'c' },
- cmdline_replace = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 20,
- cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 47,
+ short_name = 'n' },
+ [2] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ name = 'visual',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'cr' },
- insert = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'v' },
+ [3] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 25,
cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 47,
+ name = 'insert',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'i' },
- more = {
- mouse_shape = 0,
- short_name = 'm' },
- more_lastline = {
+ [4] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 20,
+ cursor_shape = 'horizontal',
+ name = 'replace',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'ml' },
- normal = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'r' },
+ [5] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ name = 'cmdline_normal',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'n' },
- operator = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 50,
+ short_name = 'c' },
+ [6] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 25,
+ cursor_shape = 'vertical',
+ name = 'cmdline_insert',
+ hl_id = 0,
+ id_lm = 0,
+ mouse_shape = 0,
+ short_name = 'ci' },
+ [7] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 20,
cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 46,
+ name = 'cmdline_replace',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'o' },
- replace = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ short_name = 'cr' },
+ [8] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 20,
cursor_shape = 'horizontal',
- hl_id = 46,
- id_lm = 47,
+ name = 'operator',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'r' },
- showmatch = {
- blinkoff = 150,
- blinkon = 175,
- blinkwait = 175,
- cell_percentage = 0,
- cursor_shape = 'block',
- hl_id = 46,
- id_lm = 46,
- short_name = 'sm' },
- statusline_drag = {
+ short_name = 'o' },
+ [9] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 25,
+ cursor_shape = 'vertical',
+ name = 'visual_select',
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
- short_name = 'sd' },
- statusline_hover = {
+ short_name = 've' },
+ [10] = {
+ name = 'cmdline_hover',
+ mouse_shape = 0,
+ short_name = 'e' },
+ [11] = {
+ name = 'statusline_hover',
mouse_shape = 0,
short_name = 's' },
- visual = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 0,
- cursor_shape = 'block',
- hl_id = 46,
- id_lm = 47,
+ [12] = {
+ name = 'statusline_drag',
mouse_shape = 0,
- short_name = 'v' },
- visual_select = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 35,
- cursor_shape = 'vertical',
- hl_id = 46,
- id_lm = 46,
+ short_name = 'sd' },
+ [13] = {
+ name = 'vsep_hover',
mouse_shape = 0,
- short_name = 've' },
- vsep_drag = {
+ short_name = 'vs' },
+ [14] = {
+ name = 'vsep_drag',
mouse_shape = 0,
short_name = 'vd' },
- vsep_hover = {
+ [15] = {
+ name = 'more',
mouse_shape = 0,
- short_name = 'vs' }
- }
+ short_name = 'm' },
+ [16] = {
+ name = 'more_lastline',
+ mouse_shape = 0,
+ short_name = 'ml' },
+ [17] = {
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ name = 'showmatch',
+ hl_id = 0,
+ id_lm = 0,
+ short_name = 'sm' },
+ }
screen:expect(function()
- -- Default 'guicursor' published on startup.
- eq(expected_cursor_style, screen._cursor_style)
+ -- Default 'guicursor', published on startup.
+ eq(expected_mode_info, screen._mode_info)
eq(true, screen._cursor_style_enabled)
eq('normal', screen.mode)
end)
-- Event is published ONLY if the cursor style changed.
- screen._cursor_style = nil
+ screen._mode_info = nil
command("echo 'test'")
screen:expect([[
^ |
@@ -158,20 +175,57 @@ describe('ui/cursor', function()
~ |
test |
]], nil, nil, function()
- eq(nil, screen._cursor_style)
+ eq(nil, screen._mode_info)
end)
-- Change the cursor style.
- meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173,ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
+ helpers.command('set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20'
+ ..',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor'
+ ..',sm:block-blinkwait175-blinkoff150-blinkon175')
+
+ -- Update the expected values.
+ for _, m in ipairs(expected_mode_info) do
+ if m.name == 'showmatch' then
+ if m.blinkon then m.blinkon = 175 end
+ if m.blinkoff then m.blinkoff = 150 end
+ if m.blinkwait then m.blinkwait = 175 end
+ else
+ if m.blinkon then m.blinkon = 250 end
+ if m.blinkoff then m.blinkoff = 400 end
+ if m.blinkwait then m.blinkwait = 700 end
+ end
+ if m.hl_id then m.hl_id = 46 end
+ if m.id_lm then m.id_lm = 47 end
+ end
+
+ -- Assert the new expectation.
screen:expect(function()
- eq('vertical', screen._cursor_style.normal.cursor_shape)
- eq('horizontal', screen._cursor_style.visual_select.cursor_shape)
- eq('vertical', screen._cursor_style.operator.cursor_shape)
- eq('block', screen._cursor_style.insert.cursor_shape)
- eq('vertical', screen._cursor_style.showmatch.cursor_shape)
- eq(171, screen._cursor_style.normal.blinkwait)
- eq(172, screen._cursor_style.normal.blinkoff)
- eq(173, screen._cursor_style.normal.blinkon)
+ eq(expected_mode_info, screen._mode_info)
+ eq(true, screen._cursor_style_enabled)
+ eq('normal', screen.mode)
+ end)
+
+ -- Another cursor style.
+ meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
+ ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
+ screen:expect(function()
+ local named = {}
+ for _, m in ipairs(screen._mode_info) do
+ named[m.name] = m
+ end
+ eq('vertical', named.normal.cursor_shape)
+ eq(35, named.normal.cell_percentage)
+ eq('horizontal', named.visual_select.cursor_shape)
+ eq(35, named.visual_select.cell_percentage)
+ eq('vertical', named.operator.cursor_shape)
+ eq(50, named.operator.cell_percentage)
+ eq('block', named.insert.cursor_shape)
+ eq('vertical', named.showmatch.cursor_shape)
+ eq(90, named.cmdline_replace.cell_percentage)
+ eq(171, named.normal.blinkwait)
+ eq(172, named.normal.blinkoff)
+ eq(173, named.normal.blinkon)
+ eq(42, named.showmatch.cell_percentage)
end)
end)
@@ -180,11 +234,11 @@ describe('ui/cursor', function()
screen:expect(function()
-- Empty 'guicursor' sets enabled=false.
eq(false, screen._cursor_style_enabled)
- for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert',
- 'showmatch', 'normal', 'replace', 'visual',
- 'visual_select', }) do
- eq('block', screen._cursor_style[m].cursor_shape)
- eq(0, screen._cursor_style[m].blinkon)
+ for _, m in ipairs(screen._mode_info) do
+ if m['cursor_shape'] ~= nil then
+ eq('block', m.cursor_shape)
+ eq(0, m.blinkon)
+ end
end
end)
end)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 5f8fafef07..2bda907c33 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -2,23 +2,23 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local os = require('os')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local command = helpers.command
+local eval = helpers.eval
local feed_command, request, eq = helpers.feed_command, helpers.request, helpers.eq
-if helpers.pending_win32(pending) then return end
-
-describe('color scheme compatibility', function()
+describe('colorscheme compatibility', function()
before_each(function()
clear()
end)
it('t_Co is set to 256 by default', function()
- eq('256', request('vim_eval', '&t_Co'))
+ eq('256', eval('&t_Co'))
request('nvim_set_option', 't_Co', '88')
- eq('88', request('vim_eval', '&t_Co'))
+ eq('88', eval('&t_Co'))
end)
end)
-describe('manual syntax highlight', function()
+describe('highlight: `:syntax manual`', function()
-- When using manual syntax highlighting, it should be preserved even when
-- switching buffers... bug did only occur without :set hidden
-- Ref: vim patch 7.4.1236
@@ -63,32 +63,32 @@ describe('manual syntax highlight', function()
end)
it("works with buffer switch and 'nohidden'", function()
- feed_command('e tmp1.vim')
- feed_command('e Xtest-functional-ui-highlight.tmp.vim')
- feed_command('filetype on')
- feed_command('syntax manual')
- feed_command('set ft=vim')
- feed_command('set syntax=ON')
+ command('e tmp1.vim')
+ command('e Xtest-functional-ui-highlight.tmp.vim')
+ command('filetype on')
+ command('syntax manual')
+ command('set filetype=vim fileformat=unix')
+ command('set syntax=ON')
feed('iecho 1<esc>0')
- feed_command('set nohidden')
- feed_command('w')
- feed_command('bn')
- feed_command('bp')
+ command('set nohidden')
+ command('w')
+ command('silent bn')
+ eq("tmp1.vim", eval("fnamemodify(bufname('%'), ':t')"))
+ feed_command('silent bp')
+ eq("Xtest-functional-ui-highlight.tmp.vim", eval("fnamemodify(bufname('%'), ':t')"))
screen:expect([[
{1:^echo} 1 |
{0:~ }|
{0:~ }|
{0:~ }|
- <ht.tmp.vim" 1L, 7C |
+ :silent bp |
]])
end)
end)
-describe('Default highlight groups', function()
- -- Test the default attributes for highlight groups shown by the :highlight
- -- command
+describe('highlight defaults', function()
local screen
before_each(function()
@@ -281,6 +281,11 @@ describe('Default highlight groups', function()
]], {[0] = {bold=true, foreground=Screen.colors.Blue}})
end)
+ it('Cursor after `:hi clear|syntax reset` #6508', function()
+ command('highlight clear|syntax reset')
+ eq('guifg=bg guibg=fg', eval([[matchstr(execute('hi Cursor'), '\v(gui|cterm).*$')]]))
+ end)
+
it('Whitespace highlight', function()
screen:try_resize(53, 4)
feed_command('highlight NonText gui=NONE guifg=#FF0000')
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index b7a33cb64d..8bdc4601c0 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
+local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local eval = helpers.eval
@@ -21,9 +22,9 @@ local default_text = [[
local function common_setup(screen, inccommand, text)
if screen then
- feed_command("syntax on")
- feed_command("set nohlsearch")
- feed_command("hi Substitute guifg=red guibg=yellow")
+ command("syntax on")
+ command("set nohlsearch")
+ command("hi Substitute guifg=red guibg=yellow")
screen:attach()
screen:set_default_attr_ids({
[1] = {foreground = Screen.colors.Fuchsia},
@@ -46,7 +47,7 @@ local function common_setup(screen, inccommand, text)
})
end
- feed_command("set inccommand=" .. (inccommand and inccommand or ""))
+ command("set inccommand=" .. (inccommand and inccommand or ""))
if text then
insert(text)
@@ -456,7 +457,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
insert("X")
feed("IY<esc>")
feed(":%s/tw/MO/<esc>")
- -- execute("undo") here would cause "Press ENTER".
+ -- feed_command("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("Inc", "XInc"))
feed("u")
@@ -514,7 +515,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed("Ay<esc>")
feed("Az<esc>")
feed(":%s/tw/AR<esc>")
- -- using execute("undo") here will result in a "Press ENTER" prompt
+ -- feed_command("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("lines", "linesxy"))
feed("u")
@@ -603,7 +604,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed_command("set undolevels=-1")
feed(":%s/tw/MO/g<enter>")
- -- using execute("undo") here will result in a "Press ENTER" prompt
+ -- feed_command("undo") here will result in a "Press ENTER" prompt
feed("u")
if case == "split" then
screen:expect([[
@@ -804,7 +805,7 @@ describe(":substitute, inccommand=split", function()
it('does not show split window for :s/', function()
feed("2gg")
feed(":s/tw")
- wait()
+ screen:sleep(1)
screen:expect([[
Inc substitution on |
two lines |
@@ -1291,14 +1292,14 @@ describe("'inccommand' and :cnoremap", function()
it('work with remapped characters', function()
for _, case in pairs(cases) do
refresh(case)
- local command = "%s/lines/LINES/g"
+ local cmd = "%s/lines/LINES/g"
- for i = 1, string.len(command) do
- local c = string.sub(command, i, i)
+ for i = 1, string.len(cmd) do
+ local c = string.sub(cmd, i, i)
feed_command("cnoremap ".. c .. " " .. c)
end
- feed_command(command)
+ feed_command(cmd)
expect([[
Inc substitution on
two LINES
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua
new file mode 100644
index 0000000000..f0cedfeeb5
--- /dev/null
+++ b/test/functional/ui/mode_spec.lua
@@ -0,0 +1,227 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local command, eval = helpers.command, helpers.eval
+local eq = helpers.eq
+
+describe('ui mode_change event', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 4)
+ screen:attach({rgb= true})
+ screen:set_default_attr_ids( {
+ [0] = {bold=true, foreground=255},
+ [1] = {bold=true, reverse=true},
+ [2] = {bold=true},
+ [3] = {reverse=true},
+ })
+ end)
+
+ it('works in normal mode', function()
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+
+ feed('d')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("operator", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in insert mode', function()
+ feed('i')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]],nil,nil,function ()
+ eq("insert", screen.mode)
+ end)
+
+ feed('word<esc>')
+ screen:expect([[
+ wor^d |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]], nil, nil, function ()
+ eq("normal", screen.mode)
+ end)
+
+ command("set showmatch")
+ eq(eval('&matchtime'), 5) -- tenths of seconds
+ feed('a(stuff')
+ screen:expect([[
+ word(stuff^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("insert", screen.mode)
+ end)
+
+ feed(')')
+ screen:expect([[
+ word^(stuff) |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("showmatch", screen.mode)
+ end)
+
+ screen:sleep(400)
+ screen:expect([[
+ word(stuff)^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- INSERT --} |
+ ]], nil, nil, function ()
+ eq("insert", screen.mode)
+ end)
+ end)
+
+ it('works in replace mode', function()
+ feed('R')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {2:-- REPLACE --} |
+ ]], nil, nil, function ()
+ eq("replace", screen.mode)
+ end)
+
+ feed('word<esc>')
+ screen:expect([[
+ wor^d |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]], nil, nil, function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in cmdline mode', function()
+ feed(':')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^ |
+ ]],nil,nil,function ()
+ eq("cmdline_normal", screen.mode)
+ end)
+
+ feed('x<left>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^x |
+ ]],nil,nil,function ()
+ eq("cmdline_insert", screen.mode)
+ end)
+
+ feed('<insert>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :^x |
+ ]],nil,nil,function ()
+ eq("cmdline_replace", screen.mode)
+ end)
+
+
+ feed('<right>')
+ screen:expect([[
+ |
+ {0:~ }|
+ {0:~ }|
+ :x^ |
+ ]],nil,nil,function ()
+ eq("cmdline_normal", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+
+ it('works in visal mode', function()
+ insert("text")
+ feed('v')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]],nil,nil,function ()
+ eq("visual", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+
+ command('set selection=exclusive')
+ feed('v')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]],nil,nil,function ()
+ eq("visual_select", screen.mode)
+ end)
+
+ feed('<esc>')
+ screen:expect([[
+ tex^t |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]],nil,nil,function ()
+ eq("normal", screen.mode)
+ end)
+ end)
+end)
+
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 2f2cc85dab..7d9cd6c026 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -284,18 +284,13 @@ function Screen:wait(check, timeout)
if failure_after_success then
print([[
-Warning: Screen changes have been received after the expected state was seen.
-This is probably due to an indeterminism in the test. Try adding
-`wait()` (or even a separate `screen:expect(...)`) at a point of possible
-indeterminism, typically in between a `feed()` or `execute()` which is non-
-synchronous, and a synchronous api call.
-
-Note that sometimes a `wait` can trigger redraws and consequently generate more
-indeterminism. If adding `wait` calls seems to increase the frequency of these
-messages, try removing every `wait` call in the test.
-
-If everything else fails, use Screen:redraw_debug to help investigate what is
- causing the problem.
+
+Warning: Screen changes were received after the expected state. This indicates
+indeterminism in the test. Try adding wait() (or screen:expect(...)) between
+asynchronous (feed(), nvim_input()) and synchronous API calls.
+ - Use Screen:redraw_debug() to investigate the problem.
+ - wait() can trigger redraws and consequently generate more indeterminism.
+ In that case try removing every wait().
]])
local tb = debug.traceback()
local index = string.find(tb, '\n%s*%[C]')
@@ -317,12 +312,13 @@ function Screen:_redraw(updates)
-- print(require('inspect')(update))
local method = update[1]
for i = 2, #update do
- local handler = self['_handle_'..method]
+ local handler_name = '_handle_'..method
+ local handler = self[handler_name]
if handler ~= nil then
handler(self, unpack(update[i]))
else
assert(self._on_event,
- "Add Screen:_handle_XXX method or call Screen:set_on_event_handler")
+ "Add Screen:"..handler_name.." or call Screen:set_on_event_handler")
self._on_event(method, update[i])
end
end
@@ -353,9 +349,9 @@ function Screen:_handle_resize(width, height)
}
end
-function Screen:_handle_cursor_style_set(enabled, style)
- self._cursor_style_enabled = enabled
- self._cursor_style = style
+function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info)
+ self._cursor_style_enabled = cursor_style_enabled
+ self._mode_info = mode_info
end
function Screen:_handle_clear()
@@ -389,9 +385,8 @@ function Screen:_handle_mouse_off()
self._mouse_enabled = false
end
-function Screen:_handle_mode_change(mode)
- assert(mode == 'insert' or mode == 'replace'
- or mode == 'normal' or mode == 'cmdline')
+function Screen:_handle_mode_change(mode, idx)
+ assert(mode == self._mode_info[idx+1].name)
self.mode = mode
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 8182190b5f..5d89416e4a 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -6,7 +6,7 @@ local insert = helpers.insert
local eq = helpers.eq
local eval = helpers.eval
-describe('Initial screen', function()
+describe('screen', function()
local screen
local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
'--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
@@ -27,7 +27,7 @@ describe('Initial screen', function()
screen:detach()
end)
- it('is the default initial screen', function()
+ it('default initial screen', function()
screen:expect([[
^ |
{0:~ }|
@@ -565,125 +565,22 @@ describe('Screen', function()
]])
end)
end)
+end)
- describe('mode change', function()
- before_each(function()
- screen:try_resize(25, 5)
- end)
-
- it('works in normal mode', function()
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]],nil,nil,function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in insert mode', function()
- feed('i')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {2:-- INSERT --} |
- ]],nil,nil,function ()
- eq("insert", screen.mode)
- end)
-
- feed('word<esc>')
- screen:expect([[
- wor^d |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]], nil, nil, function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in replace mode', function()
- feed('R')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {2:-- REPLACE --} |
- ]], nil, nil, function ()
- eq("replace", screen.mode)
- end)
-
- feed('word<esc>')
- screen:expect([[
- wor^d |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]], nil, nil, function ()
- eq("normal", screen.mode)
- end)
- end)
-
- it('works in cmdline mode', function()
- feed(':')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- :^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
- feed('<esc>/')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- /^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
-
- feed('<esc>?')
- screen:expect([[
- |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- ?^ |
- ]],nil,nil,function ()
- eq("cmdline", screen.mode)
- end)
-
- feed('<esc>')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]],nil,nil,function ()
- eq("normal", screen.mode)
- end)
- end)
+describe('nvim_ui_attach()', function()
+ before_each(function()
+ clear()
end)
-
- it('nvim_ui_attach() handles very large width/height #2180', function()
- screen:detach()
- screen = Screen.new(999, 999)
+ it('handles very large width/height #2180', function()
+ local screen = Screen.new(999, 999)
screen:attach()
eq(999, eval('&lines'))
eq(999, eval('&columns'))
end)
+ it('invalid option returns error', function()
+ local screen = Screen.new()
+ local status, rv = pcall(function() screen:attach({foo={'foo'}}) end)
+ eq(false, status)
+ eq('No such ui option', rv:match("No such .*"))
+ end)
end)
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
new file mode 100644
index 0000000000..56331a33b5
--- /dev/null
+++ b/test/functional/ui/tabline_spec.lua
@@ -0,0 +1,57 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear, command, eq = helpers.clear, helpers.command, helpers.eq
+
+describe('ui/tabline', function()
+ local screen
+ local event_tabs, event_curtab
+
+ before_each(function()
+ clear()
+ screen = Screen.new(25, 5)
+ screen:attach({rgb=true, ext_tabline=true})
+ screen:set_on_event_handler(function(name, data)
+ if name == "tabline_update" then
+ event_curtab, event_tabs = unpack(data)
+ end
+ end)
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ describe('externalized', function()
+ it('publishes UI events', function()
+ command("tabedit another-tab")
+
+ local expected_tabs = {
+ {tab = { id = 1 }, name = '[No Name]'},
+ {tab = { id = 2 }, name = 'another-tab'},
+ }
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq({ id = 2 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end)
+
+ command("tabNext")
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq({ id = 1 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end)
+
+ end)
+ end)
+end)
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index 6639bf272d..052cdd55a1 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -31,6 +31,27 @@ describe("'wildmode'", function()
:sign define^ |
]])
end)
+
+ it('does not crash after cycling back to original text', function()
+ command('set wildmode=full')
+ feed(':j<Tab><Tab><Tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ join jumps |
+ :j^ |
+ ]])
+ -- This would cause nvim to crash before #6650
+ feed('<BS><Tab>')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ! # & < = > @ > |
+ :!^ |
+ ]])
+ end)
end)
end)