aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/bufhl_spec.lua405
-rw-r--r--test/functional/ui/cmdline_highlight_spec.lua109
-rw-r--r--test/functional/ui/cmdline_spec.lua1257
-rw-r--r--test/functional/ui/cursor_spec.lua137
-rw-r--r--test/functional/ui/diff_spec.lua277
-rw-r--r--test/functional/ui/embed_spec.lua130
-rw-r--r--test/functional/ui/fold_spec.lua586
-rw-r--r--test/functional/ui/highlight_spec.lua946
-rw-r--r--test/functional/ui/hlstate_spec.lua209
-rw-r--r--test/functional/ui/inccommand_spec.lua1052
-rw-r--r--test/functional/ui/inccommand_user_spec.lua24
-rw-r--r--test/functional/ui/input_spec.lua178
-rw-r--r--test/functional/ui/linematch_spec.lua196
-rw-r--r--test/functional/ui/messages_spec.lua1655
-rw-r--r--test/functional/ui/mode_spec.lua188
-rw-r--r--test/functional/ui/mouse_spec.lua267
-rw-r--r--test/functional/ui/multibyte_spec.lua126
-rw-r--r--test/functional/ui/options_spec.lua132
-rw-r--r--test/functional/ui/output_spec.lua114
-rw-r--r--test/functional/ui/popupmenu_spec.lua1359
-rw-r--r--test/functional/ui/quickfix_spec.lua23
-rw-r--r--test/functional/ui/screen.lua546
-rw-r--r--test/functional/ui/screen_basic_spec.lua150
-rw-r--r--test/functional/ui/searchhl_spec.lua177
-rw-r--r--test/functional/ui/sign_spec.lua32
-rw-r--r--test/functional/ui/spell_spec.lua34
-rw-r--r--test/functional/ui/statuscolumn_spec.lua113
-rw-r--r--test/functional/ui/statusline_spec.lua186
-rw-r--r--test/functional/ui/syntax_conceal_spec.lua209
-rw-r--r--test/functional/ui/tabline_spec.lua122
-rw-r--r--test/functional/ui/title_spec.lua39
-rw-r--r--test/functional/ui/wildmode_spec.lua176
-rw-r--r--test/functional/ui/winbar_spec.lua130
33 files changed, 6772 insertions, 4512 deletions
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index e47ab273bd..220537f58a 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -16,26 +16,26 @@ describe('Buffer highlighting', function()
screen = Screen.new(40, 8)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold=true, foreground=Screen.colors.Blue},
- [2] = {foreground = Screen.colors.Fuchsia}, -- String
- [3] = {foreground = Screen.colors.Brown, bold = true}, -- Statement
- [4] = {foreground = Screen.colors.SlateBlue}, -- Special
- [5] = {bold = true, foreground = Screen.colors.SlateBlue},
- [6] = {foreground = Screen.colors.DarkCyan}, -- Identifier
- [7] = {bold = true},
- [8] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue},
- [9] = {foreground = Screen.colors.SlateBlue, underline = true},
- [10] = {foreground = Screen.colors.Red},
- [11] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [12] = {foreground = Screen.colors.Blue1},
- [13] = {background = Screen.colors.LightGrey},
- [14] = {background = Screen.colors.Gray90},
- [15] = {background = Screen.colors.Gray90, bold = true, foreground = Screen.colors.Brown},
- [16] = {foreground = Screen.colors.Magenta, background = Screen.colors.Gray90},
- [17] = {foreground = Screen.colors.Magenta, background = Screen.colors.LightRed},
- [18] = {background = Screen.colors.LightRed},
- [19] = {foreground = Screen.colors.Blue1, background = Screen.colors.LightRed},
- [20] = {underline = true, bold = true, foreground = Screen.colors.Cyan4},
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { foreground = Screen.colors.Fuchsia }, -- String
+ [3] = { foreground = Screen.colors.Brown, bold = true }, -- Statement
+ [4] = { foreground = Screen.colors.SlateBlue }, -- Special
+ [5] = { bold = true, foreground = Screen.colors.SlateBlue },
+ [6] = { foreground = Screen.colors.DarkCyan }, -- Identifier
+ [7] = { bold = true },
+ [8] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue },
+ [9] = { foreground = Screen.colors.SlateBlue, underline = true },
+ [10] = { foreground = Screen.colors.Red },
+ [11] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [12] = { foreground = Screen.colors.Blue1 },
+ [13] = { background = Screen.colors.LightGrey },
+ [14] = { background = Screen.colors.Gray90 },
+ [15] = { background = Screen.colors.Gray90, bold = true, foreground = Screen.colors.Brown },
+ [16] = { foreground = Screen.colors.Magenta, background = Screen.colors.Gray90 },
+ [17] = { foreground = Screen.colors.Magenta, background = Screen.colors.LightRed },
+ [18] = { background = Screen.colors.LightRed },
+ [19] = { foreground = Screen.colors.Blue1, background = Screen.colors.LightRed },
+ [20] = { underline = true, bold = true, foreground = Screen.colors.Cyan4 },
})
end)
@@ -55,8 +55,8 @@ describe('Buffer highlighting', function()
|
]])
- add_highlight(-1, "String", 0 , 10, 14)
- add_highlight(-1, "Statement", 1 , 5, -1)
+ add_highlight(-1, 'String', 0, 10, 14)
+ add_highlight(-1, 'Statement', 1, 5, -1)
screen:expect([[
these are {2:some} lines |
@@ -65,7 +65,7 @@ describe('Buffer highlighting', function()
|
]])
- feed("ggo<esc>")
+ feed('ggo<esc>')
screen:expect([[
these are {2:some} lines |
^ |
@@ -93,22 +93,22 @@ describe('Buffer highlighting', function()
combining highlights
from different sources]])
- command("hi ImportantWord gui=bold cterm=bold")
- id1 = add_highlight(0, "ImportantWord", 0, 2, 8)
- add_highlight(id1, "ImportantWord", 1, 12, -1)
- add_highlight(id1, "ImportantWord", 2, 0, 9)
- add_highlight(id1, "ImportantWord", 3, 5, 14)
+ command('hi ImportantWord gui=bold cterm=bold')
+ id1 = add_highlight(0, 'ImportantWord', 0, 2, 8)
+ add_highlight(id1, 'ImportantWord', 1, 12, -1)
+ add_highlight(id1, 'ImportantWord', 2, 0, 9)
+ add_highlight(id1, 'ImportantWord', 3, 5, 14)
-- add_highlight can be called like this to get a new source
-- without adding any highlight
- id2 = add_highlight(0, "", 0, 0, 0)
+ id2 = add_highlight(0, '', 0, 0, 0)
neq(id1, id2)
- add_highlight(id2, "Special", 0, 2, 8)
- add_highlight(id2, "Identifier", 1, 3, 8)
- add_highlight(id2, "Special", 1, 14, 20)
- add_highlight(id2, "Underlined", 2, 6, 12)
- add_highlight(id2, "Underlined", 3, 0, 9)
+ add_highlight(id2, 'Special', 0, 2, 8)
+ add_highlight(id2, 'Identifier', 1, 3, 8)
+ add_highlight(id2, 'Special', 1, 14, 20)
+ add_highlight(id2, 'Underlined', 2, 6, 12)
+ add_highlight(id2, 'Underlined', 3, 0, 9)
screen:expect([[
a {5:longer} example |
@@ -185,14 +185,16 @@ describe('Buffer highlighting', function()
-- the deleted line wrapping around. we should invalidate
-- highlights when they are completely inside deleted text
command('3move 4')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
|
{8:from different sources} |
{8:^in }{20:order}{8: to demonstrate} |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
--screen:expect([[
-- a {5:longer} example |
-- |
@@ -203,165 +205,196 @@ describe('Buffer highlighting', function()
--]])
command('undo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
^ |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 change; before #4 {MATCH:.*}|
- ]]}
+ ]],
+ }
command('undo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^a {5:longer} example |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*4
1 line less; before #3 {MATCH:.*}|
- ]]}
+ ]],
+ }
command('undo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{7:^combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 more line; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
it('and moving lines around', function()
command('2move 3')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
{7:combin}{8:ing}{9: hi}ghlights |
^in {6:order} to {7:de}{5:monstr}{7:ate} |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
command('1,2move 4')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
in {6:order} to {7:de}{5:monstr}{7:ate} |
{9:from }{8:diff}{7:erent} sources |
a {5:longer} example |
{7:^combin}{8:ing}{9: hi}ghlights |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
command('undo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
{7:combin}{8:ing}{9: hi}ghlights |
^in {6:order} to {7:de}{5:monstr}{7:ate} |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
2 changes; before #3 {MATCH:.*}|
- ]]}
+ ]],
+ }
command('undo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
^in {6:order} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 change; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
it('and adjusting columns', function()
-- insert before
feed('ggiquite <esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
quite^ a {5:longer} example |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
feed('u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^a {5:longer} example |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 change; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
-- change/insert in the middle
feed('+fesAAAA')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:ordAAAA^r} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
{7:-- INSERT --} |
- ]]}
+ ]],
+ }
feed('<esc>tdD')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:ordAAAAr} t^o |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
feed('u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:ordAAAAr} to^ {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 change; before #4 {MATCH:.*}|
- ]]}
+ ]],
+ }
feed('u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:ord^er} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 change; before #3 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
it('and joining lines', function()
feed('ggJJJ')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example in {6:order} to {7:de}{5:monstr}{7:ate}|
{7:combin}{8:ing}{9: hi}ghlights^ {9:from }{8:diff}{7:erent} sou|
rces |
{1:~ }|*4
|
- ]]}
+ ]],
+ }
feed('uuu')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^a {5:longer} example |
in {6:order} to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 more line; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
it('and splitting lines', function()
feed('2Gtti<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:order} |
^ to {7:de}{5:monstr}{7:ate} |
@@ -369,10 +402,12 @@ describe('Buffer highlighting', function()
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*2
{7:-- INSERT --} |
- ]]}
+ ]],
+ }
feed('<esc>tsi<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:order} |
to {7:de}{5:mo} |
@@ -381,10 +416,12 @@ describe('Buffer highlighting', function()
{9:from }{8:diff}{7:erent} sources |
{1:~ }|
{7:-- INSERT --} |
- ]]}
+ ]],
+ }
feed('<esc>u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:order} |
to {7:de}{5:mo^nstr}{7:ate} |
@@ -392,26 +429,29 @@ describe('Buffer highlighting', function()
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*2
1 line less; before #3 {MATCH:.*}|
- ]]}
+ ]],
+ }
feed('<esc>u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
a {5:longer} example |
in {6:order}^ to {7:de}{5:monstr}{7:ate} |
{7:combin}{8:ing}{9: hi}ghlights |
{9:from }{8:diff}{7:erent} sources |
{1:~ }|*3
1 line less; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
end)
pending('prioritizes latest added highlight', function()
insert([[
three overlapping colors]])
- add_highlight(0, "Identifier", 0, 6, 17)
- add_highlight(0, "String", 0, 14, 23)
- local id = add_highlight(0, "Special", 0, 0, 9)
+ add_highlight(0, 'Identifier', 0, 6, 17)
+ add_highlight(0, 'String', 0, 14, 23)
+ local id = add_highlight(0, 'Special', 0, 0, 9)
screen:expect([[
{4:three ove}{6:rlapp}{2:ing color}^s |
@@ -430,22 +470,26 @@ describe('Buffer highlighting', function()
it('prioritizes earlier highlight groups (TEMP)', function()
insert([[
three overlapping colors]])
- add_highlight(0, "Identifier", 0, 6, 17)
- add_highlight(0, "String", 0, 14, 23)
- local id = add_highlight(0, "Special", 0, 0, 9)
+ add_highlight(0, 'Identifier', 0, 6, 17)
+ add_highlight(0, 'String', 0, 14, 23)
+ local id = add_highlight(0, 'Special', 0, 0, 9)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{4:three }{6:overlapp}{2:ing color}^s |
{1:~ }|*6
|
- ]]}
+ ]],
+ }
clear_namespace(id, 0, 1)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
three {6:overlapp}{2:ing color}^s |
{1:~ }|*6
|
- ]]}
+ ]],
+ }
end)
it('respects priority', function()
@@ -456,14 +500,14 @@ describe('Buffer highlighting', function()
set_extmark(id, 0, 0, {
end_line = 0,
end_col = 5,
- hl_group = "Statement",
- priority = 100
+ hl_group = 'Statement',
+ priority = 100,
})
set_extmark(id, 0, 0, {
end_line = 0,
end_col = 6,
- hl_group = "String",
- priority = 1
+ hl_group = 'String',
+ priority = 1,
})
screen:expect [[
@@ -473,23 +517,25 @@ describe('Buffer highlighting', function()
]]
clear_namespace(id, 0, -1)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
fooba^r |
{1:~ }|*6
|
- ]]}
+ ]],
+ }
set_extmark(id, 0, 0, {
end_line = 0,
end_col = 6,
- hl_group = "String",
- priority = 1
+ hl_group = 'String',
+ priority = 1,
})
set_extmark(id, 0, 0, {
end_line = 0,
end_col = 5,
- hl_group = "Statement",
- priority = 100
+ hl_group = 'Statement',
+ priority = 100,
})
screen:expect [[
@@ -502,8 +548,8 @@ describe('Buffer highlighting', function()
it('works with multibyte text', function()
insert([[
Ta båten över sjön!]])
- add_highlight(-1, "Identifier", 0, 3, 9)
- add_highlight(-1, "String", 0, 16, 21)
+ add_highlight(-1, 'Identifier', 0, 3, 9)
+ add_highlight(-1, 'String', 0, 16, 21)
screen:expect([[
Ta {6:båten} över {2:sjön}^! |
@@ -515,7 +561,7 @@ describe('Buffer highlighting', function()
it('works with new syntax groups', function()
insert([[
fancy code in a new fancy language]])
- add_highlight(-1, "FancyLangItem", 0, 0, 5)
+ add_highlight(-1, 'FancyLangItem', 0, 0, 5)
screen:expect([[
fancy code in a new fancy languag^e |
{1:~ }|*6
@@ -549,11 +595,14 @@ describe('Buffer highlighting', function()
|
]])
- id1 = set_virtual_text(0, 0, {{"=", "Statement"}, {" 3", "Number"}}, {})
- set_virtual_text(id1, 1, {{"ERROR:", "ErrorMsg"}, {" invalid syntax"}}, {})
- id2 = set_virtual_text(0, 2, {{"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}}, {})
+ id1 = set_virtual_text(0, 0, { { '=', 'Statement' }, { ' 3', 'Number' } }, {})
+ set_virtual_text(id1, 1, { { 'ERROR:', 'ErrorMsg' }, { ' invalid syntax' } }, {})
+ id2 = set_virtual_text(0, 2, {
+ {
+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
+ },
+ }, {})
neq(id2, id1)
-
end)
it('works', function()
@@ -580,7 +629,15 @@ describe('Buffer highlighting', function()
-- Handles doublewidth chars, leaving a space if truncating
-- in the middle of a char
- eq(-1, set_virtual_text(-1, 1, {{"暗x事zz速野谷質結育副住新覚丸活解終事", "Comment"}}, {}))
+ eq(
+ -1,
+ set_virtual_text(
+ -1,
+ 1,
+ { { '暗x事zz速野谷質結育副住新覚丸活解終事', 'Comment' } },
+ {}
+ )
+ )
screen:expect([[
^1 + 2 |
3 + {12:暗x事zz速野谷質結育副住新覚丸活解終 }|
@@ -591,7 +648,7 @@ describe('Buffer highlighting', function()
|
]])
- feed("2Gx")
+ feed('2Gx')
screen:expect([[
1 + 2 |
^ + {12:暗x事zz速野谷質結育副住新覚丸活解終事}|
@@ -602,18 +659,20 @@ describe('Buffer highlighting', function()
|
]])
- feed("2Gdd")
+ feed('2Gdd')
-- TODO(bfredl): currently decorations get moved from a deleted line
-- to the next one. We might want to add "invalidation" when deleting
-- over a decoration.
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
1 + 2 |
^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
, 5, 5, 5, 5, 5, 5, {12:暗x事zz速野谷質結育}|
x = 4 |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
--screen:expect([[
-- 1 + 2 |
-- ^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
@@ -626,47 +685,67 @@ describe('Buffer highlighting', function()
it('validates contents', function()
-- this used to leak memory
- eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {"texty"}, {}))
- eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {}))
+ eq(
+ "Invalid 'chunk': expected Array, got String",
+ pcall_err(set_virtual_text, id1, 0, { 'texty' }, {})
+ )
+ eq(
+ "Invalid 'chunk': expected Array, got String",
+ pcall_err(set_virtual_text, id1, 0, { { 'very' }, 'texty' }, {})
+ )
end)
it('can be retrieved', function()
local get_extmarks = curbufmeths.get_extmarks
local line_count = curbufmeths.line_count
- local s1 = {{'Köttbullar', 'Comment'}, {'Kräuterbutter'}}
- local s2 = {{'こんにちは', 'Comment'}}
+ local s1 = { { 'Köttbullar', 'Comment' }, { 'Kräuterbutter' } }
+ local s2 = { { 'こんにちは', 'Comment' } }
set_virtual_text(id1, 0, s1, {})
- eq({{1, 0, 0, {
- ns_id = 1,
- priority = 0,
- virt_text = s1,
- -- other details
- right_gravity = true,
- virt_text_repeat_linebreak = false,
- virt_text_pos = 'eol',
- virt_text_hide = false,
- }}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true}))
+ eq({
+ {
+ 1,
+ 0,
+ 0,
+ {
+ ns_id = 1,
+ priority = 0,
+ virt_text = s1,
+ -- other details
+ right_gravity = true,
+ virt_text_repeat_linebreak = false,
+ virt_text_pos = 'eol',
+ virt_text_hide = false,
+ },
+ },
+ }, get_extmarks(id1, { 0, 0 }, { 0, -1 }, { details = true }))
local lastline = line_count()
set_virtual_text(id1, line_count(), s2, {})
- eq({{3, lastline, 0, {
- ns_id = 1,
- priority = 0,
- virt_text = s2,
- -- other details
- right_gravity = true,
- virt_text_repeat_linebreak = false,
- virt_text_pos = 'eol',
- virt_text_hide = false,
- }}}, get_extmarks(id1, {lastline,0}, {lastline, -1}, {details=true}))
-
- eq({}, get_extmarks(id1, {lastline+9000,0}, {lastline+9000, -1}, {}))
+ eq({
+ {
+ 3,
+ lastline,
+ 0,
+ {
+ ns_id = 1,
+ priority = 0,
+ virt_text = s2,
+ -- other details
+ right_gravity = true,
+ virt_text_repeat_linebreak = false,
+ virt_text_pos = 'eol',
+ virt_text_hide = false,
+ },
+ },
+ }, get_extmarks(id1, { lastline, 0 }, { lastline, -1 }, { details = true }))
+
+ eq({}, get_extmarks(id1, { lastline + 9000, 0 }, { lastline + 9000, -1 }, {}))
end)
it('is not highlighted by visual selection', function()
- feed("ggVG")
+ feed('ggVG')
screen:expect([[
{13:1 + 2} {3:=}{2: 3} |
{13:3 +} {11:ERROR:} invalid syntax |
@@ -677,7 +756,7 @@ describe('Buffer highlighting', function()
{7:-- VISUAL LINE --} |
]])
- feed("<esc>")
+ feed('<esc>')
screen:expect([[
1 + 2 {3:=}{2: 3} |
3 + {11:ERROR:} invalid syntax |
@@ -689,7 +768,7 @@ describe('Buffer highlighting', function()
]])
-- special case: empty line has extra eol highlight
- feed("ggd$")
+ feed('ggd$')
screen:expect([[
^ {3:=}{2: 3} |
3 + {11:ERROR:} invalid syntax |
@@ -700,7 +779,7 @@ describe('Buffer highlighting', function()
|
]])
- feed("jvk")
+ feed('jvk')
screen:expect([[
^ {3:=}{2: 3} |
{13:3} + {11:ERROR:} invalid syntax |
@@ -711,7 +790,7 @@ describe('Buffer highlighting', function()
{7:-- VISUAL --} |
]])
- feed("o")
+ feed('o')
screen:expect([[
{13: }{3:=}{2: 3} |
^3 + {11:ERROR:} invalid syntax |
@@ -723,9 +802,8 @@ describe('Buffer highlighting', function()
]])
end)
-
it('works with listchars', function()
- command("set list listchars+=eol:$")
+ command('set list listchars+=eol:$')
screen:expect([[
^1 + 2{1:$}{3:=}{2: 3} |
3 +{1:$}{11:ERROR:} invalid syntax |
@@ -749,9 +827,10 @@ describe('Buffer highlighting', function()
end)
it('works with cursorline', function()
- command("set cursorline")
+ command('set cursorline')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{14:^1 + 2 }{3:=}{2: 3}{14: }|
3 + {11:ERROR:} invalid syntax |
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
@@ -759,10 +838,12 @@ describe('Buffer highlighting', function()
x = 4 |
{1:~ }|*2
|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
1 + 2 {3:=}{2: 3} |
{14:^3 + }{11:ERROR:} invalid syntax{14: }|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
@@ -770,11 +851,12 @@ describe('Buffer highlighting', function()
x = 4 |
{1:~ }|*2
|
- ]]}
-
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
1 + 2 {3:=}{2: 3} |
3 + {11:ERROR:} invalid syntax |
{14:^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}|
@@ -782,12 +864,14 @@ describe('Buffer highlighting', function()
x = 4 |
{1:~ }|*2
|
- ]]}
+ ]],
+ }
end)
it('works with color column', function()
- eq(-1, set_virtual_text(-1, 3, {{"暗x事", "Comment"}}, {}))
- screen:expect{grid=[[
+ eq(-1, set_virtual_text(-1, 3, { { '暗x事', 'Comment' } }, {}))
+ screen:expect {
+ grid = [[
^1 + 2 {3:=}{2: 3} |
3 + {11:ERROR:} invalid syntax |
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
@@ -795,10 +879,12 @@ describe('Buffer highlighting', function()
x = 4 {12:暗x事} |
{1:~ }|*2
|
- ]]}
+ ]],
+ }
- command("set colorcolumn=9")
- screen:expect{grid=[[
+ command('set colorcolumn=9')
+ screen:expect {
+ grid = [[
^1 + 2 {3:=}{2: 3} |
3 + {11:ERROR:} invalid syntax |
5, 5, 5,{18: }5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5|
@@ -806,17 +892,18 @@ describe('Buffer highlighting', function()
x = 4 {12:暗x事} |
{1:~ }|*2
|
- ]]}
+ ]],
+ }
end)
end)
it('and virtual text use the same namespace counter', function()
local set_virtual_text = curbufmeths.set_virtual_text
- eq(1, add_highlight(0, "String", 0 , 0, -1))
- eq(2, set_virtual_text(0, 0, {{"= text", "Comment"}}, {}))
- eq(3, meths.create_namespace("my-ns"))
- eq(4, add_highlight(0, "String", 0 , 0, -1))
- eq(5, set_virtual_text(0, 0, {{"= text", "Comment"}}, {}))
- eq(6, meths.create_namespace("other-ns"))
+ eq(1, add_highlight(0, 'String', 0, 0, -1))
+ eq(2, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
+ eq(3, meths.create_namespace('my-ns'))
+ eq(4, add_highlight(0, 'String', 0, 0, -1))
+ eq(5, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
+ eq(6, meths.create_namespace('other-ns'))
end)
end)
diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua
index 3fddc4700a..4b3657f834 100644
--- a/test/functional/ui/cmdline_highlight_spec.lua
+++ b/test/functional/ui/cmdline_highlight_spec.lua
@@ -138,29 +138,28 @@ before_each(function()
endfunction
]])
screen:set_default_attr_ids({
- RBP1={background = Screen.colors.Red},
- RBP2={background = Screen.colors.Yellow},
- RBP3={background = Screen.colors.Green},
- RBP4={background = Screen.colors.Blue},
- EOB={bold = true, foreground = Screen.colors.Blue1},
- ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- SK={foreground = Screen.colors.Blue},
- PE={bold = true, foreground = Screen.colors.SeaGreen4},
- NUM={foreground = Screen.colors.Blue2},
- NPAR={foreground = Screen.colors.Yellow},
- SQ={foreground = Screen.colors.Blue3},
- SB={foreground = Screen.colors.Blue4},
- E={foreground = Screen.colors.Red, background = Screen.colors.Blue},
- M={bold = true},
- MSEP={bold = true, reverse = true};
+ RBP1 = { background = Screen.colors.Red },
+ RBP2 = { background = Screen.colors.Yellow },
+ RBP3 = { background = Screen.colors.Green },
+ RBP4 = { background = Screen.colors.Blue },
+ EOB = { bold = true, foreground = Screen.colors.Blue1 },
+ ERR = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ SK = { foreground = Screen.colors.Blue },
+ PE = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ NUM = { foreground = Screen.colors.Blue2 },
+ NPAR = { foreground = Screen.colors.Yellow },
+ SQ = { foreground = Screen.colors.Blue3 },
+ SB = { foreground = Screen.colors.Blue4 },
+ E = { foreground = Screen.colors.Red, background = Screen.colors.Blue },
+ M = { bold = true },
+ MSEP = { bold = true, reverse = true },
})
end)
local function set_color_cb(funcname, callback_return, id)
meths.set_var('id', id or '')
if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then
- command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(
- id, funcname, id))
+ command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id))
if callback_return then
meths.set_var('callback_return' .. id, callback_return)
end
@@ -228,13 +227,16 @@ describe('Command-line coloring', function()
:echo {RBP1:(}{RBP2:(}42{RBP2:)}^ |
]])
redraw_input()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{EOB:~ }|*6
:echo {RBP1:(}{RBP2:(}42{RBP2:)}^ |
- ]], reset=true}
+ ]],
+ reset = true,
+ }
end)
- for _, func_part in ipairs({'', 'n', 'msg'}) do
+ for _, func_part in ipairs({ '', 'n', 'msg' }) do
it('disables :echo' .. func_part .. ' messages', function()
set_color_cb('Echo' .. func_part .. 'ing')
start_prompt('echo')
@@ -245,11 +247,11 @@ describe('Command-line coloring', function()
]])
end)
end
- it('does the right thing when hl start appears to split multibyte char',
- function()
+ it('does the right thing when hl start appears to split multibyte char', function()
set_color_cb('SplitMultibyteStart')
start_prompt('echo "«')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{EOB:~ }|*2
{MSEP: }|
@@ -257,7 +259,8 @@ describe('Command-line coloring', function()
{ERR:E5405: Chunk 0 start 7 splits multibyte }|
{ERR:character} |
:echo "«^ |
- ]]}
+ ]],
+ }
feed('»')
screen:expect([[
|
@@ -269,8 +272,7 @@ describe('Command-line coloring', function()
:echo "«»^ |
]])
end)
- it('does the right thing when hl end appears to split multibyte char',
- function()
+ it('does the right thing when hl end appears to split multibyte char', function()
set_color_cb('SplitMultibyteEnd')
start_prompt('echo "«')
screen:expect([[
@@ -427,7 +429,7 @@ describe('Command-line coloring', function()
]])
feed('<CR><CR><CR>')
- set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}, 42})
+ set_color_cb('ReturningGlobal', { { 0, 1, 'Normal' }, 42 })
start_prompt('#')
screen:expect([[
|
@@ -439,7 +441,7 @@ describe('Command-line coloring', function()
]])
feed('<CR><CR><CR>')
- set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1}})
+ set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 1 } })
start_prompt('+')
screen:expect([[
|
@@ -452,7 +454,7 @@ describe('Command-line coloring', function()
]])
feed('<CR><CR><CR>')
- set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {2, 3, 'Normal'}})
+ set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 2, 3, 'Normal' } })
start_prompt('+')
screen:expect([[
|
@@ -465,7 +467,7 @@ describe('Command-line coloring', function()
]])
feed('<CR><CR><CR>')
- set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1, 3, 'Normal'}})
+ set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 1, 3, 'Normal' } })
start_prompt('+')
screen:expect([[
|
@@ -477,7 +479,7 @@ describe('Command-line coloring', function()
]])
end)
it('does not error out when called from a errorred out cycle', function()
- set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}})
+ set_color_cb('ReturningGlobal', { { 0, 1, 'Normal' } })
feed(dedent([[
:set regexpengine=2
:for pat in [' \ze*', ' \zs*']
@@ -499,12 +501,14 @@ describe('Command-line coloring', function()
:
:
]]))
- eq({'', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*'},
- curbufmeths.get_lines(0, -1, false))
+ eq(
+ { '', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*' },
+ curbufmeths.get_lines(0, -1, false)
+ )
eq('', funcs.execute('messages'))
end)
it('allows nesting input()s', function()
- set_color_cb('ReturningGlobal', {{0, 1, 'RBP1'}}, '')
+ set_color_cb('ReturningGlobal', { { 0, 1, 'RBP1' } }, '')
start_prompt('1')
screen:expect([[
|
@@ -512,7 +516,7 @@ describe('Command-line coloring', function()
:{RBP1:1}^ |
]])
- set_color_cb('ReturningGlobal', {{0, 1, 'RBP2'}}, '1')
+ set_color_cb('ReturningGlobal', { { 0, 1, 'RBP2' } }, '1')
start_prompt('2')
screen:expect([[
|
@@ -520,7 +524,7 @@ describe('Command-line coloring', function()
:{RBP2:2}^ |
]])
- set_color_cb('ReturningGlobal', {{0, 1, 'RBP3'}}, '2')
+ set_color_cb('ReturningGlobal', { { 0, 1, 'RBP3' } }, '2')
start_prompt('3')
screen:expect([[
|
@@ -528,7 +532,7 @@ describe('Command-line coloring', function()
:{RBP3:3}^ |
]])
- set_color_cb('ReturningGlobal', {{0, 1, 'RBP4'}}, '3')
+ set_color_cb('ReturningGlobal', { { 0, 1, 'RBP4' } }, '3')
start_prompt('4')
screen:expect([[
|
@@ -568,7 +572,7 @@ describe('Command-line coloring', function()
end)
it('runs callback with the same data only once', function()
local function new_recording_calls(...)
- eq({...}, meths.get_var('recording_calls'))
+ eq({ ... }, meths.get_var('recording_calls'))
meths.set_var('recording_calls', {})
end
set_color_cb('Recording')
@@ -578,22 +582,21 @@ describe('Command-line coloring', function()
-- new_recording_calls(expected_result) -- (actual_before_fix)
--
feed('a')
- new_recording_calls('a') -- ('a', 'a')
+ new_recording_calls('a') -- ('a', 'a')
feed('b')
new_recording_calls('ab') -- ('a', 'ab', 'ab')
feed('c')
- new_recording_calls('abc') -- ('ab', 'abc', 'abc')
+ new_recording_calls('abc') -- ('ab', 'abc', 'abc')
feed('<BS>')
- new_recording_calls('ab') -- ('abc', 'ab', 'ab')
+ new_recording_calls('ab') -- ('abc', 'ab', 'ab')
feed('<BS>')
- new_recording_calls('a') -- ('ab', 'a', 'a')
+ new_recording_calls('a') -- ('ab', 'a', 'a')
feed('<BS>')
- new_recording_calls() -- ('a')
+ new_recording_calls() -- ('a')
feed('<CR><CR>')
eq('', meths.get_var('out'))
end)
- it('does not crash when callback has caught not-a-editor-command exception',
- function()
+ it('does not crash when callback has caught not-a-editor-command exception', function()
source([[
function CaughtExc(cmdline) abort
try
@@ -624,7 +627,7 @@ describe('Ex commands coloring', function()
feed(':let x = "«"\n')
eq('«', meths.get_var('x'))
local msg = 'E5405: Chunk 0 start 10 splits multibyte character'
- eq('\n'..msg, funcs.execute('messages'))
+ eq('\n' .. msg, funcs.execute('messages'))
end)
it('does not error out when called from a errorred out cycle', function()
-- Apparently when there is a cycle in which one of the commands errors out
@@ -641,8 +644,10 @@ describe('Ex commands coloring', function()
: endtry
:endfor
]]))
- eq({'', 'E888 detected for \\ze*', 'E888 detected for \\zs*'},
- curbufmeths.get_lines(0, -1, false))
+ eq(
+ { '', 'E888 detected for \\ze*', 'E888 detected for \\zs*' },
+ curbufmeths.get_lines(0, -1, false)
+ )
eq('', funcs.execute('messages'))
end)
it('does not crash when using `n` in debug mode', function()
@@ -698,8 +703,10 @@ describe('Ex commands coloring', function()
{PE:Press ENTER or type command to continue}^ |
]])
feed('<CR>')
- eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: Empty buffer',
- exec_capture('messages'))
+ eq(
+ 'Error detected while processing :\nE605: Exception not caught: 42\nE749: Empty buffer',
+ exec_capture('messages')
+ )
end)
it('errors out when failing to get callback', function()
meths.set_var('Nvim_color_cmdline', 42)
@@ -780,7 +787,7 @@ describe('Expressions coloring support', function()
{EOB:~ }|*6
:^ |
]])
- funcs.setreg('a', {'\192'})
+ funcs.setreg('a', { '\192' })
feed('<C-r>="<C-r><C-r>a"<C-r><C-r>a"foo"')
screen:expect([[
|
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index cac070406d..82ff633fcb 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -15,16 +15,16 @@ local function new_screen(opt)
local screen = Screen.new(25, 5)
screen:attach(opt)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {reverse = true},
- [3] = {bold = true, reverse = true},
- [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [5] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [6] = {foreground = Screen.colors.Magenta},
- [7] = {bold = true, foreground = Screen.colors.Brown},
- [8] = {background = Screen.colors.LightGrey},
- [9] = {bold = true},
- [10] = {background = Screen.colors.Yellow1};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { reverse = true },
+ [3] = { bold = true, reverse = true },
+ [4] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [5] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [6] = { foreground = Screen.colors.Magenta },
+ [7] = { bold = true, foreground = Screen.colors.Brown },
+ [8] = { background = Screen.colors.LightGrey },
+ [9] = { bold = true },
+ [10] = { background = Screen.colors.Yellow1 },
})
return screen
end
@@ -34,326 +34,445 @@ local function test_cmdline(linegrid)
before_each(function()
clear()
- screen = new_screen({rgb=true, ext_cmdline=true, ext_linegrid=linegrid})
+ screen = new_screen({ rgb = true, ext_cmdline = true, ext_linegrid = linegrid })
end)
it('works', function()
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{""}},
- pos = 0,
- }}}
+ ]],
+ cmdline = { {
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ } },
+ }
feed('sign')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign"}},
- pos = 4,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign' } },
+ pos = 4,
+ },
+ },
+ }
feed('<Left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign"}},
- pos = 3,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign' } },
+ pos = 3,
+ },
+ },
+ }
feed('<bs>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sin"}},
- pos = 2,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sin' } },
+ pos = 2,
+ },
+ },
+ }
feed('<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
end)
- it("works with input()", function()
+ it('works with input()', function()
feed(':call input("input", "default")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- prompt = "input",
- content = {{"default"}},
- pos = 7,
- }}}
+ ]],
+ cmdline = {
+ {
+ prompt = 'input',
+ content = { { 'default' } },
+ pos = 7,
+ },
+ },
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
end)
- it("works with special chars and nested cmdline", function()
+ it('works with special chars and nested cmdline', function()
feed(':xx<c-r>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"xx"}},
- pos = 2,
- special = {'"', true},
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'xx' } },
+ pos = 2,
+ special = { '"', true },
+ },
+ },
+ }
feed('=')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"xx"}},
- pos = 2,
- special = {'"', true},
- }, {
- firstc = "=",
- content = {{""}},
- pos = 0,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'xx' } },
+ pos = 2,
+ special = { '"', true },
+ },
+ {
+ firstc = '=',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ }
feed('1+2')
- local expectation = {{
- firstc = ":",
- content = {{"xx"}},
- pos = 2,
- special = {'"', true},
- }, {
- firstc = "=",
- content = {{"1", 6}, {"+", 7}, {"2", 6}},
- pos = 3,
- }}
-
- screen:expect{grid=[[
+ local expectation = {
+ {
+ firstc = ':',
+ content = { { 'xx' } },
+ pos = 2,
+ special = { '"', true },
+ },
+ {
+ firstc = '=',
+ content = { { '1', 6 }, { '+', 7 }, { '2', 6 } },
+ pos = 3,
+ },
+ }
+
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline=expectation}
+ ]],
+ cmdline = expectation,
+ }
-- erase information, so we check if it is retransmitted
- command("mode")
- screen:expect{grid=[[
+ command('mode')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline=expectation, reset=true}
-
+ ]],
+ cmdline = expectation,
+ reset = true,
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"xx3"}},
- pos = 3,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'xx3' } },
+ pos = 3,
+ },
+ },
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
end)
- it("works with function definitions", function()
+ it('works with function definitions', function()
feed(':function Foo()<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- indent = 2,
- firstc = ":",
- content = {{""}},
- pos = 0,
- }}, cmdline_block = {
- {{'function Foo()'}},
- }}
+ ]],
+ cmdline = {
+ {
+ indent = 2,
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ cmdline_block = {
+ { { 'function Foo()' } },
+ },
+ }
feed('line1<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- indent = 2,
- firstc = ":",
- content = {{""}},
- pos = 0,
- }}, cmdline_block = {
- {{'function Foo()'}},
- {{' line1'}},
- }}
-
- command("mode")
- screen:expect{grid=[[
+ ]],
+ cmdline = {
+ {
+ indent = 2,
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ cmdline_block = {
+ { { 'function Foo()' } },
+ { { ' line1' } },
+ },
+ }
+
+ command('mode')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- indent = 2,
- firstc = ":",
- content = {{""}},
- pos = 0,
- }}, cmdline_block = {
- {{'function Foo()'}},
- {{' line1'}},
- }, reset=true}
+ ]],
+ cmdline = {
+ {
+ indent = 2,
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ cmdline_block = {
+ { { 'function Foo()' } },
+ { { ' line1' } },
+ },
+ reset = true,
+ }
feed('endfunction<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
-- Try once more, to check buffer is reinitialized. #8007
feed(':function Bar()<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- indent = 2,
- firstc = ":",
- content = {{""}},
- pos = 0,
- }}, cmdline_block = {
- {{'function Bar()'}},
- }}
+ ]],
+ cmdline = {
+ {
+ indent = 2,
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ cmdline_block = {
+ { { 'function Bar()' } },
+ },
+ }
feed('endfunction<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
-
+ ]],
+ }
end)
- it("works with cmdline window", function()
+ it('works with cmdline window', function()
feed(':make')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"make"}},
- pos = 4,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'make' } },
+ pos = 4,
+ },
+ },
+ }
feed('<c-f>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{2:[No Name] }|
{1::}mak^e |
{3:[Command Line] }|
|
- ]]}
+ ]],
+ }
-- nested cmdline
feed(':yank')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{2:[No Name] }|
{1::}mak^e |
{3:[Command Line] }|
|
- ]], cmdline={nil, {
- firstc = ":",
- content = {{"yank"}},
- pos = 4,
- }}}
-
- command("mode")
- screen:expect{grid=[[
+ ]],
+ cmdline = {
+ nil,
+ {
+ firstc = ':',
+ content = { { 'yank' } },
+ pos = 4,
+ },
+ },
+ }
+
+ command('mode')
+ screen:expect {
+ grid = [[
|
{2:[No Name] }|
{1::}mak^e |
{3:[Command Line] }|
|
- ]], cmdline={nil, {
- firstc = ":",
- content = {{"yank"}},
- pos = 4,
- }}, reset=true}
-
- feed("<c-c>")
- screen:expect{grid=[[
+ ]],
+ cmdline = {
+ nil,
+ {
+ firstc = ':',
+ content = { { 'yank' } },
+ pos = 4,
+ },
+ },
+ reset = true,
+ }
+
+ feed('<c-c>')
+ screen:expect {
+ grid = [[
|
{2:[No Name] }|
{1::}mak^e |
{3:[Command Line] }|
|
- ]]}
+ ]],
+ }
- feed("<c-c>")
- screen:expect{grid=[[
+ feed('<c-c>')
+ screen:expect {
+ grid = [[
^ |
{2:[No Name] }|
{1::}make |
{3:[Command Line] }|
|
- ]], cmdline={{
- firstc = ":",
- content = {{"make"}},
- pos = 4,
- }}}
-
- command("redraw!")
- screen:expect{grid=[[
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'make' } },
+ pos = 4,
+ },
+ },
+ }
+
+ command('redraw!')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"make"}},
- pos = 4,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'make' } },
+ pos = 4,
+ },
+ },
+ }
end)
it('works with inputsecret()', function()
feed(":call inputsecret('secret:')<cr>abc123")
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- prompt = "secret:",
- content = {{"******"}},
- pos = 6,
- }}}
+ ]],
+ cmdline = {
+ {
+ prompt = 'secret:',
+ content = { { '******' } },
+ pos = 6,
+ },
+ },
+ }
end)
it('works with highlighted cmdline', function()
@@ -383,21 +502,33 @@ local function test_cmdline(linegrid)
"map <f5> :let x = input({'prompt':'>'})<cr>
]])
screen:set_default_attr_ids({
- RBP1={background = Screen.colors.Red},
- RBP2={background = Screen.colors.Yellow},
- EOB={bold = true, foreground = Screen.colors.Blue1},
+ RBP1 = { background = Screen.colors.Red },
+ RBP2 = { background = Screen.colors.Yellow },
+ EOB = { bold = true, foreground = Screen.colors.Blue1 },
})
feed('<f5>(a(b)a)')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{EOB:~ }|*3
|
- ]], cmdline={{
- prompt = '>',
- content = {{'(', 'RBP1'}, {'a'}, {'(', 'RBP2'}, {'b'},
- { ')', 'RBP2'}, {'a'}, {')', 'RBP1'}},
- pos = 7,
- }}}
+ ]],
+ cmdline = {
+ {
+ prompt = '>',
+ content = {
+ { '(', 'RBP1' },
+ { 'a' },
+ { '(', 'RBP2' },
+ { 'b' },
+ { ')', 'RBP2' },
+ { 'a' },
+ { ')', 'RBP1' },
+ },
+ pos = 7,
+ },
+ },
+ }
end)
it('works together with ext_wildmenu', function()
@@ -415,69 +546,102 @@ local function test_cmdline(linegrid)
screen:set_option('ext_wildmenu', true)
feed(':sign <tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign define"}},
- pos = 11,
- }}, wildmenu_items=expected, wildmenu_pos=0}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign define' } },
+ pos = 11,
+ },
+ },
+ wildmenu_items = expected,
+ wildmenu_pos = 0,
+ }
feed('<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign jump"}},
- pos = 9,
- }}, wildmenu_items=expected, wildmenu_pos=1}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign jump' } },
+ pos = 9,
+ },
+ },
+ wildmenu_items = expected,
+ wildmenu_pos = 1,
+ }
feed('<left><left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign "}},
- pos = 5,
- }}, wildmenu_items=expected, wildmenu_pos=-1}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign ' } },
+ pos = 5,
+ },
+ },
+ wildmenu_items = expected,
+ wildmenu_pos = -1,
+ }
feed('<right>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign define"}},
- pos = 11,
- }}, wildmenu_items=expected, wildmenu_pos=0}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign define' } },
+ pos = 11,
+ },
+ },
+ wildmenu_items = expected,
+ wildmenu_pos = 0,
+ }
feed('a')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign definea"}},
- pos = 12,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign definea' } },
+ pos = 12,
+ },
+ },
+ }
end)
it('works together with ext_popupmenu', function()
local expected = {
- {'define', '', '', ''},
- {'jump', '', '', ''},
- {'list', '', '', ''},
- {'place', '', '', ''},
- {'undefine', '', '', ''},
- {'unplace', '', '', ''},
+ { 'define', '', '', '' },
+ { 'jump', '', '', '' },
+ { 'list', '', '', '' },
+ { 'place', '', '', '' },
+ { 'undefine', '', '', '' },
+ { 'unplace', '', '', '' },
}
command('set wildmode=full')
@@ -485,80 +649,115 @@ local function test_cmdline(linegrid)
screen:set_option('ext_popupmenu', true)
feed(':sign <tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign define"}},
- pos = 11,
- }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign define' } },
+ pos = 11,
+ },
+ },
+ popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } },
+ }
feed('<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign jump"}},
- pos = 9,
- }}, popupmenu={items=expected, pos=1, anchor={-1, 0, 5}}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign jump' } },
+ pos = 9,
+ },
+ },
+ popupmenu = { items = expected, pos = 1, anchor = { -1, 0, 5 } },
+ }
feed('<left><left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign "}},
- pos = 5,
- }}, popupmenu={items=expected, pos=-1, anchor={-1, 0, 5}}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign ' } },
+ pos = 5,
+ },
+ },
+ popupmenu = { items = expected, pos = -1, anchor = { -1, 0, 5 } },
+ }
feed('<right>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign define"}},
- pos = 11,
- }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign define' } },
+ pos = 11,
+ },
+ },
+ popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } },
+ }
feed('a')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign definea"}},
- pos = 12,
- }}}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign definea' } },
+ pos = 12,
+ },
+ },
+ }
feed('<esc>')
-- check positioning with multibyte char in pattern
- command("e långfile1")
- command("sp långfile2")
+ command('e långfile1')
+ command('sp långfile2')
feed(':b lå<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{3:långfile2 }|
|
{2:långfile1 }|
|
- ]], popupmenu={
- anchor = { -1, 0, 2 },
- items = {{ "långfile1", "", "", "" }, { "långfile2", "", "", "" }},
- pos = 0
- }, cmdline={{
- content = {{ "b långfile1" }},
- firstc = ":",
- pos = 12
- }}}
+ ]],
+ popupmenu = {
+ anchor = { -1, 0, 2 },
+ items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
+ pos = 0,
+ },
+ cmdline = {
+ {
+ content = { { 'b långfile1' } },
+ firstc = ':',
+ pos = 12,
+ },
+ },
+ }
end)
it('ext_wildmenu takes precedence over ext_popupmenu', function()
@@ -577,15 +776,22 @@ local function test_cmdline(linegrid)
screen:set_option('ext_popupmenu', true)
feed(':sign <tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- firstc = ":",
- content = {{"sign define"}},
- pos = 11,
- }}, wildmenu_items=expected, wildmenu_pos=0}
+ ]],
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'sign define' } },
+ pos = 11,
+ },
+ },
+ wildmenu_items = expected,
+ wildmenu_pos = 0,
+ }
end)
it("doesn't send invalid events when aborting mapping #10000", function()
@@ -593,16 +799,21 @@ local function test_cmdline(linegrid)
command('cnoremap ab c')
feed(':xa')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]], cmdline={{
- content = { { "x" } },
- firstc = ":",
- pos = 1,
- special = { "a", false }
- }}}
+ ]],
+ cmdline = {
+ {
+ content = { { 'x' } },
+ firstc = ':',
+ pos = 1,
+ special = { 'a', false },
+ },
+ },
+ }
-- This used to send an invalid event where pos where larger than the total
-- length of content. Checked in _handle_cmdline_show.
@@ -613,61 +824,75 @@ local function test_cmdline(linegrid)
|
]])
end)
-
end
-- the representation of cmdline and cmdline_block contents changed with ext_linegrid
-- (which uses indexed highlights) so make sure to test both
-describe('ui/ext_cmdline', function() test_cmdline(true) end)
-describe('ui/ext_cmdline (legacy highlights)', function() test_cmdline(false) end)
+describe('ui/ext_cmdline', function()
+ test_cmdline(true)
+end)
+describe('ui/ext_cmdline (legacy highlights)', function()
+ test_cmdline(false)
+end)
describe('cmdline redraw', function()
local screen
before_each(function()
clear()
- screen = new_screen({rgb=true})
+ screen = new_screen({ rgb = true })
end)
it('with timer', function()
feed(':012345678901234567890123456789')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
- ]]}
+ ]],
+ }
command('call timer_start(0, {-> 1})')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
- ]], unchanged=true, timeout=100}
+ ]],
+ unchanged = true,
+ timeout = 100,
+ }
end)
it('with <Cmd>', function()
if is_os('bsd') then
pending('FIXME #10804')
end
- command('cmap a <Cmd>call sin(0)<CR>') -- no-op
+ command('cmap a <Cmd>call sin(0)<CR>') -- no-op
feed(':012345678901234567890123456789')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
- ]]}
+ ]],
+ }
feed('a')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end)
it('after pressing Ctrl-C in cmdwin in Visual mode #18967', function()
@@ -697,64 +922,80 @@ describe('cmdline redraw', function()
it('with rightleftcmd', function()
command('set rightleft rightleftcmd=search shortmess+=s')
- meths.buf_set_lines(0, 0, -1, true, {"let's rock!"})
- screen:expect{grid=[[
+ meths.buf_set_lines(0, 0, -1, true, { "let's rock!" })
+ screen:expect {
+ grid = [[
!kcor s'te^l|
{1: ~}|*3
|
- ]]}
+ ]],
+ }
feed '/'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
!kcor s'tel|
{1: ~}|*3
^ /|
- ]]}
+ ]],
+ }
feed "let's"
-- note: cursor looks off but looks alright in real use
-- when rendered as a block so it touches the end of the text
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
!kcor {2:s'tel}|
{1: ~}|*3
^ s'tel/|
- ]]}
+ ]],
+ }
-- cursor movement
- feed "<space>"
- screen:expect{grid=[[
+ feed '<space>'
+ screen:expect {
+ grid = [[
!kcor{2: s'tel}|
{1: ~}|*3
^ s'tel/|
- ]]}
+ ]],
+ }
- feed "rock"
- screen:expect{grid=[[
+ feed 'rock'
+ screen:expect {
+ grid = [[
!{2:kcor s'tel}|
{1: ~}|*3
^ kcor s'tel/|
- ]]}
+ ]],
+ }
- feed "<right>"
- screen:expect{grid=[[
+ feed '<right>'
+ screen:expect {
+ grid = [[
!{2:kcor s'tel}|
{1: ~}|*3
^kcor s'tel/|
- ]]}
+ ]],
+ }
- feed "<left>"
- screen:expect{grid=[[
+ feed '<left>'
+ screen:expect {
+ grid = [[
!{2:kcor s'tel}|
{1: ~}|*3
^ kcor s'tel/|
- ]]}
+ ]],
+ }
- feed "<cr>"
- screen:expect{grid=[[
+ feed '<cr>'
+ screen:expect {
+ grid = [[
!{10:kcor s'te^l}|
{1: ~}|*3
kcor s'tel/ |
- ]]}
+ ]],
+ }
end)
end)
@@ -769,44 +1010,52 @@ describe('statusline is redrawn on entering cmdline', function()
it('from normal mode', function()
command('set statusline=%{mode()}')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*2
{3:n }|
|
- ]]}
+ ]],
+ }
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3:c }|
:^ |
- ]]}
+ ]],
+ }
end)
it('from normal mode when : is mapped', function()
command('set statusline=%{mode()}')
command('nnoremap ; :')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*2
{3:n }|
|
- ]]}
+ ]],
+ }
feed(';')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3:c }|
:^ |
- ]]}
+ ]],
+ }
end)
it('with scrolled messages', function()
- screen:try_resize(35,14)
+ screen:try_resize(35, 14)
exec([[
let g:count = 0
autocmd CmdlineEnter * let g:count += 1
@@ -816,7 +1065,8 @@ describe('statusline is redrawn on entering cmdline', function()
setlocal winbar=%{mode()}%{g:count}
]])
feed(':echoerr doesnotexist<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:c1 }|
|
{3:c1 }|
@@ -827,9 +1077,11 @@ describe('statusline is redrawn on entering cmdline', function()
{4:ist} |
{5:Press ENTER or type command to cont}|
{5:inue}^ |
- ]]}
+ ]],
+ }
feed(':echoerr doesnotexist<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:c2 }|
|
{3:c2 }|
@@ -843,10 +1095,12 @@ describe('statusline is redrawn on entering cmdline', function()
{4:ist} |
{5:Press ENTER or type command to cont}|
{5:inue}^ |
- ]]}
+ ]],
+ }
feed(':echoerr doesnotexist<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:c3 }|
|
{3:c3 }|
@@ -861,10 +1115,12 @@ describe('statusline is redrawn on entering cmdline', function()
{4:ist} |
{5:Press ENTER or type command to cont}|
{5:inue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:n3 }|
^ |
{3:n3 }|
@@ -872,40 +1128,47 @@ describe('statusline is redrawn on entering cmdline', function()
{1:~ }|*8
{2:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
describe('if custom statusline is set by', function()
before_each(function()
command('set statusline=')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*2
{3:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
it('CmdlineEnter autocommand', function()
command('autocmd CmdlineEnter * set statusline=command')
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3:command }|
:^ |
- ]]}
+ ]],
+ }
end)
it('ModeChanged autocommand', function()
command('autocmd ModeChanged *:c set statusline=command')
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3:command }|
:^ |
- ]]}
+ ]],
+ }
end)
end)
end)
@@ -914,9 +1177,9 @@ it('tabline is not redrawn in Ex mode #24122', function()
clear()
local screen = Screen.new(60, 5)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
- [1] = {bold = true, reverse = true}, -- MsgSeparator
- [2] = {reverse = true}, -- TabLineFill
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { bold = true, reverse = true }, -- MsgSeparator
+ [2] = { reverse = true }, -- TabLineFill
})
screen:attach()
@@ -931,28 +1194,32 @@ it('tabline is not redrawn in Ex mode #24122', function()
]])
feed('gQ')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:foo }|
|
{1: }|
Entering Ex mode. Type "visual" to go to Normal mode. |
:^ |
- ]]}
+ ]],
+ }
feed('echo 1<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }|
Entering Ex mode. Type "visual" to go to Normal mode. |
:echo 1 |
1 |
:^ |
- ]]}
+ ]],
+ }
end)
-describe("cmdline height", function()
+describe('cmdline height', function()
before_each(clear)
- it("does not crash resized screen #14263", function()
+ it('does not crash resized screen #14263', function()
local screen = Screen.new(25, 10)
screen:attach()
command('set cmdheight=9999')
@@ -976,254 +1243,320 @@ describe('cmdheight=0', function()
clear()
screen = Screen.new(25, 5)
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue};
- [2] = {bold = true, reverse = true};
- [3] = {bold = true};
- [4] = {foreground = Screen.colors.White, background = Screen.colors.Red};
- [5] = {foreground = Screen.colors.SeaGreen4, bold = true};
- [6] = {reverse = true};
- [7] = {background = Screen.colors.Yellow};
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { bold = true, reverse = true },
+ [3] = { bold = true },
+ [4] = { foreground = Screen.colors.White, background = Screen.colors.Red },
+ [5] = { foreground = Screen.colors.SeaGreen4, bold = true },
+ [6] = { reverse = true },
+ [7] = { background = Screen.colors.Yellow },
}
screen:attach()
end)
- it("with redrawdebug=invalid resize -1", function()
- command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0")
- screen:expect{grid=[[
+ it('with redrawdebug=invalid resize -1', function()
+ command('set redrawdebug=invalid cmdheight=0 noruler laststatus=0')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
- feed(":resize -1<CR>")
- screen:expect{grid=[[
+ ]],
+ }
+ feed(':resize -1<CR>')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
assert_alive()
end)
- it("with cmdheight=1 noruler laststatus=2", function()
- command("set cmdheight=1 noruler laststatus=2")
- screen:expect{grid=[[
+ it('with cmdheight=1 noruler laststatus=2', function()
+ command('set cmdheight=1 noruler laststatus=2')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*2
{2:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
- it("with cmdheight=0 noruler laststatus=2", function()
- command("set cmdheight=0 noruler laststatus=2")
- screen:expect{grid=[[
+ it('with cmdheight=0 noruler laststatus=2', function()
+ command('set cmdheight=0 noruler laststatus=2')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{2:[No Name] }|
- ]]}
+ ]],
+ }
end)
- it("with cmdheight=0 ruler laststatus=0", function()
- command("set cmdheight=0 ruler laststatus=0")
- screen:expect{grid=[[
+ it('with cmdheight=0 ruler laststatus=0', function()
+ command('set cmdheight=0 ruler laststatus=0')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
- it("with cmdheight=0 ruler laststatus=0", function()
- command("set cmdheight=0 noruler laststatus=0 showmode")
+ it('with cmdheight=0 ruler laststatus=0', function()
+ command('set cmdheight=0 noruler laststatus=0 showmode')
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={}}
+ ]],
+ showmode = {},
+ }
feed('<Esc>')
eq(0, eval('&cmdheight'))
end)
- it("with cmdheight=0 ruler rulerformat laststatus=0", function()
- command("set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode")
+ it('with cmdheight=0 ruler rulerformat laststatus=0', function()
+ command('set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode')
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={}}
+ ]],
+ showmode = {},
+ }
feed('<Esc>')
eq(0, eval('&cmdheight'))
end)
- it("with showmode", function()
- command("set cmdheight=1 noruler laststatus=0 showmode")
+ it('with showmode', function()
+ command('set cmdheight=1 noruler laststatus=0 showmode')
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{3:-- INSERT --} |
- ]]}
+ ]],
+ }
feed('<Esc>')
eq(1, eval('&cmdheight'))
end)
- it("when using command line", function()
- command("set cmdheight=0 noruler laststatus=0")
+ it('when using command line', function()
+ command('set cmdheight=0 noruler laststatus=0')
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
:^ |
- ]]}
+ ]],
+ }
eq(0, eval('&cmdheight'))
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={}}
+ ]],
+ showmode = {},
+ }
eq(0, eval('&cmdheight'))
end)
- it("when using input()", function()
- command("set cmdheight=0 noruler laststatus=0")
+ it('when using input()', function()
+ command('set cmdheight=0 noruler laststatus=0')
feed(':call input("foo >")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{2: }|
:call input("foo >") |
foo >^ |
- ]]}
+ ]],
+ }
eq(0, eval('&cmdheight'))
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={}}
+ ]],
+ showmode = {},
+ }
eq(0, eval('&cmdheight'))
end)
- it("with winbar and splits", function()
- command("set cmdheight=0 noruler laststatus=3 winbar=foo")
+ it('with winbar and splits', function()
+ command('set cmdheight=0 noruler laststatus=3 winbar=foo')
feed(':split<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2: }|
:split |
{4:E36: Not enough room} |
{5:Press ENTER or type comma}|
{5:nd to continue}^ |
- ]]}
+ ]],
+ }
feed('<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:foo }|
^ |
{1:~ }|*2
{2:[No Name] }|
- ]]}
+ ]],
+ }
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:foo }|
|
{1:~ }|*2
:^ |
- ]]}
+ ]],
+ }
feed('<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:foo }|
^ |
{1:~ }|*2
{2:[No Name] }|
- ]], showmode={}}
+ ]],
+ showmode = {},
+ }
eq(0, eval('&cmdheight'))
assert_alive()
end)
- it("when macro with lastline", function()
- command("set cmdheight=0 display=lastline")
+ it('when macro with lastline', function()
+ command('set cmdheight=0 display=lastline')
feed('qq')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end)
- it("when substitute text", function()
- command("set cmdheight=0 noruler laststatus=3")
+ it('when substitute text', function()
+ command('set cmdheight=0 noruler laststatus=3')
feed('ifoo<ESC>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
fo^o |
{1:~ }|*3
{2:[No Name] [+] }|
- ]]}
+ ]],
+ }
feed(':%s/foo/bar/gc<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{6:foo} |
{1:~ }|*3
{5:replace wi...q/l/^E/^Y)?}^ |
- ]]}
+ ]],
+ }
feed('y')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^bar |
{1:~ }|*3
{2:[No Name] [+] }|
- ]]}
+ ]],
+ }
assert_alive()
end)
- it("when window resize", function()
- command("set cmdheight=0")
+ it('when window resize', function()
+ command('set cmdheight=0')
feed('<C-w>+')
eq(0, eval('&cmdheight'))
end)
- it("with non-silent mappings with cmdline", function()
- command("set cmdheight=0")
- command("map <f3> :nohlsearch<cr>")
+ it('with non-silent mappings with cmdline', function()
+ command('set cmdheight=0')
+ command('map <f3> :nohlsearch<cr>')
feed('iaabbaa<esc>/aa<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:^aa}bb{7:aa} |
{1:~ }|*4
- ]]}
+ ]],
+ }
feed('<f3>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^aabbaa |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it('with silent! at startup', function()
- clear{args={'-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()'}}
+ clear { args = { '-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()' } }
screen:attach()
-- doesn't crash while not displaying silent! error message
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it('with multigrid', function()
- clear{args={'--cmd', 'set cmdheight=0'}}
- screen:attach{ext_multigrid=true}
- meths.buf_set_lines(0, 0, -1, true, {'p'})
- screen:expect{grid=[[
+ clear { args = { '--cmd', 'set cmdheight=0' } }
+ screen:attach { ext_multigrid = true }
+ meths.buf_set_lines(0, 0, -1, true, { 'p' })
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------------]|*5
## grid 2
^p |
{1:~ }|*4
## grid 3
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
feed '/p'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------------]|*4
[3:-------------------------]|
@@ -1232,9 +1565,19 @@ describe('cmdheight=0', function()
{1:~ }|*4
## grid 3
/p^ |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
end)
it('winbar is redrawn on entering cmdline and :redrawstatus #20336', function()
@@ -1324,18 +1667,22 @@ describe('cmdheight=0', function()
|
]])
command('set cmdheight=0')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{2:[No Name] }|
- ]]}
+ ]],
+ }
command('resize -1')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*2
{2:[No Name] }|
|
- ]]}
+ ]],
+ }
command('resize +1')
screen:expect([[
^ |
@@ -1344,9 +1691,9 @@ describe('cmdheight=0', function()
]])
end)
- it("cannot be resized at all with external messages", function()
+ it('cannot be resized at all with external messages', function()
clear()
- screen = new_screen({rgb=true, ext_messages=true})
+ screen = new_screen({ rgb = true, ext_messages = true })
command('set laststatus=2 mouse=a')
command('resize -1')
screen:expect([[
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 7f4d167c41..9b3de1e108 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -27,7 +27,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'n' },
+ short_name = 'n',
+ },
[2] = {
blinkoff = 0,
blinkon = 0,
@@ -40,7 +41,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'v' },
+ short_name = 'v',
+ },
[3] = {
blinkoff = 0,
blinkon = 0,
@@ -53,7 +55,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'i' },
+ short_name = 'i',
+ },
[4] = {
blinkoff = 0,
blinkon = 0,
@@ -66,7 +69,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'r' },
+ short_name = 'r',
+ },
[5] = {
blinkoff = 0,
blinkon = 0,
@@ -79,7 +83,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'c' },
+ short_name = 'c',
+ },
[6] = {
blinkoff = 0,
blinkon = 0,
@@ -92,7 +97,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'ci' },
+ short_name = 'ci',
+ },
[7] = {
blinkoff = 0,
blinkon = 0,
@@ -105,7 +111,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'cr' },
+ short_name = 'cr',
+ },
[8] = {
blinkoff = 0,
blinkon = 0,
@@ -118,7 +125,8 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 'o' },
+ short_name = 'o',
+ },
[9] = {
blinkoff = 0,
blinkon = 0,
@@ -131,35 +139,43 @@ describe('ui/cursor', function()
attr = {},
attr_lm = {},
mouse_shape = 0,
- short_name = 've' },
+ short_name = 've',
+ },
[10] = {
name = 'cmdline_hover',
mouse_shape = 0,
- short_name = 'e' },
+ short_name = 'e',
+ },
[11] = {
name = 'statusline_hover',
mouse_shape = 0,
- short_name = 's' },
+ short_name = 's',
+ },
[12] = {
name = 'statusline_drag',
mouse_shape = 0,
- short_name = 'sd' },
+ short_name = 'sd',
+ },
[13] = {
name = 'vsep_hover',
mouse_shape = 0,
- short_name = 'vs' },
+ short_name = 'vs',
+ },
[14] = {
name = 'vsep_drag',
mouse_shape = 0,
- short_name = 'vd' },
+ short_name = 'vd',
+ },
[15] = {
name = 'more',
mouse_shape = 0,
- short_name = 'm' },
+ short_name = 'm',
+ },
[16] = {
name = 'more_lastline',
mouse_shape = 0,
- short_name = 'ml' },
+ short_name = 'ml',
+ },
[17] = {
blinkoff = 0,
blinkon = 0,
@@ -171,8 +187,9 @@ describe('ui/cursor', function()
id_lm = 0,
attr = {},
attr_lm = {},
- short_name = 'sm' },
- }
+ short_name = 'sm',
+ },
+ }
screen:expect(function()
-- Default 'guicursor', published on startup.
@@ -184,36 +201,55 @@ describe('ui/cursor', function()
-- Event is published ONLY if the cursor style changed.
screen._mode_info = nil
command("echo 'test'")
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
~ |*3
test |
- ]], condition=function()
- eq(nil, screen._mode_info)
- end}
+ ]],
+ condition = function()
+ eq(nil, screen._mode_info)
+ end,
+ }
-- Change the cursor style.
helpers.command('hi Cursor guibg=DarkGray')
- 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')
+ 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
+ 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
+ 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 = 64
- m.attr = {background = Screen.colors.DarkGray}
+ m.hl_id = 64
+ m.attr = { background = Screen.colors.DarkGray }
+ end
+ if m.id_lm then
+ m.id_lm = 70
end
- if m.id_lm then m.id_lm = 70 end
end
-- Assert the new expectation.
@@ -230,10 +266,10 @@ describe('ui/cursor', function()
-- Update the expected values.
for _, m in ipairs(expected_mode_info) do
if m.hl_id then
- m.attr = {background = Screen.colors.Red}
+ m.attr = { background = Screen.colors.Red }
end
if m.id_lm then
- m.attr_lm = {background = Screen.colors.Green}
+ m.attr_lm = { background = Screen.colors.Green }
end
end
-- Assert the new expectation.
@@ -248,21 +284,27 @@ describe('ui/cursor', function()
for _, m in ipairs(expected_mode_info) do
if m.hl_id then
- m.attr = {background = Screen.colors.Red, blend = 100}
+ m.attr = { background = Screen.colors.Red, blend = 100 }
end
end
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
~ |*3
test |
- ]], condition=function()
- eq(expected_mode_info, screen._mode_info)
- end
+ ]],
+ condition = function()
+ eq(expected_mode_info, screen._mode_info)
+ end,
}
-- Another cursor style.
- meths.set_option_value('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
- ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', {})
+ meths.set_option_value(
+ '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
@@ -284,9 +326,13 @@ describe('ui/cursor', function()
end)
-- If there is no setting for guicursor, it becomes the default setting.
- meths.set_option_value('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {})
+ meths.set_option_value(
+ 'guicursor',
+ 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor',
+ {}
+ )
screen:expect(function()
- for _,m in ipairs(screen._mode_info) do
+ for _, m in ipairs(screen._mode_info) do
if m.name ~= 'normal' then
eq('block', m.cursor_shape or 'block')
eq(0, m.blinkon or 0)
@@ -314,5 +360,4 @@ describe('ui/cursor', function()
end
end)
end)
-
end)
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index 71bbb2f003..e208385e92 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -41,21 +41,21 @@ describe('Diff mode screen', function()
screen = Screen.new(40, 16)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {bold = true, reverse = true},
- [8] = {bold = true, background = Screen.colors.Red},
- [9] = {background = Screen.colors.LightMagenta},
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
+ [6] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { bold = true, reverse = true },
+ [8] = { bold = true, background = Screen.colors.Red },
+ [9] = { background = Screen.colors.LightMagenta },
})
end)
it('Add a line in beginning of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
+ write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
+ write_file(fname_2, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
reread()
feed(':set diffopt=filler<cr>')
@@ -90,11 +90,11 @@ describe('Diff mode screen', function()
end)
it('Add a line in beginning of file 1', function()
- write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
+ write_file(fname, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
reread()
- feed(":set diffopt=filler<cr>")
+ feed(':set diffopt=filler<cr>')
screen:expect([[
{1: }{4:^0 }│{1: }{2:-----------------}|
{1: }1 │{1: }1 |
@@ -109,7 +109,7 @@ describe('Diff mode screen', function()
:set diffopt=filler |
]])
- feed(":set diffopt+=internal<cr>")
+ feed(':set diffopt+=internal<cr>')
screen:expect([[
{1: }{4:^0 }│{1: }{2:-----------------}|
{1: }1 │{1: }1 |
@@ -126,11 +126,11 @@ describe('Diff mode screen', function()
end)
it('Add a line at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
+ write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
reread()
- feed(":set diffopt=filler<cr>")
+ feed(':set diffopt=filler<cr>')
screen:expect([[
{1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
{1: }5 │{1: }5 |
@@ -145,7 +145,7 @@ describe('Diff mode screen', function()
:set diffopt=filler |
]])
- feed(":set diffopt+=internal<cr>")
+ feed(':set diffopt+=internal<cr>')
screen:expect([[
{1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
{1: }5 │{1: }5 |
@@ -175,11 +175,11 @@ describe('Diff mode screen', function()
end)
it('Add a line at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
+ write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
reread()
- feed(":set diffopt=filler<cr>")
+ feed(':set diffopt=filler<cr>')
screen:expect([[
{1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
{1: }5 │{1: }5 |
@@ -194,7 +194,7 @@ describe('Diff mode screen', function()
:set diffopt=filler |
]])
- feed(":set diffopt+=internal<cr>")
+ feed(':set diffopt+=internal<cr>')
screen:expect([[
{1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
{1: }5 │{1: }5 |
@@ -224,8 +224,8 @@ describe('Diff mode screen', function()
end)
it('Add a line in the middle of file 2, remove on at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
+ write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false)
reread()
feed(':set diffopt=filler<cr>')
@@ -268,8 +268,8 @@ describe('Diff mode screen', function()
end)
it('Add a line in the middle of file 1, remove on at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
+ write_file(fname, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
reread()
feed(':set diffopt=filler<cr>')
@@ -523,7 +523,7 @@ int main(int argc, char **argv)
it('internal', function()
reread()
- feed(":set diffopt=internal,filler<cr>")
+ feed(':set diffopt=internal,filler<cr>')
screen:expect([[
{1: }^def finalize(value│{1: }def finalize(valu|
{1: } │{1: } |
@@ -581,8 +581,8 @@ int main(int argc, char **argv)
end)
it('Diff the same file', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
+ write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
+ write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
reread()
feed(':set diffopt=filler<cr>')
@@ -603,8 +603,8 @@ int main(int argc, char **argv)
end)
it('Diff an empty file', function()
- write_file(fname, "", false)
- write_file(fname_2, "", false)
+ write_file(fname, '', false)
+ write_file(fname_2, '', false)
reread()
feed(':set diffopt=filler<cr>')
@@ -625,8 +625,8 @@ int main(int argc, char **argv)
end)
it('diffopt+=icase', function()
- write_file(fname, "a\nb\ncd\n", false)
- write_file(fname_2, "A\nb\ncDe\n", false)
+ write_file(fname, 'a\nb\ncd\n', false)
+ write_file(fname_2, 'A\nb\ncDe\n', false)
reread()
feed(':set diffopt=filler,icase<cr>')
@@ -654,7 +654,8 @@ int main(int argc, char **argv)
setup(function()
local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
write_file(fname, f1, false)
- local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
+ local f2 =
+ 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
write_file(fname_2, f2, false)
feed(':diffupdate!<cr>')
end)
@@ -821,7 +822,9 @@ int main(int argc, char **argv)
-- This was scrolling for 'cursorbind' but 'scrollbind' is more important
it('scrolling works correctly vim-patch:8.2.5155', function()
screen:try_resize(40, 12)
- write_file(fname, dedent([[
+ write_file(
+ fname,
+ dedent([[
line 1
line 2
line 3
@@ -835,8 +838,12 @@ int main(int argc, char **argv)
// Common block
// two
// containing
- // four lines]]), false)
- write_file(fname_2, dedent([[
+ // four lines]]),
+ false
+ )
+ write_file(
+ fname_2,
+ dedent([[
line 1
line 2
line 3
@@ -869,7 +876,9 @@ int main(int argc, char **argv)
// Common block
// two
// containing
- // four lines]]), false)
+ // four lines]]),
+ false
+ )
reread()
feed('<C-W><C-W>jjjj')
@@ -1016,33 +1025,38 @@ AAAB]]
it('diffopt+=linematch:20,iwhiteall', function()
reread()
feed(':set diffopt=internal,filler,linematch:20<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }^BB │{1: }BB |
{1: }{9: AA}{8:A}{9: }│{1: }{9: AA}{8:B}{9: }|
{1: }{2:------------------}│{1: }{4:AAAB }|
{6:~ }│{6:~ }|*11
{7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
|
- ]]}
+ ]],
+ }
feed(':set diffopt+=iwhiteall<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }^BB │{1: }BB |
{1: }{2:------------------}│{1: }{4: AAB }|
{1: }{9: AAA }│{1: }{9:AAA}{8:B}{9: }|
{6:~ }│{6:~ }|*11
{7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
:set diffopt+=iwhiteall |
- ]]}
+ ]],
+ }
end)
end)
it('redraws with a change to non-current buffer', function()
- write_file(fname, "aaa\nbbb\nccc\n\nxx", false)
- write_file(fname_2, "aaa\nbbb\nccc\n\nyy", false)
+ write_file(fname, 'aaa\nbbb\nccc\n\nxx', false)
+ write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false)
reread()
local buf = meths.get_current_buf()
command('botright new')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }aaa │{1: }aaa |
{1: }bbb │{1: }bbb |
{1: }ccc │{1: }ccc |
@@ -1054,10 +1068,12 @@ AAAB]]
{6:~ }|*6
{7:[No Name] }|
:e |
- ]]}
+ ]],
+ }
- meths.buf_set_lines(buf, 1, 2, true, {'BBB'})
- screen:expect{grid=[[
+ meths.buf_set_lines(buf, 1, 2, true, { 'BBB' })
+ screen:expect {
+ grid = [[
{1: }aaa │{1: }aaa |
{1: }{8:BBB}{9: }│{1: }{8:bbb}{9: }|
{1: }ccc │{1: }ccc |
@@ -1069,16 +1085,18 @@ AAAB]]
{6:~ }|*6
{7:[No Name] }|
:e |
- ]]}
+ ]],
+ }
end)
- it('redraws with a change current buffer in another window', function()
- write_file(fname, "aaa\nbbb\nccc\n\nxx", false)
- write_file(fname_2, "aaa\nbbb\nccc\n\nyy", false)
+ it('redraws with a change current buffer in another window', function()
+ write_file(fname, 'aaa\nbbb\nccc\n\nxx', false)
+ write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false)
reread()
local buf = meths.get_current_buf()
command('botright split | diffoff')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }aaa │{1: }aaa |
{1: }bbb │{1: }bbb |
{1: }ccc │{1: }ccc |
@@ -1094,10 +1112,12 @@ AAAB]]
{6:~ }|*2
{7:Xtest-functional-diff-screen-1 }|
:e |
- ]]}
+ ]],
+ }
- meths.buf_set_lines(buf, 1, 2, true, {'BBB'})
- screen:expect{grid=[[
+ meths.buf_set_lines(buf, 1, 2, true, { 'BBB' })
+ screen:expect {
+ grid = [[
{1: }aaa │{1: }aaa |
{1: }{8:BBB}{9: }│{1: }{8:bbb}{9: }|
{1: }ccc │{1: }ccc |
@@ -1113,7 +1133,8 @@ AAAB]]
{6:~ }|*2
{7:Xtest-functional-diff-screen-1 [+] }|
:e |
- ]]}
+ ]],
+ }
end)
end)
@@ -1122,24 +1143,28 @@ it('win_update redraws lines properly', function()
screen = Screen.new(50, 10)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {background = Screen.colors.Red, foreground = Screen.colors.Grey100, special = Screen.colors.Yellow},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {special = Screen.colors.Yellow},
- [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4},
- [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100},
- [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100},
- [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100},
- [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')},
- [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452')},
- [12] = {bold = true, reverse = true},
- [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [14] = {reverse = true},
- [15] = {background = Screen.colors.LightBlue},
- [16] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [17] = {bold = true, background = Screen.colors.Red},
- [18] = {background = Screen.colors.LightMagenta},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = {
+ background = Screen.colors.Red,
+ foreground = Screen.colors.Grey100,
+ special = Screen.colors.Yellow,
+ },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { special = Screen.colors.Yellow },
+ [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 },
+ [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 },
+ [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 },
+ [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 },
+ [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') },
+ [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') },
+ [12] = { bold = true, reverse = true },
+ [13] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [14] = { reverse = true },
+ [15] = { background = Screen.colors.LightBlue },
+ [16] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
+ [17] = { bold = true, background = Screen.colors.Red },
+ [18] = { background = Screen.colors.LightMagenta },
})
insert([[
@@ -1149,15 +1174,16 @@ it('win_update redraws lines properly', function()
2
1a
]])
- command("vnew left")
+ command('vnew left')
insert([[
2
2a
2b
]])
- command("windo diffthis")
- command("windo 1")
- screen:expect{grid=[[
+ command('windo diffthis')
+ command('windo 1')
+ screen:expect {
+ grid = [[
{13: }{16:-----------------------}│{13: }{15:^1 }|
{13: }{16:-----------------------}│{13: }{15: }|*2
{13: }2 │{13: }2 |
@@ -1167,13 +1193,15 @@ it('win_update redraws lines properly', function()
{1:~ }│{1:~ }|
{14:left [+] }{12:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
feed('<C-e>')
feed('<C-e>')
feed('<C-y>')
feed('<C-y>')
feed('<C-y>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{13: }{16:-----------------------}│{13: }{15:1 }|
{13: }{16:-----------------------}│{13: }{15: }|
{13: }{16:-----------------------}│{13: }{15:^ }|
@@ -1184,7 +1212,8 @@ it('win_update redraws lines properly', function()
{1:~ }│{1:~ }|
{14:left [+] }{12:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
end)
-- oldtest: Test_diff_rnu()
@@ -1192,17 +1221,17 @@ it('diff updates line numbers below filler lines', function()
local screen = Screen.new(40, 14)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {bold = true, reverse = true},
- [8] = {bold = true, background = Screen.colors.Red},
- [9] = {background = Screen.colors.LightMagenta},
- [10] = {bold = true, foreground = Screen.colors.Brown},
- [11] = {foreground = Screen.colors.Brown},
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
+ [6] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { bold = true, reverse = true },
+ [8] = { bold = true, background = Screen.colors.Red },
+ [9] = { background = Screen.colors.LightMagenta },
+ [10] = { bold = true, foreground = Screen.colors.Brown },
+ [11] = { foreground = Screen.colors.Brown },
})
exec([[
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
@@ -1265,14 +1294,14 @@ it('Align the filler lines when changing text in diff mode', function()
local screen = Screen.new(40, 20)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {background = Screen.colors.LightMagenta};
- [6] = {background = Screen.colors.Red, bold = true};
- [7] = {foreground = Screen.colors.Blue1, bold = true};
- [8] = {reverse = true, bold = true};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { background = Screen.colors.LightMagenta },
+ [6] = { background = Screen.colors.Red, bold = true },
+ [7] = { foreground = Screen.colors.Blue1, bold = true },
+ [8] = { reverse = true, bold = true },
})
exec([[
call setline(1, range(1, 15))
@@ -1282,7 +1311,8 @@ it('Align the filler lines when changing text in diff mode', function()
wincmd h
exe "normal Gl5\<C-E>"
]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }{2:------------------}│{1: }{4:6 }|
{1: }{2:------------------}│{1: }{4:7 }|
{1: }{2:------------------}│{1: }{4:8 }|
@@ -1296,9 +1326,11 @@ it('Align the filler lines when changing text in diff mode', function()
{7:~ }│{7:~ }|*8
{8:[No Name] [+] }{3:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
feed('ax<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }{2:------------------}│{1: }{4:6 }|
{1: }{2:------------------}│{1: }{4:7 }|
{1: }{2:------------------}│{1: }{4:8 }|
@@ -1312,9 +1344,11 @@ it('Align the filler lines when changing text in diff mode', function()
{7:~ }│{7:~ }|*8
{8:[No Name] [+] }{3:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
feed('<C-W>lay<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }{2:-----------------}│{1: }{4:6 }|
{1: }{2:-----------------}│{1: }{4:7 }|
{1: }{2:-----------------}│{1: }{4:8 }|
@@ -1328,13 +1362,14 @@ it('Align the filler lines when changing text in diff mode', function()
{7:~ }│{7:~ }|*8
{3:[No Name] [+] }{8:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
end)
it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
local screen = Screen.new(60, 6)
screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Blue, bold = true};
+ [0] = { foreground = Screen.colors.Blue, bold = true },
})
screen:attach()
eq('0', meths.get_option_value('foldcolumn', {}))
@@ -1351,14 +1386,14 @@ end)
it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
local screen = Screen.new(40, 20)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {reverse = true};
- [3] = {background = Screen.colors.LightBlue};
- [4] = {background = Screen.colors.LightMagenta};
- [5] = {background = Screen.colors.Red, bold = true};
- [6] = {foreground = Screen.colors.Blue, bold = true};
- [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true};
- [8] = {reverse = true, bold = true};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { reverse = true },
+ [3] = { background = Screen.colors.LightBlue },
+ [4] = { background = Screen.colors.LightMagenta },
+ [5] = { background = Screen.colors.Red, bold = true },
+ [6] = { foreground = Screen.colors.Blue, bold = true },
+ [7] = { background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true },
+ [8] = { reverse = true, bold = true },
})
screen:attach()
exec([[
@@ -1439,10 +1474,10 @@ it("diff mode draws 'breakindent' correctly after filler lines", function()
local screen = Screen.new(45, 8)
screen:attach()
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue};
- [2] = {background = Screen.colors.LightBlue};
- [3] = {background = Screen.colors.LightCyan, bold = true, foreground = Screen.colors.Blue};
- [4] = {foreground = Screen.colors.Blue, bold = true};
+ [1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue },
+ [2] = { background = Screen.colors.LightBlue },
+ [3] = { background = Screen.colors.LightCyan, bold = true, foreground = Screen.colors.Blue },
+ [4] = { foreground = Screen.colors.Blue, bold = true },
})
exec([[
set laststatus=0 diffopt+=followwrap breakindent
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index 9d7934a8c6..1ce465eaae 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -1,4 +1,4 @@
-local uv = require'luv'
+local uv = require 'luv'
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
@@ -15,20 +15,20 @@ local retry = helpers.retry
local function test_embed(ext_linegrid)
local screen
local function startup(...)
- clear{args_rm={'--headless'}, args={...}}
+ clear { args_rm = { '--headless' }, args = { ... } }
-- attach immediately after startup, for early UI
screen = Screen.new(60, 8)
- screen:attach{ext_linegrid=ext_linegrid}
+ screen:attach { ext_linegrid = ext_linegrid }
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [2] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [3] = {bold = true, foreground = Screen.colors.Blue1},
- [4] = {bold = true, foreground = Screen.colors.Green},
- [5] = {bold = true, reverse = true},
- [6] = {foreground = Screen.colors.NvimDarkGrey3, background = Screen.colors.NvimLightGrey1};
- [7] = {foreground = Screen.colors.NvimDarkRed};
- [8] = {foreground = Screen.colors.NvimDarkCyan};
+ [1] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [2] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [3] = { bold = true, foreground = Screen.colors.Blue1 },
+ [4] = { bold = true, foreground = Screen.colors.Green },
+ [5] = { bold = true, reverse = true },
+ [6] = { foreground = Screen.colors.NvimDarkGrey3, background = Screen.colors.NvimLightGrey1 },
+ [7] = { foreground = Screen.colors.NvimDarkRed },
+ [8] = { foreground = Screen.colors.NvimDarkCyan },
})
end
@@ -67,21 +67,28 @@ local function test_embed(ext_linegrid)
it("doesn't erase output when setting Normal colors", function()
startup('--cmd', 'echoerr "foo"', '--cmd', 'hi Normal guibg=Green', '--cmd', 'echoerr "bar"')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|*3
{6: }|
{7:Error detected while processing pre-vimrc command line:} |
{7:foo} |
{7:bar} |
{8:Press ENTER or type command to continue}^ |
- ]], condition=function()
- eq(Screen.colors.Green, screen.default_colors.rgb_bg)
- end}
+ ]],
+ condition = function()
+ eq(Screen.colors.Green, screen.default_colors.rgb_bg)
+ end,
+ }
end)
end
-describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end)
-describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end)
+describe('--embed UI on startup (ext_linegrid=true)', function()
+ test_embed(true)
+end)
+describe('--embed UI on startup (ext_linegrid=false)', function()
+ test_embed(false)
+end)
describe('--embed UI', function()
it('can pass stdin', function()
@@ -90,39 +97,45 @@ describe('--embed UI', function()
local writer = assert(uv.new_pipe(false))
writer:open(pipe.write)
- clear {args_rm={'--headless'}, io_extra=pipe.read}
+ clear { args_rm = { '--headless' }, io_extra = pipe.read }
-- attach immediately after startup, for early UI
local screen = Screen.new(40, 8)
- screen.rpc_async = true -- Avoid hanging. #24888
- screen:attach {stdin_fd=3}
+ screen.rpc_async = true -- Avoid hanging. #24888
+ screen:attach { stdin_fd = 3 }
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue1};
- [2] = {bold = true};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { bold = true },
}
- writer:write "hello nvim\nfrom external input\n"
- writer:shutdown(function() writer:close() end)
+ writer:write 'hello nvim\nfrom external input\n'
+ writer:shutdown(function()
+ writer:close()
+ end)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^hello nvim |
from external input |
{1:~ }|*5
|
- ]]}
+ ]],
+ }
-- stdin (rpc input) still works
feed 'o'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
hello nvim |
^ |
from external input |
{1:~ }|*4
{2:-- INSERT --} |
- ]]}
+ ]],
+ }
end)
- it("only sets background colors once even if overridden", function()
+ it('only sets background colors once even if overridden', function()
local screen, current, seen
local function handle_default_colors_set(_, _, rgb_bg, _, _, _)
seen[rgb_bg] = true
@@ -131,7 +144,7 @@ describe('--embed UI', function()
local function startup(...)
seen = {}
current = nil
- clear {args_rm={'--headless'}, args={...}}
+ clear { args_rm = { '--headless' }, args = { ... } }
-- attach immediately after startup, for early UI
screen = Screen.new(40, 8)
@@ -140,19 +153,23 @@ describe('--embed UI', function()
end
startup()
- screen:expect{condition=function()
- eq(16777215, current)
- end}
- eq({[16777215]=true}, seen)
+ screen:expect {
+ condition = function()
+ eq(16777215, current)
+ end,
+ }
+ eq({ [16777215] = true }, seen)
-- NB: by accident how functional/helpers.lua currently handles the default color scheme, the
-- above is sufficient to test the behavior. But in case that workaround is removed, we need
-- a test with an explicit override like below, so do it to remain safe.
startup('--cmd', 'hi NORMAL guibg=#FF00FF')
- screen:expect{condition=function()
- eq(16711935, current)
- end}
- eq({[16711935]=true}, seen) -- we only saw the last one, despite 16777215 was set internally earlier
+ screen:expect {
+ condition = function()
+ eq(16711935, current)
+ end,
+ }
+ eq({ [16711935] = true }, seen) -- we only saw the last one, despite 16777215 was set internally earlier
end)
end)
@@ -161,8 +178,18 @@ describe('--embed --listen UI', function()
helpers.skip(helpers.is_os('win'))
clear()
local child_server = assert(helpers.new_pipename())
- funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean', '--cmd', 'colorscheme vim'})
- retry(nil, nil, function() neq(nil, uv.fs_stat(child_server)) end)
+ funcs.jobstart({
+ nvim_prog,
+ '--embed',
+ '--listen',
+ child_server,
+ '--clean',
+ '--cmd',
+ 'colorscheme vim',
+ })
+ retry(nil, nil, function()
+ neq(nil, uv.fs_stat(child_server))
+ end)
local child_session = helpers.connect(child_server)
@@ -171,11 +198,15 @@ describe('--embed --listen UI', function()
eq(2, #api_info)
ok(api_info[1] > 2, 'channel_id > 2', api_info[1])
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
let g:evs = []
autocmd UIEnter * call add(g:evs, $"UIEnter:{v:event.chan}")
autocmd VimEnter * call add(g:evs, "VimEnter")
- ]], {})
+ ]],
+ {}
+ )
-- VimEnter and UIEnter shouldn't be triggered until after attach
local var_ok, var = child_session:request('nvim_get_var', 'evs')
@@ -184,19 +215,22 @@ describe('--embed --listen UI', function()
local child_screen = Screen.new(40, 6)
child_screen:attach(nil, child_session)
- child_screen:expect{grid=[[
+ child_screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{2:[No Name] 0,0-1 All}|
|
- ]], attr_ids={
- [1] = {foreground = Screen.colors.Blue, bold = true};
- [2] = {reverse = true, bold = true};
- }}
+ ]],
+ attr_ids = {
+ [1] = { foreground = Screen.colors.Blue, bold = true },
+ [2] = { reverse = true, bold = true },
+ },
+ }
-- VimEnter and UIEnter should now be triggered
var_ok, var = child_session:request('nvim_get_var', 'evs')
ok(var_ok)
- eq({'VimEnter', ('UIEnter:%d'):format(api_info[1])}, var)
+ eq({ 'VimEnter', ('UIEnter:%d'):format(api_info[1]) }, var)
end)
end)
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 55197c75a8..6951d2eb9a 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -9,7 +9,6 @@ local meths = helpers.meths
local exec = helpers.exec
local assert_alive = helpers.assert_alive
-
local content1 = [[
This is a
valid English
@@ -18,7 +17,7 @@ local content1 = [[
in his cave.
]]
-describe("folded lines", function()
+describe('folded lines', function()
before_each(function()
clear()
command('hi VertSplit gui=reverse')
@@ -28,35 +27,39 @@ describe("folded lines", function()
local screen
before_each(function()
screen = Screen.new(45, 8)
- screen:attach({rgb=true, ext_multigrid=multigrid})
+ screen:attach({ rgb = true, ext_multigrid = multigrid })
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {reverse = true},
- [3] = {bold = true, reverse = true},
- [4] = {foreground = Screen.colors.White, background = Screen.colors.Red},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {background = Screen.colors.Yellow},
- [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [8] = {foreground = Screen.colors.Brown },
- [9] = {bold = true, foreground = Screen.colors.Brown},
- [10] = {background = Screen.colors.LightGrey, underline = true},
- [11] = {bold = true},
- [12] = {foreground = Screen.colors.Red},
- [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey},
- [14] = {background = Screen.colors.Red},
- [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red},
- [16] = {background = Screen.colors.LightGrey},
- [17] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red},
- [18] = {background = Screen.colors.LightGrey, bold = true, foreground = Screen.colors.Blue},
- [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.DarkBlue},
- [20] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { reverse = true },
+ [3] = { bold = true, reverse = true },
+ [4] = { foreground = Screen.colors.White, background = Screen.colors.Red },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
+ [6] = { background = Screen.colors.Yellow },
+ [7] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [8] = { foreground = Screen.colors.Brown },
+ [9] = { bold = true, foreground = Screen.colors.Brown },
+ [10] = { background = Screen.colors.LightGrey, underline = true },
+ [11] = { bold = true },
+ [12] = { foreground = Screen.colors.Red },
+ [13] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey },
+ [14] = { background = Screen.colors.Red },
+ [15] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Red },
+ [16] = { background = Screen.colors.LightGrey },
+ [17] = { background = Screen.colors.Yellow, foreground = Screen.colors.Red },
+ [18] = {
+ background = Screen.colors.LightGrey,
+ bold = true,
+ foreground = Screen.colors.Blue,
+ },
+ [19] = { background = Screen.colors.Yellow, foreground = Screen.colors.DarkBlue },
+ [20] = { background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue },
})
end)
- it("work with more than one signcolumn", function()
- command("set signcolumn=yes:9")
- feed("i<cr><esc>")
- feed("vkzf")
+ it('work with more than one signcolumn', function()
+ command('set signcolumn=yes:9')
+ feed('i<cr><esc>')
+ feed('vkzf')
if multigrid then
screen:expect([[
## grid 1
@@ -78,10 +81,10 @@ describe("folded lines", function()
end)
local function test_folded_cursorline()
- command("set number cursorline foldcolumn=2")
- command("hi link CursorLineFold Search")
+ command('set number cursorline foldcolumn=2')
+ command('hi link CursorLineFold Search')
insert(content1)
- feed("ggzf3jj")
+ feed('ggzf3jj')
if multigrid then
screen:expect([[
## grid 1
@@ -104,7 +107,7 @@ describe("folded lines", function()
|
]])
end
- feed("k")
+ feed('k')
if multigrid then
screen:expect([[
## grid 1
@@ -128,12 +131,12 @@ describe("folded lines", function()
]])
end
-- CursorLine is applied correctly with screenrow motions #22232
- feed("jgk")
+ feed('jgk')
screen:expect_unchanged()
-- CursorLine is applied correctly when closing a fold when cursor is not at fold start
- feed("zo4Gzc")
+ feed('zo4Gzc')
screen:expect_unchanged()
- command("set cursorlineopt=line")
+ command('set cursorlineopt=line')
if multigrid then
screen:expect([[
## grid 1
@@ -156,7 +159,7 @@ describe("folded lines", function()
|
]])
end
- command("set relativenumber cursorlineopt=number")
+ command('set relativenumber cursorlineopt=number')
if multigrid then
screen:expect([[
## grid 1
@@ -183,55 +186,63 @@ describe("folded lines", function()
describe("when 'cursorline' is set", function()
it('with high-priority CursorLine', function()
- command("hi! CursorLine guibg=NONE guifg=Red gui=NONE")
+ command('hi! CursorLine guibg=NONE guifg=Red gui=NONE')
test_folded_cursorline()
end)
it('with low-priority CursorLine', function()
- command("hi! CursorLine guibg=NONE guifg=NONE gui=underline")
+ command('hi! CursorLine guibg=NONE guifg=NONE gui=underline')
local attrs = screen:get_default_attr_ids()
- attrs[12] = {underline = true}
- attrs[13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}
+ attrs[12] = { underline = true }
+ attrs[13] = {
+ foreground = Screen.colors.DarkBlue,
+ background = Screen.colors.LightGrey,
+ underline = true,
+ }
screen:set_default_attr_ids(attrs)
test_folded_cursorline()
end)
end)
- it("work with spell", function()
- command("set spell")
+ it('work with spell', function()
+ command('set spell')
insert(content1)
- feed("gg")
- feed("zf3j")
+ feed('gg')
+ feed('zf3j')
if not multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5:^+-- 4 lines: This is a······················}|
in his cave. |
|
{1:~ }|*4
|
- ]]}
+ ]],
+ }
end
end)
- it("work with matches", function()
+ it('work with matches', function()
insert(content1)
- command("highlight MyWord gui=bold guibg=red guifg=white")
+ command('highlight MyWord gui=bold guibg=red guifg=white')
command("call matchadd('MyWord', '\\V' . 'test', -1)")
- feed("gg")
- feed("zf3j")
+ feed('gg')
+ feed('zf3j')
if not multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5:^+-- 4 lines: This is a······················}|
in his cave. |
|
{1:~ }|*4
|
- ]]}
+ ]],
+ }
end
end)
- it("works with multibyte fillchars", function()
+ it('works with multibyte fillchars', function()
insert([[
aa
bb
@@ -239,9 +250,9 @@ describe("folded lines", function()
dd
ee
ff]])
- command("set fillchars+=foldopen:▾,foldsep:│,foldclose:▸")
+ command('set fillchars+=foldopen:▾,foldsep:│,foldclose:▸')
feed_command('1')
- command("set foldcolumn=2")
+ command('set foldcolumn=2')
feed('zf4j')
feed('zf2j')
feed('zO')
@@ -274,7 +285,7 @@ describe("folded lines", function()
]])
end
- feed_command("set rightleft")
+ feed_command('set rightleft')
if multigrid then
screen:expect([[
## grid 1
@@ -304,7 +315,7 @@ describe("folded lines", function()
]])
end
- feed_command("set norightleft")
+ feed_command('set norightleft')
if multigrid then
meths.input_mouse('left', 'press', '', 2, 0, 1)
screen:expect([[
@@ -408,7 +419,7 @@ describe("folded lines", function()
end
end)
- it("works with split", function()
+ it('works with split', function()
insert([[
aa
bb
@@ -417,12 +428,12 @@ describe("folded lines", function()
ee
ff]])
feed_command('2')
- command("set foldcolumn=1")
+ command('set foldcolumn=1')
feed('zf3j')
feed_command('1')
feed('zf2j')
feed('zO')
- feed_command("rightbelow new")
+ feed_command('rightbelow new')
insert([[
aa
bb
@@ -431,7 +442,7 @@ describe("folded lines", function()
ee
ff]])
feed_command('2')
- command("set foldcolumn=1")
+ command('set foldcolumn=1')
feed('zf3j')
feed_command('1')
feed('zf2j')
@@ -568,7 +579,7 @@ describe("folded lines", function()
end
end)
- it("works with vsplit", function()
+ it('works with vsplit', function()
insert([[
aa
bb
@@ -577,12 +588,12 @@ describe("folded lines", function()
ee
ff]])
feed_command('2')
- command("set foldcolumn=1")
+ command('set foldcolumn=1')
feed('zf3j')
feed_command('1')
feed('zf2j')
feed('zO')
- feed_command("rightbelow vnew")
+ feed_command('rightbelow vnew')
insert([[
aa
bb
@@ -591,7 +602,7 @@ describe("folded lines", function()
ee
ff]])
feed_command('2')
- command("set foldcolumn=1")
+ command('set foldcolumn=1')
feed('zf3j')
feed_command('1')
feed('zf2j')
@@ -740,7 +751,7 @@ describe("folded lines", function()
end
end)
- it("works with tab", function()
+ it('works with tab', function()
insert([[
aa
bb
@@ -749,12 +760,12 @@ describe("folded lines", function()
ee
ff]])
feed_command('2')
- command("set foldcolumn=2")
+ command('set foldcolumn=2')
feed('zf3j')
feed_command('1')
feed('zf2j')
feed('zO')
- feed_command("tab split")
+ feed_command('tab split')
if multigrid then
meths.input_mouse('left', 'press', '', 4, 1, 1)
screen:expect([[
@@ -821,7 +832,7 @@ describe("folded lines", function()
]])
end
- feed_command("tabnext")
+ feed_command('tabnext')
if multigrid then
meths.input_mouse('left', 'press', '', 2, 1, 1)
screen:expect([[
@@ -879,7 +890,7 @@ describe("folded lines", function()
end
end)
- it("works with multibyte text", function()
+ it('works with multibyte text', function()
eq(true, meths.get_option_value('arabicshape', {}))
insert([[
å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة
@@ -925,7 +936,7 @@ describe("folded lines", function()
]])
end
- feed_command("set noarabicshape")
+ feed_command('set noarabicshape')
if multigrid then
screen:expect([[
## grid 1
@@ -945,7 +956,7 @@ describe("folded lines", function()
]])
end
- feed_command("set number foldcolumn=2")
+ feed_command('set number foldcolumn=2')
if multigrid then
screen:expect([[
## grid 1
@@ -966,7 +977,7 @@ describe("folded lines", function()
end
-- Note: too much of the folded line gets cut off.This is a vim bug.
- feed_command("set rightleft")
+ feed_command('set rightleft')
if multigrid then
screen:expect([[
## grid 1
@@ -986,7 +997,7 @@ describe("folded lines", function()
]])
end
- feed_command("set nonumber foldcolumn=0")
+ feed_command('set nonumber foldcolumn=0')
if multigrid then
screen:expect([[
## grid 1
@@ -1006,7 +1017,7 @@ describe("folded lines", function()
]])
end
- feed_command("set arabicshape")
+ feed_command('set arabicshape')
if multigrid then
screen:expect([[
## grid 1
@@ -1069,16 +1080,15 @@ describe("folded lines", function()
:set noarabicshape |
]])
end
-
end)
- it("work in cmdline window", function()
- feed_command("set foldmethod=manual")
- feed_command("let x = 1")
- feed_command("/alpha")
- feed_command("/omega")
+ it('work in cmdline window', function()
+ feed_command('set foldmethod=manual')
+ feed_command('let x = 1')
+ feed_command('/alpha')
+ feed_command('/omega')
- feed("<cr>q:")
+ feed('<cr>q:')
if multigrid then
screen:expect([[
## grid 1
@@ -1110,7 +1120,7 @@ describe("folded lines", function()
]])
end
- feed("kzfk")
+ feed('kzfk')
if multigrid then
screen:expect([[
## grid 1
@@ -1140,7 +1150,7 @@ describe("folded lines", function()
]])
end
- feed("<cr>")
+ feed('<cr>')
if multigrid then
screen:expect([[
## grid 1
@@ -1160,7 +1170,7 @@ describe("folded lines", function()
]])
end
- feed("/<c-f>")
+ feed('/<c-f>')
if multigrid then
screen:expect([[
## grid 1
@@ -1192,7 +1202,7 @@ describe("folded lines", function()
]])
end
- feed("ggzfG")
+ feed('ggzfG')
if multigrid then
screen:expect([[
## grid 1
@@ -1219,18 +1229,16 @@ describe("folded lines", function()
/ |
]])
end
-
end)
- it("work with autoresize", function()
-
+ it('work with autoresize', function()
funcs.setline(1, 'line 1')
funcs.setline(2, 'line 2')
funcs.setline(3, 'line 3')
funcs.setline(4, 'line 4')
- feed("zfj")
- command("set foldcolumn=0")
+ feed('zfj')
+ command('set foldcolumn=0')
if multigrid then
screen:expect([[
## grid 1
@@ -1254,7 +1262,7 @@ describe("folded lines", function()
]])
end
-- should adapt to the current nesting of folds (e.g., 1)
- command("set foldcolumn=auto:1")
+ command('set foldcolumn=auto:1')
if multigrid then
screen:expect([[
## grid 1
@@ -1277,9 +1285,10 @@ describe("folded lines", function()
|
]])
end
- command("set foldcolumn=auto")
+ command('set foldcolumn=auto')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1290,18 +1299,23 @@ describe("folded lines", function()
{1:~ }|*4
## grid 3
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:+}{5:^+-- 2 lines: line 1························}|
{7: }line 3 |
{7: }line 4 |
{1:~ }|*4
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end
-- fdc should not change with a new fold as the maximum is 1
- feed("zf3j")
+ feed('zf3j')
if multigrid then
screen:expect([[
@@ -1322,8 +1336,10 @@ describe("folded lines", function()
]])
end
- command("set foldcolumn=auto:1")
- if multigrid then screen:expect{grid=[[
+ command('set foldcolumn=auto:1')
+ if multigrid then
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1332,18 +1348,23 @@ describe("folded lines", function()
{1:~ }|*6
## grid 3
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:+}{5:^+-- 4 lines: line 1························}|
{1:~ }|*6
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end
-- relax the maximum fdc thus fdc should expand to
-- accommodate the current number of folds
- command("set foldcolumn=auto:4")
+ command('set foldcolumn=auto:4')
if multigrid then
screen:expect([[
## grid 1
@@ -1371,8 +1392,8 @@ describe("folded lines", function()
endfunction
]])
command('set foldtext=MyFoldText()')
- feed("i<cr><esc>")
- feed("vkzf")
+ feed('i<cr><esc>')
+ feed('vkzf')
if multigrid then
screen:expect([[
## grid 1
@@ -1509,14 +1530,27 @@ describe("folded lines", function()
funcs.setline(2, 'line 2')
funcs.setline(3, 'line 3')
funcs.setline(4, 'line 4')
- feed("zfj")
+ feed('zfj')
local ns = meths.create_namespace('ns')
- meths.buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} })
- meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} })
- meths.buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} })
- meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} })
- if multigrid then
- screen:expect{grid=[[
+ meths.buf_set_extmark(
+ 0,
+ ns,
+ 0,
+ 0,
+ { virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } }
+ )
+ meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = { { { 'virt_line below line 2', '' } } } })
+ meths.buf_set_extmark(
+ 0,
+ ns,
+ 2,
+ 0,
+ { virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } }
+ )
+ meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = { { { 'virt_line below line 4', '' } } } })
+ if multigrid then
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1529,9 +1563,19 @@ describe("folded lines", function()
{1:~ }|*2
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 0, curcol = 0, linecount = 4, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 5,
+ curline = 0,
+ curcol = 0,
+ linecount = 4,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
screen:expect([[
{5:^+-- 2 lines: line 1·························}|
@@ -1546,7 +1590,8 @@ describe("folded lines", function()
feed('jzfj')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1556,9 +1601,19 @@ describe("folded lines", function()
{1:~ }|*5
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 2, curcol = 0, linecount = 4, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 5,
+ curline = 2,
+ curcol = 0,
+ linecount = 4,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
screen:expect([[
{5:+-- 2 lines: line 1·························}|
@@ -1571,7 +1626,8 @@ describe("folded lines", function()
feed('kzo<C-Y>')
funcs.setline(5, 'line 5')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1585,9 +1641,19 @@ describe("folded lines", function()
{1:~ }|
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 6,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = -1,
+ },
+ },
+ }
else
screen:expect([[
virt_line above line 1 |
@@ -1613,10 +1679,17 @@ describe("folded lines", function()
coladd = 0,
}, funcs.getmousepos())
- meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} })
+ meths.buf_set_extmark(
+ 0,
+ ns,
+ 1,
+ 0,
+ { virt_lines = { { { 'more virt_line below line 2', '' } } } }
+ )
feed('G<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1630,9 +1703,19 @@ describe("folded lines", function()
{1:~ }|
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
screen:expect([[
line 1 |
@@ -1648,7 +1731,8 @@ describe("folded lines", function()
feed('<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1661,9 +1745,19 @@ describe("folded lines", function()
{1:~ }|*2
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 1, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 1};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 1,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 1,
+ },
+ },
+ }
else
screen:expect([[
line 2 |
@@ -1678,7 +1772,8 @@ describe("folded lines", function()
feed('<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1690,9 +1785,19 @@ describe("folded lines", function()
{1:~ }|*3
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 2,
+ },
+ },
+ }
else
screen:expect([[
virt_line below line 2 |
@@ -1706,7 +1811,8 @@ describe("folded lines", function()
feed('<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1717,9 +1823,19 @@ describe("folded lines", function()
{1:~ }|*4
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 3,
+ },
+ },
+ }
else
screen:expect([[
more virt_line below line 2 |
@@ -1732,7 +1848,8 @@ describe("folded lines", function()
feed('<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1742,9 +1859,19 @@ describe("folded lines", function()
{1:~ }|*5
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 4};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 4,
+ },
+ },
+ }
else
screen:expect([[
{5:+-- 2 lines: line 3·························}|
@@ -1756,7 +1883,8 @@ describe("folded lines", function()
feed('<C-E>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1765,9 +1893,19 @@ describe("folded lines", function()
{1:~ }|*6
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 4, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 5};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 4,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 5,
+ },
+ },
+ }
else
screen:expect([[
^line 5 |
@@ -1778,7 +1916,8 @@ describe("folded lines", function()
feed('3<C-Y>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1790,9 +1929,19 @@ describe("folded lines", function()
{1:~ }|*3
## grid 3
|
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 2,
+ },
+ },
+ }
else
screen:expect([[
virt_line below line 2 |
@@ -1806,7 +1955,8 @@ describe("folded lines", function()
meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0)
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1818,9 +1968,19 @@ describe("folded lines", function()
{1:~ }|*3
## grid 3
{11:-- VISUAL LINE --} |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 2,
+ },
+ },
+ }
else
screen:expect([[
virt_line below line 2 |
@@ -1834,7 +1994,8 @@ describe("folded lines", function()
meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0)
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1845,9 +2006,19 @@ describe("folded lines", function()
{1:~ }|*4
## grid 3
{11:-- VISUAL LINE --} |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 3,
+ },
+ },
+ }
else
screen:expect([[
more virt_line below line 2 |
@@ -1860,7 +2031,8 @@ describe("folded lines", function()
meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5)
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*7
[3:---------------------------------------------]|
@@ -1870,9 +2042,19 @@ describe("folded lines", function()
{1:~ }|*5
## grid 3
{11:-- VISUAL LINE --} |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 5, linecount = 5, sum_scroll_delta = 4};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 2,
+ botline = 6,
+ curline = 4,
+ curcol = 5,
+ linecount = 5,
+ sum_scroll_delta = 4,
+ },
+ },
+ }
else
screen:expect([[
{5:+-- 2 lines: line 3·························}|
@@ -1885,7 +2067,8 @@ describe("folded lines", function()
feed('<Esc>gg')
command('botright 1split | wincmd w')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*4
{3:[No Name] [+] }|
@@ -1901,10 +2084,28 @@ describe("folded lines", function()
|
## grid 4
line 1 |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0};
- [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 3,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 0,
+ },
+ [4] = {
+ win = { id = 1001 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
screen:expect([[
^line 1 |
@@ -1920,7 +2121,8 @@ describe("folded lines", function()
feed('<C-Y>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:---------------------------------------------]|*4
{3:[No Name] [+] }|
@@ -1936,10 +2138,28 @@ describe("folded lines", function()
|
## grid 4
line 1 |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1};
- [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 3,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = -1,
+ },
+ [4] = {
+ win = { id = 1001 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 5,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
screen:expect([[
virt_line above line 1 |
@@ -2196,16 +2416,20 @@ describe("folded lines", function()
it('support foldtext with virtual text format', function()
screen:try_resize(30, 7)
insert(content1)
- command("hi! CursorLine guibg=NONE guifg=Red gui=NONE")
+ command('hi! CursorLine guibg=NONE guifg=Red gui=NONE')
command('hi F0 guibg=Red guifg=Black')
command('hi F1 guifg=White')
meths.set_option_value('cursorline', true, {})
meths.set_option_value('foldcolumn', '4', {})
- meths.set_option_value('foldtext', '['
- .. '["▶", ["F0", "F1"]], '
- .. '[v:folddashes], '
- .. '["\t", "Search"], '
- .. '[getline(v:foldstart), "NonText"]]', {})
+ meths.set_option_value(
+ 'foldtext',
+ '['
+ .. '["▶", ["F0", "F1"]], '
+ .. '[v:folddashes], '
+ .. '["\t", "Search"], '
+ .. '[getline(v:foldstart), "NonText"]]',
+ {}
+ )
command('3,4fold')
command('5,6fold')
@@ -2315,7 +2539,7 @@ describe("folded lines", function()
end)
end
- describe("with ext_multigrid", function()
+ describe('with ext_multigrid', function()
with_ext_multigrid(true)
end)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index d9ed66eb01..54c14fb44a 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -30,13 +30,13 @@ describe('highlight: `:syntax manual`', function()
before_each(function()
clear()
- screen = Screen.new(20,5)
+ screen = Screen.new(20, 5)
screen:attach()
--syntax highlight for vimcscripts "echo"
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {bold=true, foreground=Screen.colors.Brown}
- } )
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { bold = true, foreground = Screen.colors.Brown },
+ })
end)
after_each(function()
@@ -75,9 +75,9 @@ describe('highlight: `:syntax manual`', function()
command('set nohidden')
command('w')
command('silent bn')
- eq("tmp1.vim", eval("fnamemodify(bufname('%'), ':t')"))
+ eq('tmp1.vim', eval("fnamemodify(bufname('%'), ':t')"))
feed_command('silent bp')
- eq("Xtest-functional-ui-highlight.tmp.vim", eval("fnamemodify(bufname('%'), ':t')"))
+ eq('Xtest-functional-ui-highlight.tmp.vim', eval("fnamemodify(bufname('%'), ':t')"))
screen:expect([[
{1:^echo} 1 |
{0:~ }|*3
@@ -86,7 +86,6 @@ describe('highlight: `:syntax manual`', function()
end)
end)
-
describe('highlight defaults', function()
local screen
@@ -94,16 +93,16 @@ describe('highlight defaults', function()
clear()
screen = Screen.new()
screen:set_default_attr_ids {
- [0] = {bold=true, foreground=Screen.colors.Blue};
- [1] = {reverse = true, bold = true};
- [2] = {reverse = true};
- [3] = {bold = true};
- [4] = {bold = true, foreground = Screen.colors.SeaGreen};
- [5] = {foreground = Screen.colors.Red1, background = Screen.colors.WebGreen};
- [6] = {background = Screen.colors.Red1, foreground = Screen.colors.Grey100};
- [7] = {foreground = Screen.colors.Red};
- [8] = {foreground = Screen.colors.Blue};
- [9] = {italic = true};
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { reverse = true, bold = true },
+ [2] = { reverse = true },
+ [3] = { bold = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [5] = { foreground = Screen.colors.Red1, background = Screen.colors.WebGreen },
+ [6] = { background = Screen.colors.Red1, foreground = Screen.colors.Grey100 },
+ [7] = { foreground = Screen.colors.Red },
+ [8] = { foreground = Screen.colors.Blue },
+ [9] = { italic = true },
}
screen:attach()
end)
@@ -226,8 +225,10 @@ describe('highlight defaults', function()
{0:~ }|*2
|
]])
- feed_command("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE"
- .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE")
+ feed_command(
+ 'hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE'
+ .. ' gui=NONE guifg=NONE guibg=NONE guisp=NONE'
+ )
screen:expect([[
neovi^m |
{0:~ }|*2
@@ -242,13 +243,16 @@ describe('highlight defaults', function()
{0:~ }|*2
|
]])
- feed_command("hi NonTextAlt guifg=Red")
- feed_command("hi! link NonText NonTextAlt")
- screen:expect([[
+ feed_command('hi NonTextAlt guifg=Red')
+ feed_command('hi! link NonText NonTextAlt')
+ screen:expect(
+ [[
^ |
{0:~ }|*2
:hi! link NonText NonTextAlt |
- ]], {[0] = {foreground=Screen.colors.Red}})
+ ]],
+ { [0] = { foreground = Screen.colors.Red } }
+ )
end)
it('Cursor after `:hi clear|syntax reset` #6508', function()
@@ -276,25 +280,34 @@ describe('highlight defaults', function()
it('are sent to UIs', function()
screen:try_resize(53, 4)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}}
+ ]],
+ hl_groups = { EndOfBuffer = 0, MsgSeparator = 1 },
+ }
command('highlight EndOfBuffer gui=italic')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{9:~ }|*2
|
- ]], hl_groups={EndOfBuffer=9, MsgSeparator=1}}
+ ]],
+ hl_groups = { EndOfBuffer = 9, MsgSeparator = 1 },
+ }
command('highlight clear EndOfBuffer')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}}
+ ]],
+ hl_groups = { EndOfBuffer = 0, MsgSeparator = 1 },
+ }
end)
end)
@@ -302,12 +315,12 @@ describe('highlight', function()
before_each(clear)
it('visual', function()
- local screen = Screen.new(20,4)
+ local screen = Screen.new(20, 4)
screen:attach()
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.LightGrey},
- [2] = {bold = true, foreground = Screen.colors.Blue1},
- [3] = {bold = true},
+ [1] = { background = Screen.colors.LightGrey },
+ [2] = { bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { bold = true },
})
insert([[
line1 foo bar
@@ -334,14 +347,18 @@ describe('highlight', function()
end)
it('cterm=standout gui=standout', function()
- local screen = Screen.new(20,5)
+ local screen = Screen.new(20, 5)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {standout = true, bold = true, underline = true,
- background = Screen.colors.Gray90, foreground = Screen.colors.Blue1},
- [3] = {standout = true, underline = true,
- background = Screen.colors.Gray90}
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = {
+ standout = true,
+ bold = true,
+ underline = true,
+ background = Screen.colors.Gray90,
+ foreground = Screen.colors.Blue1,
+ },
+ [3] = { standout = true, underline = true, background = Screen.colors.Gray90 },
})
feed_command('hi CursorLine cterm=standout,underline gui=standout,underline')
feed_command('set cursorline')
@@ -357,7 +374,7 @@ describe('highlight', function()
end)
it('strikethrough', function()
- local screen = Screen.new(25,6)
+ local screen = Screen.new(25, 6)
screen:attach()
feed_command('syntax on')
feed_command('syn keyword TmpKeyword foo')
@@ -368,27 +385,34 @@ describe('highlight', function()
foo bar
foobarfoobar
]])
- screen:expect([[
+ screen:expect(
+ [[
{1:foo} |
{1:foo} bar |
foobarfoobar |
^ |
{2:~ }|
|
- ]], {
- [1] = {strikethrough = true},
- [2] = {bold = true, foreground = Screen.colors.Blue1},
- })
+ ]],
+ {
+ [1] = { strikethrough = true },
+ [2] = { bold = true, foreground = Screen.colors.Blue1 },
+ }
+ )
end)
it('nocombine', function()
- local screen = Screen.new(25,6)
- screen:set_default_attr_ids{
- [1] = {foreground = Screen.colors.SlateBlue, underline = true},
- [2] = {bold = true, foreground = Screen.colors.Blue1},
- [3] = {underline = true, reverse = true, foreground = Screen.colors.SlateBlue},
- [4] = {background = Screen.colors.Yellow, reverse = true, foreground = Screen.colors.SlateBlue},
- [5] = {foreground = Screen.colors.Red},
+ local screen = Screen.new(25, 6)
+ screen:set_default_attr_ids {
+ [1] = { foreground = Screen.colors.SlateBlue, underline = true },
+ [2] = { bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { underline = true, reverse = true, foreground = Screen.colors.SlateBlue },
+ [4] = {
+ background = Screen.colors.Yellow,
+ reverse = true,
+ foreground = Screen.colors.SlateBlue,
+ },
+ [5] = { foreground = Screen.colors.Red },
}
screen:attach()
feed_command('syntax on')
@@ -399,33 +423,39 @@ describe('highlight', function()
foobar
foobar
]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:foobar} |*2
^ |
{2:~ }|*2
|
- ]]}
+ ]],
+ }
feed('/foo')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:foo}{1:bar} |
{4:foo}{1:bar} |
|
{2:~ }|*2
/foo^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{4:^foo}{1:bar} |
{4:foo}{1:bar} |
|
{2:~ }|*2
{5:search hit...uing at TOP} |
- ]]}
+ ]],
+ }
end)
it('guisp (special/undercurl)', function()
- local screen = Screen.new(25,10)
+ local screen = Screen.new(25, 10)
screen:attach()
feed_command('syntax on')
feed_command('syn keyword TmpKeyword neovim')
@@ -449,7 +479,8 @@ describe('highlight', function()
specialwithfg
]])
feed('Go<tab>neovim tabbed')
- screen:expect([[
+ screen:expect(
+ [[
{1:neovim} |
awesome {1:neovim} |
wordcontainingneovim |
@@ -460,20 +491,24 @@ describe('highlight', function()
{1:neovim} tabbed^ |
{0:~ }|
{5:-- INSERT --} |
- ]], {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red,
- special = Screen.colors.Red},
- [2] = {special = Screen.colors.Red},
- [3] = {special = Screen.colors.Red, background = Screen.colors.Yellow},
- [4] = {foreground = Screen.colors.Red, special = Screen.colors.Red},
- [5] = {bold=true},
- })
-
+ ]],
+ {
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = {
+ background = Screen.colors.Yellow,
+ foreground = Screen.colors.Red,
+ special = Screen.colors.Red,
+ },
+ [2] = { special = Screen.colors.Red },
+ [3] = { special = Screen.colors.Red, background = Screen.colors.Yellow },
+ [4] = { foreground = Screen.colors.Red, special = Screen.colors.Red },
+ [5] = { bold = true },
+ }
+ )
end)
it("'diff', syntax and extmark #23722", function()
- local screen = Screen.new(25,10)
+ local screen = Screen.new(25, 10)
screen:attach()
exec([[
new
@@ -483,7 +518,8 @@ describe('highlight', function()
syn match WarningMsg "^.*$"
call nvim_buf_add_highlight(0, -1, 'ErrorMsg', 1, 2, 8)
]])
- screen:expect([[
+ screen:expect(
+ [[
{1: }^ |
{1: }{2:01}{3:234 67}{2:89}{5: }|
{4:~ }|*2
@@ -493,17 +529,23 @@ describe('highlight', function()
{4:~ }|
{8:[No Name] }|
|
- ]], {
- [0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue},
- [1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4},
- [2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.LightBlue},
- [4] = {bold = true, foreground = Screen.colors.Blue},
- [5] = {background = Screen.colors.LightBlue},
- [6] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1},
- [7] = {reverse = true, bold = true},
- [8] = {reverse = true},
- })
+ ]],
+ {
+ [0] = { Screen.colors.WebGray, foreground = Screen.colors.DarkBlue },
+ [1] = { background = Screen.colors.Grey, foreground = Screen.colors.Blue4 },
+ [2] = { foreground = Screen.colors.Red, background = Screen.colors.LightBlue },
+ [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.LightBlue },
+ [4] = { bold = true, foreground = Screen.colors.Blue },
+ [5] = { background = Screen.colors.LightBlue },
+ [6] = {
+ bold = true,
+ background = Screen.colors.LightCyan,
+ foreground = Screen.colors.Blue1,
+ },
+ [7] = { reverse = true, bold = true },
+ [8] = { reverse = true },
+ }
+ )
end)
end)
@@ -512,14 +554,14 @@ describe("'listchars' highlight", function()
before_each(function()
clear()
- screen = Screen.new(20,5)
+ screen = Screen.new(20, 5)
screen:attach()
end)
it("'cursorline' and 'cursorcolumn'", function()
screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {background=Screen.colors.Grey90}
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.Grey90 },
})
feed_command('highlight clear ModeMsg')
feed_command('set cursorline')
@@ -586,22 +628,22 @@ describe("'listchars' highlight", function()
it("'cursorline' and with 'listchars' option", function()
screen:set_default_attr_ids({
- [1] = {background=Screen.colors.Grey90},
+ [1] = { background = Screen.colors.Grey90 },
[2] = {
- foreground=Screen.colors.Red,
- background=Screen.colors.Grey90,
+ foreground = Screen.colors.Red,
+ background = Screen.colors.Grey90,
},
[3] = {
- background=Screen.colors.Grey90,
- foreground=Screen.colors.Blue,
- bold=true,
+ background = Screen.colors.Grey90,
+ foreground = Screen.colors.Blue,
+ bold = true,
},
[4] = {
- foreground=Screen.colors.Blue,
- bold=true,
+ foreground = Screen.colors.Blue,
+ bold = true,
},
[5] = {
- foreground=Screen.colors.Red,
+ foreground = Screen.colors.Red,
},
})
feed_command('highlight clear ModeMsg')
@@ -669,7 +711,7 @@ describe("'listchars' highlight", function()
it("'listchar' with wrap", function()
screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
})
feed_command('set wrap')
feed_command('set listchars=eol:¬,precedes:< list')
@@ -690,34 +732,34 @@ describe("'listchars' highlight", function()
it("'listchar' in visual mode", function()
screen:set_default_attr_ids({
- [1] = {background=Screen.colors.Grey90},
+ [1] = { background = Screen.colors.Grey90 },
[2] = {
- foreground=Screen.colors.Red,
- background=Screen.colors.Grey90,
+ foreground = Screen.colors.Red,
+ background = Screen.colors.Grey90,
},
[3] = {
- background=Screen.colors.Grey90,
- foreground=Screen.colors.Blue,
- bold=true,
+ background = Screen.colors.Grey90,
+ foreground = Screen.colors.Blue,
+ bold = true,
},
[4] = {
- foreground=Screen.colors.Blue,
- bold=true,
+ foreground = Screen.colors.Blue,
+ bold = true,
},
[5] = {
- foreground=Screen.colors.Red,
+ foreground = Screen.colors.Red,
},
[6] = {
- background=Screen.colors.LightGrey,
+ background = Screen.colors.LightGrey,
},
[7] = {
- background=Screen.colors.LightGrey,
- foreground=Screen.colors.Red,
+ background = Screen.colors.LightGrey,
+ foreground = Screen.colors.Red,
},
[8] = {
- background=Screen.colors.LightGrey,
- foreground=Screen.colors.Blue,
- bold=true,
+ background = Screen.colors.LightGrey,
+ foreground = Screen.colors.Blue,
+ bold = true,
},
})
feed_command('highlight clear ModeMsg')
@@ -762,10 +804,10 @@ describe("'listchars' highlight", function()
it("'cursorline' with :match", function()
screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {background=Screen.colors.Grey90},
- [2] = {foreground=Screen.colors.Red},
- [3] = {foreground=Screen.colors.X11Green, background=Screen.colors.Red1},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.Grey90 },
+ [2] = { foreground = Screen.colors.Red },
+ [3] = { foreground = Screen.colors.X11Green, background = Screen.colors.Red1 },
})
feed_command('highlight clear ModeMsg')
feed_command('highlight Whitespace guifg=#FF0000')
@@ -796,15 +838,15 @@ describe('CursorLine and CursorLineNr highlights', function()
before_each(clear)
it('overridden by Error, ColorColumn if fg not set', function()
- local screen = Screen.new(50,5)
+ local screen = Screen.new(50, 5)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.SlateBlue},
- [2] = {bold = true, foreground = Screen.colors.Brown},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
- [5] = {background = Screen.colors.Gray90},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {background = Screen.colors.LightRed},
+ [1] = { foreground = Screen.colors.SlateBlue },
+ [2] = { bold = true, foreground = Screen.colors.Brown },
+ [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 },
+ [5] = { background = Screen.colors.Gray90 },
+ [6] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { background = Screen.colors.LightRed },
})
screen:attach()
@@ -832,12 +874,12 @@ describe('CursorLine and CursorLineNr highlights', function()
end)
it("overridden by NonText in 'showbreak' characters", function()
- local screen = Screen.new(20,5)
+ local screen = Screen.new(20, 5)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Yellow, background = Screen.colors.Blue};
- [2] = {foreground = Screen.colors.Black, background = Screen.colors.White};
- [3] = {foreground = Screen.colors.Yellow, background = Screen.colors.White};
- [4] = {foreground = Screen.colors.Yellow};
+ [1] = { foreground = Screen.colors.Yellow, background = Screen.colors.Blue },
+ [2] = { foreground = Screen.colors.Black, background = Screen.colors.White },
+ [3] = { foreground = Screen.colors.Yellow, background = Screen.colors.White },
+ [4] = { foreground = Screen.colors.Yellow },
})
screen:attach()
@@ -883,13 +925,13 @@ describe('CursorLine and CursorLineNr highlights', function()
end)
it("'cursorlineopt' screenline", function()
- local screen = Screen.new(20,5)
+ local screen = Screen.new(20, 5)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Black, background = Screen.colors.White};
- [2] = {foreground = Screen.colors.Yellow};
- [3] = {foreground = Screen.colors.Red, background = Screen.colors.Green};
- [4] = {foreground = Screen.colors.Green, background = Screen.colors.Red};
- [5] = {bold = true}, -- ModeMsg
+ [1] = { foreground = Screen.colors.Black, background = Screen.colors.White },
+ [2] = { foreground = Screen.colors.Yellow },
+ [3] = { foreground = Screen.colors.Red, background = Screen.colors.Green },
+ [4] = { foreground = Screen.colors.Green, background = Screen.colors.Red },
+ [5] = { bold = true }, -- ModeMsg
})
screen:attach()
@@ -1014,16 +1056,16 @@ describe('CursorLine and CursorLineNr highlights', function()
-- oldtest: Test_cursorline_after_yank()
it('always updated. vim-patch:8.1.0849', function()
- local screen = Screen.new(50,5)
+ local screen = Screen.new(50, 5)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.SlateBlue},
- [2] = {bold = true, foreground = Screen.colors.Brown},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
- [5] = {background = Screen.colors.Gray90},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {background = Screen.colors.LightRed},
- [8] = {foreground = Screen.colors.Brown},
+ [1] = { foreground = Screen.colors.SlateBlue },
+ [2] = { bold = true, foreground = Screen.colors.Brown },
+ [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 },
+ [5] = { background = Screen.colors.Gray90 },
+ [6] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { background = Screen.colors.LightRed },
+ [8] = { foreground = Screen.colors.Brown },
})
screen:attach()
command('set cursorline relativenumber')
@@ -1048,18 +1090,18 @@ describe('CursorLine and CursorLineNr highlights', function()
-- oldtest: Test_cursorline_with_visualmode()
it('with visual area. vim-patch:8.1.1001', function()
- local screen = Screen.new(50,5)
+ local screen = Screen.new(50, 5)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.SlateBlue},
- [2] = {bold = true, foreground = Screen.colors.Brown},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
- [5] = {background = Screen.colors.Gray90},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {background = Screen.colors.LightRed},
- [8] = {foreground = Screen.colors.Brown},
- [9] = {background = Screen.colors.LightGrey},
- [10] = {bold = true},
+ [1] = { foreground = Screen.colors.SlateBlue },
+ [2] = { bold = true, foreground = Screen.colors.Brown },
+ [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 },
+ [5] = { background = Screen.colors.Gray90 },
+ [6] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { background = Screen.colors.LightRed },
+ [8] = { foreground = Screen.colors.Brown },
+ [9] = { background = Screen.colors.LightGrey },
+ [10] = { bold = true },
})
screen:attach()
command('set cursorline')
@@ -1077,8 +1119,8 @@ describe('CursorLine and CursorLineNr highlights', function()
it('is updated if cursor is moved up from timer vim-patch:8.2.4591', function()
local screen = Screen.new(50, 8)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Gray90}, -- CursorLine
- [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
+ [1] = { background = Screen.colors.Gray90 }, -- CursorLine
+ [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText
})
screen:attach()
exec([[
@@ -1092,36 +1134,41 @@ describe('CursorLine and CursorLineNr highlights', function()
call timer_start(300, 'Func')
]])
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
aaaaa |
bbbbb |
ccccc |
{1:^ddddd }|
{2:~ }|*3
|
- ]], timeout = 100})
- screen:expect({grid = [[
+ ]],
+ timeout = 100,
+ })
+ screen:expect({
+ grid = [[
aaaaa |
{1:^bbbbb }|
ccccc |
ddddd |
{2:~ }|*3
|
- ]]})
+ ]],
+ })
end)
it('with split windows in diff mode', function()
- local screen = Screen.new(50,12)
+ local screen = Screen.new(50, 12)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {bold = true, background = Screen.colors.Red},
- [3] = {background = Screen.colors.LightMagenta},
- [4] = {reverse = true},
- [5] = {background = Screen.colors.LightBlue},
- [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [7] = {background = Screen.colors.Red, foreground = Screen.colors.White},
- [8] = {bold = true, foreground = Screen.colors.Blue1},
- [9] = {bold = true, reverse = true},
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [2] = { bold = true, background = Screen.colors.Red },
+ [3] = { background = Screen.colors.LightMagenta },
+ [4] = { reverse = true },
+ [5] = { background = Screen.colors.LightBlue },
+ [6] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { background = Screen.colors.Red, foreground = Screen.colors.White },
+ [8] = { bold = true, foreground = Screen.colors.Blue1 },
+ [9] = { bold = true, reverse = true },
})
screen:attach()
@@ -1131,7 +1178,9 @@ describe('CursorLine and CursorLineNr highlights', function()
feed('<esc>gg')
command('vsplit')
command('enew')
- feed('iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>')
+ feed(
+ 'iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>'
+ )
feed('<esc>gg')
command('windo diffthis')
screen:expect([[
@@ -1162,7 +1211,8 @@ describe('CursorLine and CursorLineNr highlights', function()
-- Rendered as underline in a diff-line. #9028
command('hi CursorLine ctermbg=red ctermfg=NONE guibg=red guifg=NONE')
feed('kkkk')
- screen:expect([[
+ screen:expect(
+ [[
{1: }line 1 some text │{1: }line 1 some text |
{1: }{11:line 2 mo}{12:Re text!}{11: }│{1: }{11:^line 2 mo}{12:re text}{11: }|
{1: }{5:extra line! }│{1: }{6:----------------------}|
@@ -1172,37 +1222,41 @@ describe('CursorLine and CursorLineNr highlights', function()
{8:~ }│{8:~ }|*3
{4:[No Name] [+] }{9:[No Name] [+] }|
|
- ]], {
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {bold = true, background = Screen.colors.Red},
- [3] = {background = Screen.colors.LightMagenta},
- [4] = {reverse = true},
- [5] = {background = Screen.colors.LightBlue},
- [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [8] = {bold = true, foreground = Screen.colors.Blue1},
- [9] = {bold = true, reverse = true},
- [10] = {bold = true},
- [11] = {underline = true,
- background = Screen.colors.LightMagenta},
- [12] = {bold = true, underline = true,
- background = Screen.colors.Red},
- })
+ ]],
+ {
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [2] = { bold = true, background = Screen.colors.Red },
+ [3] = { background = Screen.colors.LightMagenta },
+ [4] = { reverse = true },
+ [5] = { background = Screen.colors.LightBlue },
+ [6] = {
+ background = Screen.colors.LightCyan1,
+ bold = true,
+ foreground = Screen.colors.Blue1,
+ },
+ [7] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [8] = { bold = true, foreground = Screen.colors.Blue1 },
+ [9] = { bold = true, reverse = true },
+ [10] = { bold = true },
+ [11] = { underline = true, background = Screen.colors.LightMagenta },
+ [12] = { bold = true, underline = true, background = Screen.colors.Red },
+ }
+ )
end)
-- oldtest: Test_diff_with_cursorline_number()
it('CursorLineNr shows correctly just below filler lines', function()
- local screen = Screen.new(50,12)
+ local screen = Screen.new(50, 12)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {background = Screen.colors.Red, foreground = Screen.colors.White},
- [6] = {background = Screen.colors.White, bold = true, foreground = Screen.colors.Black},
- [7] = {bold = true, foreground = Screen.colors.Blue1},
- [8] = {bold = true, reverse = true},
- [9] = {foreground = Screen.colors.Brown},
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
+ [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { background = Screen.colors.Red, foreground = Screen.colors.White },
+ [6] = { background = Screen.colors.White, bold = true, foreground = Screen.colors.Black },
+ [7] = { bold = true, foreground = Screen.colors.Blue1 },
+ [8] = { bold = true, reverse = true },
+ [9] = { foreground = Screen.colors.Brown },
})
screen:attach()
@@ -1243,9 +1297,9 @@ describe('CursorColumn highlight', function()
clear()
screen = Screen.new(50, 8)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Gray90}, -- CursorColumn
- [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
- [3] = {bold = true}, -- ModeMsg
+ [1] = { background = Screen.colors.Gray90 }, -- CursorColumn
+ [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText
+ [3] = { bold = true }, -- ModeMsg
})
screen:attach()
end)
@@ -1298,22 +1352,27 @@ describe('CursorColumn highlight', function()
call timer_start(300, 'Func')
]])
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
aaaa{1:a} |
bbbb{1:b} |
cccc{1:c} |
dddd^d |
{2:~ }|*3
|
- ]], timeout = 100})
- screen:expect({grid = [[
+ ]],
+ timeout = 100,
+ })
+ screen:expect({
+ grid = [[
^aaaaa |
{1:b}bbbb |
{1:c}cccc |
{1:d}dddd |
{2:~ }|*3
|
- ]]})
+ ]],
+ })
end)
end)
@@ -1324,15 +1383,15 @@ describe('ColorColumn highlight', function()
clear()
screen = Screen.new(40, 15)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.LightRed}, -- ColorColumn
- [2] = {background = Screen.colors.Grey90}, -- CursorLine
- [3] = {foreground = Screen.colors.Brown}, -- LineNr
- [4] = {foreground = Screen.colors.Brown, bold = true}, -- CursorLineNr
- [5] = {foreground = Screen.colors.Blue, bold = true}, -- NonText
- [6] = {foreground = Screen.colors.Blue, background = Screen.colors.LightRed, bold = true},
- [7] = {reverse = true, bold = true}, -- StatusLine
- [8] = {reverse = true}, -- StatusLineNC
- [9] = {background = Screen.colors.Grey90, foreground = Screen.colors.Red},
+ [1] = { background = Screen.colors.LightRed }, -- ColorColumn
+ [2] = { background = Screen.colors.Grey90 }, -- CursorLine
+ [3] = { foreground = Screen.colors.Brown }, -- LineNr
+ [4] = { foreground = Screen.colors.Brown, bold = true }, -- CursorLineNr
+ [5] = { foreground = Screen.colors.Blue, bold = true }, -- NonText
+ [6] = { foreground = Screen.colors.Blue, background = Screen.colors.LightRed, bold = true },
+ [7] = { reverse = true, bold = true }, -- StatusLine
+ [8] = { reverse = true }, -- StatusLineNC
+ [9] = { background = Screen.colors.Grey90, foreground = Screen.colors.Red },
})
screen:attach()
end)
@@ -1413,33 +1472,36 @@ describe('ColorColumn highlight', function()
end)
end)
-describe("MsgSeparator highlight and msgsep fillchar", function()
+describe('MsgSeparator highlight and msgsep fillchar', function()
local screen
before_each(function()
clear()
- screen = Screen.new(50,5)
+ screen = Screen.new(50, 5)
screen:set_default_attr_ids({
- [1] = {bold=true, foreground=Screen.colors.Blue},
- [2] = {bold=true, reverse=true},
- [3] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [4] = {background = Screen.colors.Cyan, bold = true, reverse = true},
- [5] = {bold = true, background = Screen.colors.Magenta},
- [6] = {background = Screen.colors.WebGray},
- [7] = {background = Screen.colors.WebGray, bold = true, foreground = Screen.colors.SeaGreen4},
- [8] = {foreground = Screen.colors.Grey0, background = Screen.colors.Gray60},
- [9] = {foreground = Screen.colors.Grey40, background = Screen.colors.Gray60},
- [10] = {foreground = tonumber('0x000019'), background = Screen.colors.Gray60},
- [11] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x666699')},
- [12] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e')},
- [13] = {background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff')},
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { bold = true, reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [4] = { background = Screen.colors.Cyan, bold = true, reverse = true },
+ [5] = { bold = true, background = Screen.colors.Magenta },
+ [6] = { background = Screen.colors.WebGray },
+ [7] = {
+ background = Screen.colors.WebGray,
+ bold = true,
+ foreground = Screen.colors.SeaGreen4,
+ },
+ [8] = { foreground = Screen.colors.Grey0, background = Screen.colors.Gray60 },
+ [9] = { foreground = Screen.colors.Grey40, background = Screen.colors.Gray60 },
+ [10] = { foreground = tonumber('0x000019'), background = Screen.colors.Gray60 },
+ [11] = { background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x666699') },
+ [12] = { background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e') },
+ [13] = { background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff') },
})
screen:attach()
end)
- it("works", function()
-
+ it('works', function()
-- defaults
- feed_command("ls")
+ feed_command('ls')
screen:expect([[
|
{2: }|
@@ -1449,8 +1511,8 @@ describe("MsgSeparator highlight and msgsep fillchar", function()
]])
feed('<cr>')
- feed_command("set fillchars+=msgsep:-")
- feed_command("ls")
+ feed_command('set fillchars+=msgsep:-')
+ feed_command('ls')
screen:expect([[
|
{2:--------------------------------------------------}|
@@ -1460,8 +1522,8 @@ describe("MsgSeparator highlight and msgsep fillchar", function()
]])
-- linked to StatusLine per default
- feed_command("hi StatusLine guibg=Cyan")
- feed_command("ls")
+ feed_command('hi StatusLine guibg=Cyan')
+ feed_command('ls')
screen:expect([[
|
{4:--------------------------------------------------}|
@@ -1471,9 +1533,9 @@ describe("MsgSeparator highlight and msgsep fillchar", function()
]])
-- but can be unlinked
- feed_command("hi clear MsgSeparator")
- feed_command("hi MsgSeparator guibg=Magenta gui=bold")
- feed_command("ls")
+ feed_command('hi clear MsgSeparator')
+ feed_command('hi MsgSeparator guibg=Magenta gui=bold')
+ feed_command('ls')
screen:expect([[
|
{5:--------------------------------------------------}|
@@ -1483,51 +1545,63 @@ describe("MsgSeparator highlight and msgsep fillchar", function()
]])
end)
- it("and MsgArea", function()
- feed_command("hi MsgArea guibg=Gray")
- screen:expect{grid=[[
+ it('and MsgArea', function()
+ feed_command('hi MsgArea guibg=Gray')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{6: }|
- ]]}
- feed(":ls")
- screen:expect{grid=[[
+ ]],
+ }
+ feed(':ls')
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
{6::ls^ }|
- ]]}
- feed(":<cr>")
- screen:expect{grid=[[
+ ]],
+ }
+ feed(':<cr>')
+ screen:expect {
+ grid = [[
|
{2: }|
{6::ls: }|
{6: 1 %a "[No Name]" line 1 }|
{7:Press ENTER or type command to continue}{6:^ }|
- ]]}
+ ]],
+ }
-- support madness^Wblending of message "overlay"
- feed_command("hi MsgArea blend=20")
- feed_command("hi clear MsgSeparator")
- feed_command("hi MsgSeparator blend=30 guibg=Magenta")
- screen:expect{grid=[[
+ feed_command('hi MsgArea blend=20')
+ feed_command('hi clear MsgSeparator')
+ feed_command('hi MsgSeparator blend=30 guibg=Magenta')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
{8::hi}{9: }{8:MsgSeparator}{9: }{8:blend=30}{9: }{8:guibg=Magenta}{9: }|
- ]]}
- feed(":ls")
- screen:expect{grid=[[
+ ]],
+ }
+ feed(':ls')
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
{8::ls}{9:^ }|
- ]]}
- feed("<cr>")
- screen:expect{grid=[[
+ ]],
+ }
+ feed('<cr>')
+ screen:expect {
+ grid = [[
|
{13:~ }|
{10::ls}{11: }|
{11:~ }{10:1}{11: }{10:%a}{11: }{10:"[No}{11: }{10:Name]"}{11: }{10:line}{11: }{10:1}{11: }|
{12:Press}{9: }{12:ENTER}{9: }{12:or}{9: }{12:type}{9: }{12:command}{9: }{12:to}{9: }{12:continue}{9:^ }|
- ]]}
+ ]],
+ }
end)
end)
@@ -1535,11 +1609,11 @@ describe("'number' and 'relativenumber' highlight", function()
before_each(clear)
it('LineNr, LineNrAbove and LineNrBelow', function()
- local screen = Screen.new(20,10)
+ local screen = Screen.new(20, 10)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Red},
- [2] = {foreground = Screen.colors.Blue},
- [3] = {foreground = Screen.colors.Green},
+ [1] = { foreground = Screen.colors.Red },
+ [2] = { foreground = Screen.colors.Blue },
+ [3] = { foreground = Screen.colors.Green },
})
screen:attach()
command('set number relativenumber')
@@ -1603,8 +1677,8 @@ describe("'number' and 'relativenumber' highlight", function()
it('relative number highlight is updated if cursor is moved from timer', function()
local screen = Screen.new(50, 8)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Brown}, -- LineNr
- [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
+ [1] = { foreground = Screen.colors.Brown }, -- LineNr
+ [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText
})
screen:attach()
exec([[
@@ -1618,22 +1692,27 @@ describe("'number' and 'relativenumber' highlight", function()
call timer_start(300, 'Func')
]])
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
{1: 3 }aaaaa |
{1: 2 }bbbbb |
{1: 1 }ccccc |
{1: 0 }^ddddd |
{2:~ }|*3
|
- ]], timeout = 100})
- screen:expect({grid = [[
+ ]],
+ timeout = 100,
+ })
+ screen:expect({
+ grid = [[
{1: 0 }^aaaaa |
{1: 1 }bbbbb |
{1: 2 }ccccc |
{1: 3 }ddddd |
{2:~ }|*3
|
- ]]})
+ ]],
+ })
end)
end)
@@ -1642,50 +1721,54 @@ describe("'winhighlight' highlight", function()
before_each(function()
clear()
- screen = Screen.new(20,8)
+ screen = Screen.new(20, 8)
screen:attach()
screen:set_default_attr_ids {
- [0] = {bold=true, foreground=Screen.colors.Blue};
- [1] = {background = Screen.colors.DarkBlue};
- [2] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Blue1};
- [3] = {bold = true, reverse = true};
- [4] = {reverse = true};
- [5] = {background = Screen.colors.DarkGreen};
- [6] = {background = Screen.colors.DarkGreen, bold = true, foreground = Screen.colors.Blue1};
- [7] = {background = Screen.colors.DarkMagenta};
- [8] = {background = Screen.colors.DarkMagenta, bold = true, foreground = Screen.colors.Blue1};
- [9] = {foreground = Screen.colors.Brown};
- [10] = {foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue};
- [11] = {background = Screen.colors.DarkBlue, bold = true, reverse = true};
- [12] = {background = Screen.colors.DarkGreen, reverse = true};
- [13] = {background = Screen.colors.Magenta4, reverse = true};
- [14] = {background = Screen.colors.DarkBlue, reverse = true};
- [15] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
- [16] = {foreground = Screen.colors.Blue1};
- [17] = {background = Screen.colors.LightRed};
- [18] = {background = Screen.colors.Gray90};
- [19] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray};
- [20] = {background = Screen.colors.LightGrey, underline = true};
- [21] = {bold = true};
- [22] = {bold = true, foreground = Screen.colors.SeaGreen4};
- [23] = {background = Screen.colors.LightMagenta};
- [24] = {background = Screen.colors.WebGray};
- [25] = {bold = true, foreground = Screen.colors.Green1};
- [26] = {background = Screen.colors.Red};
- [27] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1};
- [28] = {bold = true, foreground = Screen.colors.Brown};
- [29] = {foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true};
- [30] = {background = tonumber('0xff8800')};
- [31] = {background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue};
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.DarkBlue },
+ [2] = { background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { bold = true, reverse = true },
+ [4] = { reverse = true },
+ [5] = { background = Screen.colors.DarkGreen },
+ [6] = { background = Screen.colors.DarkGreen, bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { background = Screen.colors.DarkMagenta },
+ [8] = {
+ background = Screen.colors.DarkMagenta,
+ bold = true,
+ foreground = Screen.colors.Blue1,
+ },
+ [9] = { foreground = Screen.colors.Brown },
+ [10] = { foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue },
+ [11] = { background = Screen.colors.DarkBlue, bold = true, reverse = true },
+ [12] = { background = Screen.colors.DarkGreen, reverse = true },
+ [13] = { background = Screen.colors.Magenta4, reverse = true },
+ [14] = { background = Screen.colors.DarkBlue, reverse = true },
+ [15] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [16] = { foreground = Screen.colors.Blue1 },
+ [17] = { background = Screen.colors.LightRed },
+ [18] = { background = Screen.colors.Gray90 },
+ [19] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
+ [20] = { background = Screen.colors.LightGrey, underline = true },
+ [21] = { bold = true },
+ [22] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [23] = { background = Screen.colors.LightMagenta },
+ [24] = { background = Screen.colors.WebGray },
+ [25] = { bold = true, foreground = Screen.colors.Green1 },
+ [26] = { background = Screen.colors.Red },
+ [27] = { background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1 },
+ [28] = { bold = true, foreground = Screen.colors.Brown },
+ [29] = { foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true },
+ [30] = { background = tonumber('0xff8800') },
+ [31] = { background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue },
}
- command("hi Background1 guibg=DarkBlue")
- command("hi Background2 guibg=DarkGreen")
+ command('hi Background1 guibg=DarkBlue')
+ command('hi Background2 guibg=DarkGreen')
end)
it('works for background color', function()
- insert("aa")
- command("split")
- command("set winhl=Normal:Background1")
+ insert('aa')
+ command('split')
+ command('set winhl=Normal:Background1')
screen:expect([[
{1:a^a }|
{2:~ }|*2
@@ -1696,7 +1779,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("enew")
+ command('enew')
screen:expect([[
{1:^ }|
{2:~ }|*2
@@ -1729,42 +1812,48 @@ describe("'winhighlight' highlight", function()
end)
it('handles undefined groups', function()
- command("set winhl=Normal:Background1")
+ command('set winhl=Normal:Background1')
screen:expect([[
{1:^ }|
{2:~ }|*6
|
]])
- command("set winhl=xxx:yyy")
+ command('set winhl=xxx:yyy')
eq('xxx:yyy', eval('&winhl'))
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*6
|
- ]]}
+ ]],
+ }
end)
it('can be changed to define different groups', function()
- command("set winhl=EndOfBuffer:Background1")
- screen:expect{grid=[[
+ command('set winhl=EndOfBuffer:Background1')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*6
|
- ]]}
+ ]],
+ }
- command("set winhl=Normal:ErrorMsg")
- screen:expect{grid=[[
+ command('set winhl=Normal:ErrorMsg')
+ screen:expect {
+ grid = [[
{15:^ }|
{29:~ }|*6
|
- ]]}
+ ]],
+ }
end)
it('works local to the window', function()
- insert("aa")
- command("split")
- command("setlocal winhl=Normal:Background1")
+ insert('aa')
+ command('split')
+ command('setlocal winhl=Normal:Background1')
screen:expect([[
{1:a^a }|
{2:~ }|*2
@@ -1775,7 +1864,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("enew")
+ command('enew')
screen:expect([[
^ |
{0:~ }|*2
@@ -1786,7 +1875,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("bnext")
+ command('bnext')
screen:expect([[
{1:^aa }|
{2:~ }|*2
@@ -1799,9 +1888,9 @@ describe("'winhighlight' highlight", function()
end)
it('for inactive window background works', function()
- command("set winhl=Normal:Background1,NormalNC:Background2")
+ command('set winhl=Normal:Background1,NormalNC:Background2')
-- tests global value is copied across split
- command("split")
+ command('split')
screen:expect([[
{1:^ }|
{2:~ }|*2
@@ -1812,7 +1901,7 @@ describe("'winhighlight' highlight", function()
|
]])
- feed("<c-w><c-w>")
+ feed('<c-w><c-w>')
screen:expect([[
{5: }|
{6:~ }|*2
@@ -1823,7 +1912,7 @@ describe("'winhighlight' highlight", function()
|
]])
- feed("<c-w><c-w>")
+ feed('<c-w><c-w>')
screen:expect([[
{1:^ }|
{2:~ }|*2
@@ -1836,9 +1925,9 @@ describe("'winhighlight' highlight", function()
end)
it('works with NormalNC', function()
- command("hi NormalNC guibg=DarkMagenta")
+ command('hi NormalNC guibg=DarkMagenta')
-- tests global value is copied across split
- command("split")
+ command('split')
screen:expect([[
^ |
{0:~ }|*2
@@ -1849,7 +1938,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("wincmd w")
+ command('wincmd w')
screen:expect([[
{7: }|
{8:~ }|*2
@@ -1860,9 +1949,8 @@ describe("'winhighlight' highlight", function()
|
]])
-
-- winbg=Normal:... overrides global NormalNC
- command("set winhl=Normal:Background1")
+ command('set winhl=Normal:Background1')
screen:expect([[
{7: }|
{8:~ }|*2
@@ -1873,7 +1961,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("wincmd w")
+ command('wincmd w')
screen:expect([[
^ |
{0:~ }|*2
@@ -1884,8 +1972,8 @@ describe("'winhighlight' highlight", function()
|
]])
- command("wincmd w")
- command("set winhl=Normal:Background1,NormalNC:Background2")
+ command('wincmd w')
+ command('set winhl=Normal:Background1,NormalNC:Background2')
screen:expect([[
{7: }|
{8:~ }|*2
@@ -1896,7 +1984,7 @@ describe("'winhighlight' highlight", function()
|
]])
- command("wincmd w")
+ command('wincmd w')
screen:expect([[
^ |
{0:~ }|*2
@@ -1909,9 +1997,10 @@ describe("'winhighlight' highlight", function()
end)
it('updates background to changed linked group', function()
- command("split")
- command("setlocal winhl=Normal:FancyGroup") -- does not yet exist
- screen:expect{grid=[[
+ command('split')
+ command('setlocal winhl=Normal:FancyGroup') -- does not yet exist
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{3:[No Name] }|
@@ -1919,10 +2008,12 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
- command("hi FancyGroup guibg=#FF8800") -- nice orange
- screen:expect{grid=[[
+ command('hi FancyGroup guibg=#FF8800') -- nice orange
+ screen:expect {
+ grid = [[
{30:^ }|
{31:~ }|*2
{3:[No Name] }|
@@ -1930,7 +2021,8 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
it('background applies also to non-text', function()
@@ -1996,13 +2088,12 @@ describe("'winhighlight' highlight", function()
end)
it('can override NonText, Conceal and EndOfBuffer', function()
- curbufmeths.set_lines(0,-1,true, {"raa\000"})
+ curbufmeths.set_lines(0, -1, true, { 'raa\000' })
command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
command('set cole=2 cocu=nvic')
command('split')
command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
- command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,'
- ..'Conceal:Background2')
+ command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,' .. 'Conceal:Background2')
screen:expect([[
^r{5:#}a{15:^@} |
@@ -2023,8 +2114,7 @@ describe("'winhighlight' highlight", function()
feed('k')
command('split')
- command('set winhl=LineNr:Background1,CursorColumn:Background2,'
- ..'ColorColumn:ErrorMsg')
+ command('set winhl=LineNr:Background1,CursorColumn:Background2,' .. 'ColorColumn:ErrorMsg')
screen:expect([[
{1: 1 }v{15:e}ry tex^t |
{1: 2 }m{15:o}re tex{5:t} |
@@ -2047,7 +2137,7 @@ describe("'winhighlight' highlight", function()
{0:~ }|*5
|
]])
- command("tabnext")
+ command('tabnext')
screen:expect([[
{21: No Name] }{1: No Name]}{20:X}|
^ |
@@ -2059,8 +2149,9 @@ describe("'winhighlight' highlight", function()
it('can override popupmenu', function()
insert('word wording wordy')
command('split')
- command('set winhl=Pmenu:Background1,PmenuSel:Background2,'
- ..'PmenuSbar:ErrorMsg,PmenuThumb:Normal')
+ command(
+ 'set winhl=Pmenu:Background1,PmenuSel:Background2,' .. 'PmenuSbar:ErrorMsg,PmenuThumb:Normal'
+ )
screen:expect([[
word wording word^y |
{0:~ }|*2
@@ -2101,7 +2192,8 @@ describe("'winhighlight' highlight", function()
command('set cursorline number')
command('split')
command('set winhl=CursorLine:Background1')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{28: 1 }{1:^ }|
{0:~ }|*2
{3:[No Name] }|
@@ -2109,10 +2201,12 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
command('set winhl=CursorLineNr:Background2,CursorLine:Background1')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5: 1 }{1:^ }|
{0:~ }|*2
{3:[No Name] }|
@@ -2120,10 +2214,12 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
feed('<c-w>w')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5: 1 }{1: }|
{0:~ }|*2
{4:[No Name] }|
@@ -2131,7 +2227,8 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{3:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
it('can override StatusLine and StatusLineNC', function()
@@ -2164,8 +2261,7 @@ describe("'winhighlight' highlight", function()
]])
end)
-
- it("can override syntax groups", function()
+ it('can override syntax groups', function()
command('syntax on')
command('syntax keyword Foobar foobar')
command('syntax keyword Article the')
@@ -2181,7 +2277,8 @@ describe("'winhighlight' highlight", function()
command('split')
command('set winhl=Foobar:Background1,Article:ErrorMsg')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{15:the} {1:foobar} was {1:fooba}|
{1:^r} |
{0:~ }|
@@ -2190,12 +2287,14 @@ describe("'winhighlight' highlight", function()
{26:r} |
{4:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
end)
it('can be disabled in newly opened window #19823', function()
command('split | set winhl=Normal:ErrorMsg | set winhl=')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{3:[No Name] }|
@@ -2203,7 +2302,8 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
helpers.assert_alive()
end)
@@ -2217,7 +2317,8 @@ describe("'winhighlight' highlight", function()
insert [[
some text
more text]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
some text |
more tex^t |
{0:~ }|
@@ -2226,10 +2327,12 @@ describe("'winhighlight' highlight", function()
more text |
{4:[No Name] }{1:1,1 All}|
|
- ]]}
+ ]],
+ }
command 'set winhl=Background1:Background2'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
some text |
more tex^t |
{0:~ }|
@@ -2238,10 +2341,12 @@ describe("'winhighlight' highlight", function()
more text |
{4:[No Name] }{1:1,1 All}|
|
- ]]}
+ ]],
+ }
feed 'k'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
some tex^t |
more text |
{0:~ }|
@@ -2250,7 +2355,8 @@ describe("'winhighlight' highlight", function()
more text |
{4:[No Name] }{1:1,1 All}|
|
- ]]}
+ ]],
+ }
end)
it('can link to empty highlight group', function()
@@ -2258,7 +2364,8 @@ describe("'winhighlight' highlight", function()
command 'set winhl=NormalNC:Normal'
command 'split'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{3:[No Name] }|
@@ -2266,7 +2373,8 @@ describe("'winhighlight' highlight", function()
{0:~ }|
{4:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
end)
@@ -2276,57 +2384,69 @@ describe('highlight namespaces', function()
before_each(function()
clear()
- screen = Screen.new(25,10)
+ screen = Screen.new(25, 10)
screen:attach()
screen:set_default_attr_ids {
- [1] = {foreground = Screen.colors.Blue, bold = true};
- [2] = {background = Screen.colors.DarkGrey};
- [3] = {italic = true, foreground = Screen.colors.DarkCyan, background = Screen.colors.DarkOrange4};
- [4] = {background = Screen.colors.Magenta4};
- [5] = {background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson};
- [6] = {bold = true, reverse = true};
- [7] = {reverse = true};
- [8] = {foreground = Screen.colors.Gray20};
- [9] = {foreground = Screen.colors.Blue};
- [10] = {bold = true, foreground = Screen.colors.SeaGreen};
+ [1] = { foreground = Screen.colors.Blue, bold = true },
+ [2] = { background = Screen.colors.DarkGrey },
+ [3] = {
+ italic = true,
+ foreground = Screen.colors.DarkCyan,
+ background = Screen.colors.DarkOrange4,
+ },
+ [4] = { background = Screen.colors.Magenta4 },
+ [5] = { background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson },
+ [6] = { bold = true, reverse = true },
+ [7] = { reverse = true },
+ [8] = { foreground = Screen.colors.Gray20 },
+ [9] = { foreground = Screen.colors.Blue },
+ [10] = { bold = true, foreground = Screen.colors.SeaGreen },
}
ns1 = meths.create_namespace 'grungy'
ns2 = meths.create_namespace 'ultrared'
- meths.set_hl(ns1, 'Normal', {bg='DarkGrey'})
- meths.set_hl(ns1, 'NonText', {bg='DarkOrange4', fg='DarkCyan', italic=true})
- meths.set_hl(ns2, 'Normal', {bg='DarkMagenta'})
- meths.set_hl(ns2, 'NonText', {fg='Crimson'})
+ meths.set_hl(ns1, 'Normal', { bg = 'DarkGrey' })
+ meths.set_hl(ns1, 'NonText', { bg = 'DarkOrange4', fg = 'DarkCyan', italic = true })
+ meths.set_hl(ns2, 'Normal', { bg = 'DarkMagenta' })
+ meths.set_hl(ns2, 'NonText', { fg = 'Crimson' })
end)
it('can be used globally', function()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
meths.set_hl_ns(ns1)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:^ }|
{3:~ }|*8
|
- ]]}
+ ]],
+ }
meths.set_hl_ns(ns2)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{4:^ }|
{5:~ }|*8
|
- ]]}
+ ]],
+ }
meths.set_hl_ns(0)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
end)
it('can be used per window', function()
@@ -2338,7 +2458,8 @@ describe('highlight namespaces', function()
meths.win_set_hl_ns(win1, ns1)
meths.win_set_hl_ns(win2, ns2)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|
{6:[No Name] }|
@@ -2349,22 +2470,27 @@ describe('highlight namespaces', function()
{3:~ }|
{7:[No Name] }|
|
- ]]}
+ ]],
+ }
end)
it('redraws correctly when ns=0', function()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*8
|
- ]]}
+ ]],
+ }
- meths.set_hl(0, 'EndOfBuffer', {fg='#333333'})
- screen:expect{grid=[[
+ meths.set_hl(0, 'EndOfBuffer', { fg = '#333333' })
+ screen:expect {
+ grid = [[
^ |
{8:~ }|*8
|
- ]]}
+ ]],
+ }
end)
it('winhl does not accept invalid value #24586', function()
@@ -2375,16 +2501,17 @@ describe('highlight namespaces', function()
return { msg, vim.wo[curwin].winhl }
]])
eq({
- "Vim(set):E5248: Invalid character in group name",
- "Normal:Visual",
- },res)
+ 'Vim(set):E5248: Invalid character in group name',
+ 'Normal:Visual',
+ }, res)
end)
it('Normal in set_hl #25474', function()
command('highlight Ignore guifg=bg ctermfg=White')
- meths.set_hl(0, 'Normal', {bg='#333333'})
+ meths.set_hl(0, 'Normal', { bg = '#333333' })
command('highlight Ignore')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{6: }|
@@ -2394,6 +2521,7 @@ describe('highlight namespaces', function()
bg |
{10:Press ENTER or type comma}|
{10:nd to continue}^ |
- ]]}
+ ]],
+ }
end)
end)
diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua
index e36309f32a..8147636326 100644
--- a/test/functional/ui/hlstate_spec.lua
+++ b/test/functional/ui/hlstate_spec.lua
@@ -17,59 +17,80 @@ describe('ext_hlstate detailed highlights', function()
command('syntax on')
command('hi VertSplit gui=reverse')
screen = Screen.new(40, 8)
- screen:attach({ext_hlstate=true})
+ screen:attach({ ext_hlstate = true })
end)
after_each(function()
screen:detach()
end)
-
it('work with combined UI and syntax highlights', function()
insert([[
these are some lines
with colorful text]])
- meths.buf_add_highlight(0, -1, "String", 0 , 10, 14)
- meths.buf_add_highlight(0, -1, "Statement", 1 , 5, -1)
- command("/th co")
+ meths.buf_add_highlight(0, -1, 'String', 0, 10, 14)
+ meths.buf_add_highlight(0, -1, 'Statement', 1, 5, -1)
+ command('/th co')
- screen:expect([[
+ screen:expect(
+ [[
these are {1:some} lines |
^wi{2:th }{4:co}{3:lorful text} |
{5:~ }|*5
{8:search hit BOTTOM, continuing at TOP}{7: }|
- ]], {
- [1] = {{foreground = Screen.colors.Magenta},
- {{hi_name = "Constant", kind = "syntax"}}},
- [2] = {{background = Screen.colors.Yellow},
- {{hi_name = "Search", ui_name = "Search", kind = "ui"}}},
- [3] = {{bold = true, foreground = Screen.colors.Brown},
- {{hi_name = "Statement", kind = "syntax"}}},
- [4] = {{bold = true, background = Screen.colors.Yellow, foreground = Screen.colors.Brown}, {3, 2}},
- [5] = {{bold = true, foreground = Screen.colors.Blue1},
- {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}},
- [6] = {{foreground = Screen.colors.Red},
- {{hi_name = "WarningMsg", ui_name = "WarningMsg", kind = "ui"}}},
- [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
- [8] = {{foreground = Screen.colors.Red}, {7, 6}},
- })
+ ]],
+ {
+ [1] = {
+ { foreground = Screen.colors.Magenta },
+ { { hi_name = 'Constant', kind = 'syntax' } },
+ },
+ [2] = {
+ { background = Screen.colors.Yellow },
+ { { hi_name = 'Search', ui_name = 'Search', kind = 'ui' } },
+ },
+ [3] = {
+ { bold = true, foreground = Screen.colors.Brown },
+ { { hi_name = 'Statement', kind = 'syntax' } },
+ },
+ [4] = {
+ { bold = true, background = Screen.colors.Yellow, foreground = Screen.colors.Brown },
+ { 3, 2 },
+ },
+ [5] = {
+ { bold = true, foreground = Screen.colors.Blue1 },
+ { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
+ },
+ [6] = {
+ { foreground = Screen.colors.Red },
+ { { hi_name = 'WarningMsg', ui_name = 'WarningMsg', kind = 'ui' } },
+ },
+ [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
+ [8] = { { foreground = Screen.colors.Red }, { 7, 6 } },
+ }
+ )
end)
it('work with cleared UI highlights', function()
screen:set_default_attr_ids({
- [1] = {{}, {{hi_name = "Normal", ui_name = "WinSeparator", kind = "ui"}}},
- [2] = {{bold = true, foreground = Screen.colors.Blue1},
- {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}},
- [3] = {{bold = true, reverse = true},
- {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}} ,
- [4] = {{reverse = true},
- {{hi_name = "StatusLineNC", ui_name = "StatusLineNC" , kind = "ui"}}},
- [5] = {{}, {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}},
- [6] = {{}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}},
- [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
+ [1] = { {}, { { hi_name = 'Normal', ui_name = 'WinSeparator', kind = 'ui' } } },
+ [2] = {
+ { bold = true, foreground = Screen.colors.Blue1 },
+ { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
+ },
+ [3] = {
+ { bold = true, reverse = true },
+ { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } },
+ },
+ [4] = {
+ { reverse = true },
+ { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } },
+ },
+ [5] = { {}, { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } } },
+ [6] = { {}, { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } } },
+ [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
})
- command("hi clear WinSeparator")
- command("vsplit")
+ command('hi clear WinSeparator')
+ command('vsplit')
screen:expect([[
^ {1:│} |
@@ -78,7 +99,7 @@ describe('ext_hlstate detailed highlights', function()
{7: }|
]])
- command("hi clear StatusLine | hi clear StatuslineNC")
+ command('hi clear StatusLine | hi clear StatuslineNC')
screen:expect([[
^ {1:│} |
{2:~ }{1:│}{2:~ }|*5
@@ -87,36 +108,62 @@ describe('ext_hlstate detailed highlights', function()
]])
-- redrawing is done even if visible highlights didn't change
- command("wincmd w")
+ command('wincmd w')
screen:expect([[
{1:│}^ |
{2:~ }{1:│}{2:~ }|*5
{6:[No Name] }{5:[No Name] }|
{7: }|
]])
-
end)
- it("work with window-local highlights", function()
+ it('work with window-local highlights', function()
screen:set_default_attr_ids({
- [1] = {{foreground = Screen.colors.Brown}, {{hi_name = "LineNr", ui_name = "LineNr", kind = "ui"}}},
- [2] = {{bold = true, foreground = Screen.colors.Blue1}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}},
- [3] = {{bold = true, reverse = true}, {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}},
- [4] = {{reverse = true}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}},
- [5] = {{background = Screen.colors.Red, foreground = Screen.colors.Grey100}, {{hi_name = "ErrorMsg", ui_name = "LineNr", kind = "ui"}}},
- [6] = {{bold = true, reverse = true}, {{hi_name = "Normal", ui_name = "Normal", kind = "ui"}}},
- [7] = {{foreground = Screen.colors.Brown, bold = true, reverse = true}, {6, 1}},
- [8] = {{foreground = Screen.colors.Blue1, bold = true, reverse = true}, {6, 14}},
- [9] = {{bold = true, foreground = Screen.colors.Brown}, {{hi_name = "NormalNC", ui_name = "NormalNC", kind = "ui"}}},
- [10] = {{bold = true, foreground = Screen.colors.Brown}, {9, 1}},
- [11] = {{bold = true, foreground = Screen.colors.Blue1}, {9, 14}},
- [12] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
- [13] = {{background = Screen.colors.Red1, foreground = Screen.colors.Gray100}, {{ui_name = "LineNr", kind = "ui", hi_name = "LineNr"}}};
- [14] = {{bold = true, foreground = Screen.colors.Blue}, {{ui_name = "EndOfBuffer", kind = "ui", hi_name = "EndOfBuffer"}}};
+ [1] = {
+ { foreground = Screen.colors.Brown },
+ { { hi_name = 'LineNr', ui_name = 'LineNr', kind = 'ui' } },
+ },
+ [2] = {
+ { bold = true, foreground = Screen.colors.Blue1 },
+ { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
+ },
+ [3] = {
+ { bold = true, reverse = true },
+ { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } },
+ },
+ [4] = {
+ { reverse = true },
+ { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } },
+ },
+ [5] = {
+ { background = Screen.colors.Red, foreground = Screen.colors.Grey100 },
+ { { hi_name = 'ErrorMsg', ui_name = 'LineNr', kind = 'ui' } },
+ },
+ [6] = {
+ { bold = true, reverse = true },
+ { { hi_name = 'Normal', ui_name = 'Normal', kind = 'ui' } },
+ },
+ [7] = { { foreground = Screen.colors.Brown, bold = true, reverse = true }, { 6, 1 } },
+ [8] = { { foreground = Screen.colors.Blue1, bold = true, reverse = true }, { 6, 14 } },
+ [9] = {
+ { bold = true, foreground = Screen.colors.Brown },
+ { { hi_name = 'NormalNC', ui_name = 'NormalNC', kind = 'ui' } },
+ },
+ [10] = { { bold = true, foreground = Screen.colors.Brown }, { 9, 1 } },
+ [11] = { { bold = true, foreground = Screen.colors.Blue1 }, { 9, 14 } },
+ [12] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
+ [13] = {
+ { background = Screen.colors.Red1, foreground = Screen.colors.Gray100 },
+ { { ui_name = 'LineNr', kind = 'ui', hi_name = 'LineNr' } },
+ },
+ [14] = {
+ { bold = true, foreground = Screen.colors.Blue },
+ { { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'EndOfBuffer' } },
+ },
})
- command("set number")
- command("split")
+ command('set number')
+ command('split')
-- NormalNC is not applied if not set, to avoid spurious redraws
screen:expect([[
{1: 1 }^ |
@@ -128,8 +175,9 @@ describe('ext_hlstate detailed highlights', function()
{12: }|
]])
- command("set winhl=LineNr:ErrorMsg")
- screen:expect{grid=[[
+ command('set winhl=LineNr:ErrorMsg')
+ screen:expect {
+ grid = [[
{13: 1 }^ |
{14:~ }|*2
{3:[No Name] }|
@@ -137,9 +185,10 @@ describe('ext_hlstate detailed highlights', function()
{2:~ }|
{4:[No Name] }|
{12: }|
- ]]}
+ ]],
+ }
- command("set winhl=Normal:MsgSeparator,NormalNC:Statement")
+ command('set winhl=Normal:MsgSeparator,NormalNC:Statement')
screen:expect([[
{7: 1 }{6:^ }|
{8:~ }|*2
@@ -150,7 +199,7 @@ describe('ext_hlstate detailed highlights', function()
{12: }|
]])
- command("wincmd w")
+ command('wincmd w')
screen:expect([[
{10: 1 }{9: }|
{11:~ }|*2
@@ -162,17 +211,22 @@ describe('ext_hlstate detailed highlights', function()
]])
end)
- it("work with :terminal", function()
+ it('work with :terminal', function()
skip(is_os('win'))
screen:set_default_attr_ids({
- [1] = {{}, {{hi_name = "TermCursorNC", ui_name = "TermCursorNC", kind = "ui"}}},
- [2] = {{foreground = tonumber('0x00ccff'), fg_indexed=true}, {{kind = "term"}}},
- [3] = {{bold = true, foreground = tonumber('0x00ccff'), fg_indexed=true}, {{kind = "term"}}},
- [4] = {{foreground = tonumber('0x00ccff'), fg_indexed=true}, {2, 1}},
- [5] = {{foreground = tonumber('0x40ffff'), fg_indexed=true}, {{kind = "term"}}},
- [6] = {{foreground = tonumber('0x40ffff'), fg_indexed=true}, {5, 1}},
- [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
+ [1] = { {}, { { hi_name = 'TermCursorNC', ui_name = 'TermCursorNC', kind = 'ui' } } },
+ [2] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { { kind = 'term' } } },
+ [3] = {
+ { bold = true, foreground = tonumber('0x00ccff'), fg_indexed = true },
+ {
+ { kind = 'term' },
+ },
+ },
+ [4] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { 2, 1 } },
+ [5] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { { kind = 'term' } } },
+ [6] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { 5, 1 } },
+ [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
})
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
screen:expect([[
@@ -206,8 +260,8 @@ describe('ext_hlstate detailed highlights', function()
]])
end
- thelpers.feed_termcode("[A")
- thelpers.feed_termcode("[2C")
+ thelpers.feed_termcode('[A')
+ thelpers.feed_termcode('[2C')
if is_os('win') then
screen:expect([[
^tty ready |
@@ -225,14 +279,22 @@ describe('ext_hlstate detailed highlights', function()
end
end)
- it("can use independent cterm and rgb colors", function()
+ it('can use independent cterm and rgb colors', function()
-- tell test module to save all attributes (doesn't change nvim options)
screen:set_rgb_cterm(true)
screen:set_default_attr_ids({
- [1] = {{bold = true, foreground = Screen.colors.Blue1}, {foreground = 12}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}},
- [2] = {{reverse = true, foreground = Screen.colors.Red}, {foreground = 10, italic=true}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}},
- [3] = {{}, {}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
+ [1] = {
+ { bold = true, foreground = Screen.colors.Blue1 },
+ { foreground = 12 },
+ { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
+ },
+ [2] = {
+ { reverse = true, foreground = Screen.colors.Red },
+ { foreground = 10, italic = true },
+ { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
+ },
+ [3] = { {}, {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
})
screen:expect([[
^ |
@@ -240,12 +302,11 @@ describe('ext_hlstate detailed highlights', function()
{3: }|
]])
- command("hi NonText guifg=Red gui=reverse ctermfg=Green cterm=italic")
+ command('hi NonText guifg=Red gui=reverse ctermfg=Green cterm=italic')
screen:expect([[
^ |
{2:~ }|*6
{3: }|
]])
-
end)
end)
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 7a7c3c2945..6b64928622 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -32,7 +32,7 @@ local multiline_text = [[
7 8 9
]]
-local multimatch_text = [[
+local multimatch_text = [[
a bdc eae a fgl lzia r
x
]]
@@ -62,70 +62,70 @@ local long_multiline_text = [[
local function common_setup(screen, inccommand, text)
if screen then
- command("syntax on")
- command("set nohlsearch")
- 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},
- [2] = {foreground = Screen.colors.Brown, bold = true},
- [3] = {foreground = Screen.colors.SlateBlue},
- [4] = {bold = true, foreground = Screen.colors.SlateBlue},
- [5] = {foreground = Screen.colors.DarkCyan},
- [6] = {bold = true},
- [7] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue},
- [8] = {foreground = Screen.colors.Slateblue, underline = true},
- [9] = {background = Screen.colors.Yellow},
- [10] = {reverse = true},
- [11] = {reverse = true, bold=true},
- [12] = {foreground = Screen.colors.Red, background = Screen.colors.Yellow},
- [13] = {bold = true, foreground = Screen.colors.SeaGreen},
- [14] = {foreground = Screen.colors.White, background = Screen.colors.Red},
- [15] = {bold=true, foreground=Screen.colors.Blue},
- [16] = {background=Screen.colors.Grey90}, -- cursorline
- [17] = {foreground = Screen.colors.Blue1},
- vis = {background=Screen.colors.LightGrey}
+ [1] = { foreground = Screen.colors.Fuchsia },
+ [2] = { foreground = Screen.colors.Brown, bold = true },
+ [3] = { foreground = Screen.colors.SlateBlue },
+ [4] = { bold = true, foreground = Screen.colors.SlateBlue },
+ [5] = { foreground = Screen.colors.DarkCyan },
+ [6] = { bold = true },
+ [7] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue },
+ [8] = { foreground = Screen.colors.Slateblue, underline = true },
+ [9] = { background = Screen.colors.Yellow },
+ [10] = { reverse = true },
+ [11] = { reverse = true, bold = true },
+ [12] = { foreground = Screen.colors.Red, background = Screen.colors.Yellow },
+ [13] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [14] = { foreground = Screen.colors.White, background = Screen.colors.Red },
+ [15] = { bold = true, foreground = Screen.colors.Blue },
+ [16] = { background = Screen.colors.Grey90 }, -- cursorline
+ [17] = { foreground = Screen.colors.Blue1 },
+ vis = { background = Screen.colors.LightGrey },
})
end
- command("set inccommand=" .. (inccommand or ""))
+ command('set inccommand=' .. (inccommand or ''))
if text then
insert(text)
end
end
-describe(":substitute, inccommand=split interactivity", function()
+describe(':substitute, inccommand=split interactivity', function()
before_each(function()
clear()
- common_setup(nil, "split", default_text)
+ common_setup(nil, 'split', default_text)
end)
-- Test the tests: verify that the `1==bufnr('$')` assertion
-- in the "no preview" tests (below) actually means something.
- it("previews interactive cmdline", function()
+ it('previews interactive cmdline', function()
feed(':%s/tw/MO/g')
retry(nil, 1000, function()
eq(2, eval("bufnr('$')"))
end)
end)
- it("no preview if invoked by a script", function()
+ it('no preview if invoked by a script', function()
source('%s/tw/MO/g')
poke_eventloop()
eq(1, eval("bufnr('$')"))
-- sanity check: assert the buffer state
- expect(default_text:gsub("tw", "MO"))
+ expect(default_text:gsub('tw', 'MO'))
end)
- it("no preview if invoked by feedkeys()", function()
+ it('no preview if invoked by feedkeys()', function()
-- in a script...
source([[:call feedkeys(":%s/tw/MO/g\<CR>")]])
-- or interactively...
feed([[:call feedkeys(":%s/bs/BUU/g\<lt>CR>")<CR>]])
eq(1, eval("bufnr('$')"))
-- sanity check: assert the buffer state
- expect(default_text:gsub("tw", "MO"):gsub("bs", "BUU"))
+ expect(default_text:gsub('tw', 'MO'):gsub('bs', 'BUU'))
end)
end)
@@ -133,8 +133,8 @@ describe(":substitute, 'inccommand' preserves", function()
before_each(clear)
it('listed buffers (:ls)', function()
- local screen = Screen.new(30,10)
- common_setup(screen, "split", "ABC")
+ local screen = Screen.new(30, 10)
+ common_setup(screen, 'split', 'ABC')
feed(':%s/AB/BA/')
poke_eventloop()
@@ -159,62 +159,62 @@ describe(":substitute, 'inccommand' preserves", function()
feed('ggyG')
local X = meths.get_vvar('maxcol')
- eq({0, 1, 1, 0}, funcs.getpos("'["))
- eq({0, 101, X, 0}, funcs.getpos("']"))
+ eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
+ eq({ 0, 101, X, 0 }, funcs.getpos("']"))
feed(":'[,']s/def/")
poke_eventloop()
- eq({0, 1, 1, 0}, funcs.getpos("'["))
- eq({0, 101, X, 0}, funcs.getpos("']"))
+ eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
+ eq({ 0, 101, X, 0 }, funcs.getpos("']"))
feed('DEF/g')
poke_eventloop()
- eq({0, 1, 1, 0}, funcs.getpos("'["))
- eq({0, 101, X, 0}, funcs.getpos("']"))
+ eq({ 0, 1, 1, 0 }, funcs.getpos("'["))
+ eq({ 0, 101, X, 0 }, funcs.getpos("']"))
feed('<CR>')
expect(('abc\nDEF\n'):rep(50))
end)
- for _, case in pairs{"", "split", "nosplit"} do
- it("various delimiters (inccommand="..case..")", function()
+ for _, case in pairs { '', 'split', 'nosplit' } do
+ it('various delimiters (inccommand=' .. case .. ')', function()
insert(default_text)
- command("set inccommand=" .. case)
+ command('set inccommand=' .. case)
local delims = { '/', '#', ';', '%', ',', '@', '!' }
- for _,delim in pairs(delims) do
- feed(":%s"..delim.."lines"..delim.."LINES"..delim.."g")
+ for _, delim in pairs(delims) do
+ feed(':%s' .. delim .. 'lines' .. delim .. 'LINES' .. delim .. 'g')
poke_eventloop()
feed('<CR>')
expect([[
Inc substitution on
two LINES
]])
- command("undo")
+ command('undo')
end
end)
end
- for _, case in pairs{"", "split", "nosplit"} do
- it("'undolevels' (inccommand="..case..")", function()
- command("set undolevels=139")
- command("setlocal undolevels=34")
- command("split") -- Show the buffer in multiple windows
- command("set inccommand=" .. case)
- insert("as")
- feed(":%s/as/glork/")
+ for _, case in pairs { '', 'split', 'nosplit' } do
+ it("'undolevels' (inccommand=" .. case .. ')', function()
+ command('set undolevels=139')
+ command('setlocal undolevels=34')
+ command('split') -- Show the buffer in multiple windows
+ command('set inccommand=' .. case)
+ insert('as')
+ feed(':%s/as/glork/')
poke_eventloop()
- feed("<enter>")
- eq(meths.get_option_value('undolevels', {scope='global'}), 139)
- eq(meths.get_option_value('undolevels', {buf=0}), 34)
+ feed('<enter>')
+ eq(meths.get_option_value('undolevels', { scope = 'global' }), 139)
+ eq(meths.get_option_value('undolevels', { buf = 0 }), 34)
end)
end
- for _, case in ipairs({"", "split", "nosplit"}) do
- it("empty undotree() (inccommand="..case..")", function()
- command("set undolevels=1000")
- command("set inccommand=" .. case)
- local expected_undotree = eval("undotree()")
+ for _, case in ipairs({ '', 'split', 'nosplit' }) do
+ it('empty undotree() (inccommand=' .. case .. ')', function()
+ command('set undolevels=1000')
+ command('set inccommand=' .. case)
+ local expected_undotree = eval('undotree()')
-- Start typing an incomplete :substitute command.
feed([[:%s/e/YYYY/g]])
@@ -223,15 +223,15 @@ describe(":substitute, 'inccommand' preserves", function()
feed([[<C-\><C-N>]])
-- The undo tree should be unchanged.
- eq(expected_undotree, eval("undotree()"))
- eq({}, eval("undotree()")["entries"])
+ eq(expected_undotree, eval('undotree()'))
+ eq({}, eval('undotree()')['entries'])
end)
end
- for _, case in ipairs({"", "split", "nosplit"}) do
- it("undotree() with branches (inccommand="..case..")", function()
- command("set undolevels=1000")
- command("set inccommand=" .. case)
+ for _, case in ipairs({ '', 'split', 'nosplit' }) do
+ it('undotree() with branches (inccommand=' .. case .. ')', function()
+ command('set undolevels=1000')
+ command('set inccommand=' .. case)
-- Make some changes.
feed([[isome text 1<C-\><C-N>]])
feed([[osome text 2<C-\><C-N>]])
@@ -249,8 +249,8 @@ describe(":substitute, 'inccommand' preserves", function()
some text 1
some text 3XX
some text 5]])
- local expected_undotree = eval("undotree()")
- eq(5, #expected_undotree["entries"]) -- sanity
+ local expected_undotree = eval('undotree()')
+ eq(5, #expected_undotree['entries']) -- sanity
-- Start typing an incomplete :substitute command.
feed([[:%s/e/YYYY/g]])
@@ -259,31 +259,31 @@ describe(":substitute, 'inccommand' preserves", function()
feed([[<C-\><C-N>]])
-- The undo tree should be unchanged.
- eq(expected_undotree, eval("undotree()"))
+ eq(expected_undotree, eval('undotree()'))
end)
end
- for _, case in pairs{"", "split", "nosplit"} do
- it("b:changedtick (inccommand="..case..")", function()
- command("set inccommand=" .. case)
+ for _, case in pairs { '', 'split', 'nosplit' } do
+ it('b:changedtick (inccommand=' .. case .. ')', function()
+ command('set inccommand=' .. case)
feed([[isome text 1<C-\><C-N>]])
feed([[osome text 2<C-\><C-N>]])
- local expected_tick = eval("b:changedtick")
+ local expected_tick = eval('b:changedtick')
ok(expected_tick > 0)
expect([[
some text 1
some text 2]])
- feed(":%s/e/XXX/")
+ feed(':%s/e/XXX/')
poke_eventloop()
- eq(expected_tick, eval("b:changedtick"))
+ eq(expected_tick, eval('b:changedtick'))
end)
end
- for _, case in ipairs({'', 'split', 'nosplit'}) do
- it('previous substitute string ~ (inccommand='..case..') #12109', function()
- local screen = Screen.new(30,10)
+ for _, case in ipairs({ '', 'split', 'nosplit' }) do
+ it('previous substitute string ~ (inccommand=' .. case .. ') #12109', function()
+ local screen = Screen.new(30, 10)
common_setup(screen, case, default_text)
feed(':%s/Inc/SUB<CR>')
@@ -348,7 +348,7 @@ describe(":substitute, 'inccommand' preserves", function()
end)
describe(":substitute, 'inccommand' preserves undo", function()
- local cases = { "", "split", "nosplit" }
+ local cases = { '', 'split', 'nosplit' }
local substrings = {
{ ':%s/', '1' },
@@ -370,29 +370,29 @@ describe(":substitute, 'inccommand' preserves undo", function()
local function test_sub(substring, split, redoable)
command('bwipe!')
- command("set inccommand=" .. split)
+ command('set inccommand=' .. split)
- insert("1")
- feed("o2<esc>")
- command("undo")
- feed("o3<esc>")
+ insert('1')
+ feed('o2<esc>')
+ command('undo')
+ feed('o3<esc>')
if redoable then
- feed("o4<esc>")
- command("undo")
+ feed('o4<esc>')
+ command('undo')
end
for _, s in pairs(substring) do
feed(s)
end
poke_eventloop()
- feed("<enter>")
- command("undo")
+ feed('<enter>')
+ command('undo')
- feed("g-")
+ feed('g-')
expect([[
1
2]])
- feed("g+")
+ feed('g+')
expect([[
1
3]])
@@ -400,34 +400,34 @@ describe(":substitute, 'inccommand' preserves undo", function()
local function test_notsub(substring, split, redoable)
command('bwipe!')
- command("set inccommand=" .. split)
+ command('set inccommand=' .. split)
- insert("1")
- feed("o2<esc>")
- command("undo")
- feed("o3<esc>")
+ insert('1')
+ feed('o2<esc>')
+ command('undo')
+ feed('o3<esc>')
if redoable then
- feed("o4<esc>")
- command("undo")
+ feed('o4<esc>')
+ command('undo')
end
for _, s in pairs(substring) do
feed(s)
end
poke_eventloop()
- feed("<esc>")
+ feed('<esc>')
- feed("g-")
+ feed('g-')
expect([[
1
2]])
- feed("g+")
+ feed('g+')
expect([[
1
3]])
if redoable then
- feed("<c-r>")
+ feed('<c-r>')
expect([[
1
3
@@ -435,20 +435,19 @@ describe(":substitute, 'inccommand' preserves undo", function()
end
end
-
local function test_threetree(substring, split)
command('bwipe!')
- command("set inccommand=" .. split)
-
- insert("1")
- feed("o2<esc>")
- feed("o3<esc>")
- feed("uu")
- feed("oa<esc>")
- feed("ob<esc>")
- feed("uu")
- feed("oA<esc>")
- feed("oB<esc>")
+ command('set inccommand=' .. split)
+
+ insert('1')
+ feed('o2<esc>')
+ feed('o3<esc>')
+ feed('uu')
+ feed('oa<esc>')
+ feed('ob<esc>')
+ feed('uu')
+ feed('oA<esc>')
+ feed('oB<esc>')
-- This is the undo tree (x-Axis is timeline), we're at B now
-- ----------------A - B
@@ -457,45 +456,45 @@ describe(":substitute, 'inccommand' preserves undo", function()
-- |/
-- 1 - 2 - 3
- feed("2u")
+ feed('2u')
for _, s in pairs(substring) do
feed(s)
poke_eventloop()
end
- feed("<esc>")
+ feed('<esc>')
expect([[
1]])
- feed("g-")
+ feed('g-')
expect([[
]])
- feed("g+")
+ feed('g+')
expect([[
1]])
- feed("<c-r>")
+ feed('<c-r>')
expect([[
1
A]])
- feed("g-") -- go to b
- feed("2u")
+ feed('g-') -- go to b
+ feed('2u')
for _, s in pairs(substring) do
feed(s)
poke_eventloop()
end
- feed("<esc>")
- feed("<c-r>")
+ feed('<esc>')
+ feed('<c-r>')
expect([[
1
a]])
- feed("g-") -- go to 3
- feed("2u")
+ feed('g-') -- go to 3
+ feed('2u')
for _, s in pairs(substring) do
feed(s)
poke_eventloop()
end
- feed("<esc>")
- feed("<c-r>")
+ feed('<esc>')
+ feed('<c-r>')
expect([[
1
2]])
@@ -503,37 +502,37 @@ describe(":substitute, 'inccommand' preserves undo", function()
before_each(clear)
- it("at a non-leaf of the undo tree", function()
- for _, case in pairs(cases) do
- for _, str in pairs(substrings) do
- for _, redoable in pairs({true}) do
- test_sub(str, case, redoable)
- end
- end
- end
+ it('at a non-leaf of the undo tree', function()
+ for _, case in pairs(cases) do
+ for _, str in pairs(substrings) do
+ for _, redoable in pairs({ true }) do
+ test_sub(str, case, redoable)
+ end
+ end
+ end
end)
- it("at a leaf of the undo tree", function()
+ it('at a leaf of the undo tree', function()
for _, case in pairs(cases) do
for _, str in pairs(substrings) do
- for _, redoable in pairs({false}) do
+ for _, redoable in pairs({ false }) do
test_sub(str, case, redoable)
end
end
end
end)
- it("when interrupting substitution", function()
+ it('when interrupting substitution', function()
for _, case in pairs(cases) do
for _, str in pairs(substrings) do
- for _, redoable in pairs({true,false}) do
+ for _, redoable in pairs({ true, false }) do
test_notsub(str, case, redoable)
end
end
end
end)
- it("in a complex undo scenario", function()
+ it('in a complex undo scenario', function()
for _, case in pairs(cases) do
for _, str in pairs(substrings) do
test_threetree(str, case)
@@ -545,32 +544,32 @@ describe(":substitute, 'inccommand' preserves undo", function()
for _, case in pairs(cases) do
clear()
common_setup(nil, case, default_text)
- command("set undolevels=0")
+ command('set undolevels=0')
- feed("1G0")
- insert("X")
- feed(":%s/tw/MO/")
+ feed('1G0')
+ insert('X')
+ feed(':%s/tw/MO/')
poke_eventloop()
- feed("<esc>")
- command("undo")
+ feed('<esc>')
+ command('undo')
expect(default_text)
- command("undo")
- expect(default_text:gsub("Inc", "XInc"))
- command("undo")
+ command('undo')
+ expect(default_text:gsub('Inc', 'XInc'))
+ command('undo')
- feed(":%s/tw/MO/g")
+ feed(':%s/tw/MO/g')
poke_eventloop()
- feed("<CR>")
- expect(default_text:gsub("tw", "MO"))
- command("undo")
+ feed('<CR>')
+ expect(default_text:gsub('tw', 'MO'))
+ command('undo')
expect(default_text)
- command("undo")
- expect(default_text:gsub("tw", "MO"))
+ command('undo')
+ expect(default_text:gsub('tw', 'MO'))
end
end)
it('with undolevels=1', function()
- local screen = Screen.new(20,10)
+ local screen = Screen.new(20, 10)
for _, case in pairs(cases) do
clear()
@@ -582,35 +581,35 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|*6
|
]])
- command("set undolevels=1")
+ command('set undolevels=1')
- feed("1G0")
- insert("X")
- feed("IY<esc>")
- feed(":%s/tw/MO/")
+ feed('1G0')
+ insert('X')
+ feed('IY<esc>')
+ feed(':%s/tw/MO/')
poke_eventloop()
- feed("<esc>")
- feed("u")
- expect(default_text:gsub("Inc", "XInc"))
- feed("u")
+ feed('<esc>')
+ feed('u')
+ expect(default_text:gsub('Inc', 'XInc'))
+ feed('u')
expect(default_text)
- feed(":%s/tw/MO/g")
+ feed(':%s/tw/MO/g')
poke_eventloop()
- feed("<enter>")
- feed(":%s/MO/GO/g")
+ feed('<enter>')
+ feed(':%s/MO/GO/g')
poke_eventloop()
- feed("<enter>")
- feed(":%s/GO/NO/g")
+ feed('<enter>')
+ feed(':%s/GO/NO/g')
poke_eventloop()
- feed("<enter>")
- feed("u")
- expect(default_text:gsub("tw", "GO"))
- feed("u")
- expect(default_text:gsub("tw", "MO"))
- feed("u")
-
- if case == "split" then
+ feed('<enter>')
+ feed('u')
+ expect(default_text:gsub('tw', 'GO'))
+ feed('u')
+ expect(default_text:gsub('tw', 'MO'))
+ feed('u')
+
+ if case == 'split' then
screen:expect([[
Inc substitution on |
^MOo lines |
@@ -631,28 +630,28 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
it('with undolevels=2', function()
- local screen = Screen.new(20,10)
+ local screen = Screen.new(20, 10)
for _, case in pairs(cases) do
clear()
common_setup(screen, case, default_text)
- command("set undolevels=2")
+ command('set undolevels=2')
- feed("2GAx<esc>")
- feed("Ay<esc>")
- feed("Az<esc>")
- feed(":%s/tw/AR")
+ feed('2GAx<esc>')
+ feed('Ay<esc>')
+ feed('Az<esc>')
+ feed(':%s/tw/AR')
poke_eventloop()
- feed("<esc>")
- feed("u")
- expect(default_text:gsub("lines", "linesxy"))
- feed("u")
- expect(default_text:gsub("lines", "linesx"))
- feed("u")
+ feed('<esc>')
+ feed('u')
+ expect(default_text:gsub('lines', 'linesxy'))
+ feed('u')
+ expect(default_text:gsub('lines', 'linesx'))
+ feed('u')
expect(default_text)
- feed("u")
+ feed('u')
- if case == "split" then
+ if case == 'split' then
screen:expect([[
Inc substitution on |
two line^s |
@@ -670,27 +669,27 @@ describe(":substitute, 'inccommand' preserves undo", function()
]])
end
- feed(":%s/tw/MO/g")
+ feed(':%s/tw/MO/g')
poke_eventloop()
- feed("<enter>")
- feed(":%s/MO/GO/g")
+ feed('<enter>')
+ feed(':%s/MO/GO/g')
poke_eventloop()
- feed("<enter>")
- feed(":%s/GO/NO/g")
+ feed('<enter>')
+ feed(':%s/GO/NO/g')
poke_eventloop()
- feed("<enter>")
- feed(":%s/NO/LO/g")
+ feed('<enter>')
+ feed(':%s/NO/LO/g')
poke_eventloop()
- feed("<enter>")
- feed("u")
- expect(default_text:gsub("tw", "NO"))
- feed("u")
- expect(default_text:gsub("tw", "GO"))
- feed("u")
- expect(default_text:gsub("tw", "MO"))
- feed("u")
-
- if case == "split" then
+ feed('<enter>')
+ feed('u')
+ expect(default_text:gsub('tw', 'NO'))
+ feed('u')
+ expect(default_text:gsub('tw', 'GO'))
+ feed('u')
+ expect(default_text:gsub('tw', 'MO'))
+ feed('u')
+
+ if case == 'split' then
screen:expect([[
Inc substitution on |
^MOo lines |
@@ -711,18 +710,18 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
it('with undolevels=-1', function()
- local screen = Screen.new(20,10)
+ local screen = Screen.new(20, 10)
for _, case in pairs(cases) do
clear()
common_setup(screen, case, default_text)
- command("set undolevels=-1")
- feed(":%s/tw/MO/g")
+ command('set undolevels=-1')
+ feed(':%s/tw/MO/g')
poke_eventloop()
- feed("<enter>")
- feed("u")
- if case == "split" then
+ feed('<enter>')
+ feed('u')
+ if case == 'split' then
screen:expect([[
Inc substitution on |
^MOo lines |
@@ -744,13 +743,13 @@ describe(":substitute, 'inccommand' preserves undo", function()
clear()
common_setup(screen, case, default_text)
- command("set undolevels=-1")
- feed("1G")
- feed("IL<esc>")
- feed(":%s/tw/MO/g")
+ command('set undolevels=-1')
+ feed('1G')
+ feed('IL<esc>')
+ feed(':%s/tw/MO/g')
poke_eventloop()
- feed("<esc>")
- feed("u")
+ feed('<esc>')
+ feed('u')
screen:expect([[
^LInc substitution on|
@@ -761,21 +760,20 @@ describe(":substitute, 'inccommand' preserves undo", function()
]])
end
end)
-
end)
-describe(":substitute, inccommand=split", function()
+describe(':substitute, inccommand=split', function()
local screen
before_each(function()
clear()
- screen = Screen.new(30,15)
- common_setup(screen, "split", default_text .. default_text)
+ screen = Screen.new(30, 15)
+ common_setup(screen, 'split', default_text .. default_text)
end)
it("preserves 'modified' buffer flag", function()
- command("set nomodified")
- feed(":%s/tw")
+ command('set nomodified')
+ feed(':%s/tw')
screen:expect([[
Inc substitution on |
{12:tw}o lines |
@@ -789,22 +787,22 @@ describe(":substitute, inccommand=split", function()
{10:[Preview] }|
:%s/tw^ |
]])
- feed([[<C-\><C-N>]]) -- Cancel the :substitute command.
- eq(0, eval("&modified"))
+ feed([[<C-\><C-N>]]) -- Cancel the :substitute command.
+ eq(0, eval('&modified'))
end)
- it("shows preview when cmd modifiers are present", function()
+ it('shows preview when cmd modifiers are present', function()
-- one modifier
feed(':keeppatterns %s/tw/to')
- screen:expect{any=[[{12:to}o lines]]}
+ screen:expect { any = [[{12:to}o lines]] }
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
-- multiple modifiers
feed(':keeppatterns silent %s/tw/to')
- screen:expect{any=[[{12:to}o lines]]}
+ screen:expect { any = [[{12:to}o lines]] }
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
-- non-modifier prefix
feed(':silent tabedit %s/tw/to')
@@ -821,12 +819,12 @@ describe(":substitute, inccommand=split", function()
-- leading colons
feed(':::%s/tw/to')
- screen:expect{any=[[{12:to}o lines]]}
+ screen:expect { any = [[{12:to}o lines]] }
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
end)
- it("ignores new-window modifiers when splitting the preview window", function()
+ it('ignores new-window modifiers when splitting the preview window', function()
-- one modifier
feed(':topleft %s/tw/to')
screen:expect([[
@@ -843,7 +841,7 @@ describe(":substitute, inccommand=split", function()
:topleft %s/tw/to^ |
]])
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
-- multiple modifiers
feed(':topleft vert %s/tw/to')
@@ -861,11 +859,11 @@ describe(":substitute, inccommand=split", function()
:topleft vert %s/tw/to^ |
]])
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
end)
it('shows split window when typing the pattern', function()
- feed(":%s/tw")
+ feed(':%s/tw')
screen:expect([[
Inc substitution on |
{12:tw}o lines |
@@ -882,7 +880,7 @@ describe(":substitute, inccommand=split", function()
end)
it('shows preview with empty replacement', function()
- feed(":%s/tw/")
+ feed(':%s/tw/')
screen:expect([[
Inc substitution on |
o lines |
@@ -897,7 +895,7 @@ describe(":substitute, inccommand=split", function()
:%s/tw/^ |
]])
- feed("x")
+ feed('x')
screen:expect([[
Inc substitution on |
{12:x}o lines |
@@ -912,7 +910,7 @@ describe(":substitute, inccommand=split", function()
:%s/tw/x^ |
]])
- feed("<bs>")
+ feed('<bs>')
screen:expect([[
Inc substitution on |
o lines |
@@ -926,11 +924,10 @@ describe(":substitute, inccommand=split", function()
{10:[Preview] }|
:%s/tw/^ |
]])
-
end)
it('shows split window when typing replacement', function()
- feed(":%s/tw/XX")
+ feed(':%s/tw/XX')
screen:expect([[
Inc substitution on |
{12:XX}o lines |
@@ -947,8 +944,8 @@ describe(":substitute, inccommand=split", function()
end)
it('does not show split window for :s/', function()
- feed("2gg")
- feed(":s/tw")
+ feed('2gg')
+ feed(':s/tw')
screen:expect([[
Inc substitution on |
{12:tw}o lines |
@@ -961,8 +958,8 @@ describe(":substitute, inccommand=split", function()
end)
it("'hlsearch' is active, 'cursorline' is not", function()
- command("set hlsearch cursorline")
- feed("gg")
+ command('set hlsearch cursorline')
+ feed('gg')
-- Assert that 'cursorline' is active.
screen:expect([[
@@ -975,7 +972,7 @@ describe(":substitute, inccommand=split", function()
|
]])
- feed(":%s/tw")
+ feed(':%s/tw')
-- 'cursorline' is NOT active during preview.
screen:expect([[
Inc substitution on |
@@ -1045,9 +1042,9 @@ describe(":substitute, inccommand=split", function()
end)
it('actually replaces text', function()
- feed(":%s/tw/XX/g")
+ feed(':%s/tw/XX/g')
poke_eventloop()
- feed("<Enter>")
+ feed('<Enter>')
screen:expect([[
Inc substitution on |
@@ -1061,12 +1058,12 @@ describe(":substitute, inccommand=split", function()
end)
it('shows correct line numbers with many lines', function()
- feed("gg")
- feed("2yy")
- feed("2000p")
- command("1,1000s/tw/BB/g")
+ feed('gg')
+ feed('2yy')
+ feed('2000p')
+ command('1,1000s/tw/BB/g')
- feed(":%s/tw/X")
+ feed(':%s/tw/X')
screen:expect([[
BBo lines |
Inc substitution on |
@@ -1089,26 +1086,26 @@ describe(":substitute, inccommand=split", function()
it('does not spam the buffer numbers', function()
-- The preview buffer is re-used (unless user deleted it), so buffer numbers
-- will not increase on each keystroke.
- feed(":%s/tw/Xo/g")
+ feed(':%s/tw/Xo/g')
-- Delete and re-type the g a few times.
- feed("<BS>")
+ feed('<BS>')
poke_eventloop()
- feed("g")
+ feed('g')
poke_eventloop()
- feed("<BS>")
+ feed('<BS>')
poke_eventloop()
- feed("g")
+ feed('g')
poke_eventloop()
- feed("<CR>")
+ feed('<CR>')
poke_eventloop()
- feed(":vs tmp<enter>")
+ feed(':vs tmp<enter>')
eq(3, funcs.bufnr('$'))
end)
it('works with the n flag', function()
- feed(":%s/tw/Mix/n")
+ feed(':%s/tw/Mix/n')
poke_eventloop()
- feed("<Enter>")
+ feed('<Enter>')
screen:expect([[
Inc substitution on |
two lines |
@@ -1124,17 +1121,17 @@ describe(":substitute, inccommand=split", function()
-- prevent redraws from 'incsearch'
meths.set_option_value('incsearch', false, {})
-- Assert that 'inccommand' is ENABLED initially.
- eq("split", eval("&inccommand"))
+ eq('split', eval('&inccommand'))
-- Set 'redrawtime' to minimal value, to ensure timeout is triggered.
- command("set redrawtime=1 nowrap")
+ command('set redrawtime=1 nowrap')
-- Load a big file.
- command("silent edit! test/functional/fixtures/bigfile_oneline.txt")
+ command('silent edit! test/functional/fixtures/bigfile_oneline.txt')
-- Start :substitute with a slow pattern.
feed([[:%s/B.*N/x]])
poke_eventloop()
-- Assert that 'inccommand' is DISABLED in cmdline mode.
- eq("", eval("&inccommand"))
+ eq('', eval('&inccommand'))
-- Assert that preview cleared (or never manifested).
screen:expect([[
0000;<control>;Cc;0;BN;;;;;N;N|
@@ -1156,7 +1153,7 @@ describe(":substitute, inccommand=split", function()
-- Assert that 'inccommand' is again ENABLED after leaving cmdline mode.
feed([[<C-\><C-N>]])
- eq("split", eval("&inccommand"))
+ eq('split', eval('&inccommand'))
end)
it("deactivates if 'foldexpr' is slow #9557", function()
@@ -1192,12 +1189,12 @@ describe(":substitute, inccommand=split", function()
end)
end)
- it("clears preview if non-previewable command is edited #5585", function()
+ it('clears preview if non-previewable command is edited #5585', function()
feed('gg')
-- Put a non-previewable command in history.
feed(":echo 'foo'<CR>")
-- Start an incomplete :substitute command.
- feed(":1,2s/t/X")
+ feed(':1,2s/t/X')
screen:expect([[
Inc subs{12:X}itution on |
@@ -1214,7 +1211,7 @@ describe(":substitute, inccommand=split", function()
]])
-- Select the previous command.
- feed("<C-P>")
+ feed('<C-P>')
-- Assert that preview was cleared.
screen:expect([[
Inc substitution on |
@@ -1229,7 +1226,7 @@ describe(":substitute, inccommand=split", function()
it([[preview changes correctly with c_CTRL-R_= and c_CTRL-\_e]], function()
feed('gg')
- feed(":1,2s/t/X")
+ feed(':1,2s/t/X')
screen:expect([[
Inc subs{12:X}itution on |
{12:X}wo lines |
@@ -1304,23 +1301,22 @@ describe(":substitute, inccommand=split", function()
:echo^ |
]])
end)
-
end)
-describe("inccommand=nosplit", function()
+describe('inccommand=nosplit', function()
local screen
before_each(function()
clear()
- screen = Screen.new(20,10)
- common_setup(screen, "nosplit", default_text .. default_text)
+ screen = Screen.new(20, 10)
+ common_setup(screen, 'nosplit', default_text .. default_text)
end)
- it("works with :smagic, :snomagic", function()
- command("set hlsearch")
- insert("Line *.3.* here")
+ it('works with :smagic, :snomagic', function()
+ command('set hlsearch')
+ insert('Line *.3.* here')
- feed(":%smagic/3.*/X") -- start :smagic command
+ feed(':%smagic/3.*/X') -- start :smagic command
screen:expect([[
Inc substitution on |
two lines |
@@ -1331,8 +1327,8 @@ describe("inccommand=nosplit", function()
:%smagic/3.*/X^ |
]])
- feed([[<C-\><C-N>]]) -- cancel
- feed(":%snomagic/3.*/X") -- start :snomagic command
+ feed([[<C-\><C-N>]]) -- cancel
+ feed(':%snomagic/3.*/X') -- start :snomagic command
screen:expect([[
Inc substitution on |
two lines |
@@ -1344,18 +1340,18 @@ describe("inccommand=nosplit", function()
]])
end)
- it("shows preview when cmd modifiers are present", function()
+ it('shows preview when cmd modifiers are present', function()
-- one modifier
feed(':keeppatterns %s/tw/to')
- screen:expect{any=[[{12:to}o lines]]}
+ screen:expect { any = [[{12:to}o lines]] }
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
-- multiple modifiers
feed(':keeppatterns silent %s/tw/to')
- screen:expect{any=[[{12:to}o lines]]}
+ screen:expect { any = [[{12:to}o lines]] }
feed('<Esc>')
- screen:expect{any=[[two lines]]}
+ screen:expect { any = [[two lines]] }
-- non-modifier prefix
feed(':silent tabedit %s/tw/to')
@@ -1372,14 +1368,14 @@ describe("inccommand=nosplit", function()
]])
end)
- it("does not show window after toggling :set inccommand", function()
- feed(":%s/tw/OKOK")
- feed("<Esc>")
- command("set icm=split")
- feed(":%s/tw/OKOK")
- feed("<Esc>")
- command("set icm=nosplit")
- feed(":%s/tw/OKOK")
+ it('does not show window after toggling :set inccommand', function()
+ feed(':%s/tw/OKOK')
+ feed('<Esc>')
+ command('set icm=split')
+ feed(':%s/tw/OKOK')
+ feed('<Esc>')
+ command('set icm=nosplit')
+ feed(':%s/tw/OKOK')
poke_eventloop()
screen:expect([[
Inc substitution on |
@@ -1393,9 +1389,9 @@ describe("inccommand=nosplit", function()
end)
it('never shows preview buffer', function()
- command("set hlsearch")
+ command('set hlsearch')
- feed(":%s/tw")
+ feed(':%s/tw')
screen:expect([[
Inc substitution on |
{12:tw}o lines |
@@ -1406,7 +1402,7 @@ describe("inccommand=nosplit", function()
:%s/tw^ |
]])
- feed("/BM")
+ feed('/BM')
screen:expect([[
Inc substitution on |
{12:BM}o lines |
@@ -1417,7 +1413,7 @@ describe("inccommand=nosplit", function()
:%s/tw/BM^ |
]])
- feed("/")
+ feed('/')
screen:expect([[
Inc substitution on |
{12:BM}o lines |
@@ -1428,7 +1424,7 @@ describe("inccommand=nosplit", function()
:%s/tw/BM/^ |
]])
- feed("<enter>")
+ feed('<enter>')
screen:expect([[
Inc substitution on |
BMo lines |
@@ -1440,11 +1436,11 @@ describe("inccommand=nosplit", function()
]])
end)
- it("clears preview if non-previewable command is edited", function()
+ it('clears preview if non-previewable command is edited', function()
-- Put a non-previewable command in history.
feed(":echo 'foo'<CR>")
-- Start an incomplete :substitute command.
- feed(":1,2s/t/X")
+ feed(':1,2s/t/X')
screen:expect([[
Inc subs{12:X}itution on |
@@ -1457,7 +1453,7 @@ describe("inccommand=nosplit", function()
]])
-- Select the previous command.
- feed("<C-P>")
+ feed('<C-P>')
-- Assert that preview was cleared.
screen:expect([[
Inc substitution on |
@@ -1470,7 +1466,7 @@ describe("inccommand=nosplit", function()
]])
end)
- it("does not execute trailing bar-separated commands #7494", function()
+ it('does not execute trailing bar-separated commands #7494', function()
feed(':%s/two/three/g|q!')
screen:expect([[
Inc substitution on |
@@ -1484,7 +1480,7 @@ describe("inccommand=nosplit", function()
eq(eval('v:null'), eval('v:exiting'))
end)
- it("does not break bar-separated command #8796", function()
+ it('does not break bar-separated command #8796', function()
source([[
function! F()
if v:false | return | endif
@@ -1492,7 +1488,7 @@ describe("inccommand=nosplit", function()
]])
command('call timer_start(10, {-> F()}, {"repeat":-1})')
feed(':%s/')
- sleep(20) -- Allow some timer activity.
+ sleep(20) -- Allow some timer activity.
screen:expect([[
Inc substitution on |
two lines |
@@ -1507,21 +1503,21 @@ end)
describe(":substitute, 'inccommand' with a failing expression", function()
local screen
- local cases = { "", "split", "nosplit" }
+ local cases = { '', 'split', 'nosplit' }
local function refresh(case)
clear()
- screen = Screen.new(20,10)
+ screen = Screen.new(20, 10)
common_setup(screen, case, default_text)
end
it('in the pattern does nothing', function()
for _, case in pairs(cases) do
refresh(case)
- command("set inccommand=" .. case)
- feed(":silent! %s/tw\\(/LARD/")
+ command('set inccommand=' .. case)
+ feed(':silent! %s/tw\\(/LARD/')
poke_eventloop()
- feed("<enter>")
+ feed('<enter>')
expect(default_text)
end
end)
@@ -1529,15 +1525,15 @@ describe(":substitute, 'inccommand' with a failing expression", function()
it('in the replacement deletes the matches', function()
for _, case in pairs(cases) do
refresh(case)
- local replacements = { "\\='LARD", "\\=xx_novar__xx" }
+ local replacements = { "\\='LARD", '\\=xx_novar__xx' }
for _, repl in pairs(replacements) do
- command("set inccommand=" .. case)
- feed(":silent! %s/tw/" .. repl .. "/")
+ command('set inccommand=' .. case)
+ feed(':silent! %s/tw/' .. repl .. '/')
poke_eventloop()
- feed("<enter>")
- expect(default_text:gsub("tw", ""))
- command("undo")
+ feed('<enter>')
+ expect(default_text:gsub('tw', ''))
+ command('undo')
end
end
end)
@@ -1565,27 +1561,26 @@ describe(":substitute, 'inccommand' with a failing expression", function()
]])
end
end)
-
end)
describe("'inccommand' and :cnoremap", function()
- local cases = { "", "split", "nosplit" }
+ local cases = { '', 'split', 'nosplit' }
local screen
local function refresh(case, visual)
clear()
- screen = visual and Screen.new(80,10) or nil
+ screen = visual and Screen.new(80, 10) or nil
common_setup(screen, case, default_text)
end
it('work with remapped characters', function()
for _, case in pairs(cases) do
refresh(case)
- local cmd = "%s/lines/LINES/g"
+ local cmd = '%s/lines/LINES/g'
for i = 1, string.len(cmd) do
local c = string.sub(cmd, i, i)
- command("cnoremap ".. c .. " " .. c)
+ command('cnoremap ' .. c .. ' ' .. c)
end
feed(':' .. cmd)
@@ -1595,58 +1590,58 @@ describe("'inccommand' and :cnoremap", function()
Inc substitution on
two LINES
]])
- end
+ end
end)
it('work when mappings move the cursor', function()
for _, case in pairs(cases) do
refresh(case)
- command("cnoremap ,S LINES/<left><left><left><left><left><left>")
+ command('cnoremap ,S LINES/<left><left><left><left><left><left>')
- feed(":%s/lines/")
+ feed(':%s/lines/')
poke_eventloop()
- feed(",S")
+ feed(',S')
poke_eventloop()
- feed("or three <enter>")
+ feed('or three <enter>')
poke_eventloop()
expect([[
Inc substitution on
two or three LINES
]])
- command("cnoremap ;S /X/<left><left><left>")
- feed(":%s/")
+ command('cnoremap ;S /X/<left><left><left>')
+ feed(':%s/')
poke_eventloop()
- feed(";S")
+ feed(';S')
poke_eventloop()
- feed("I<enter>")
+ feed('I<enter>')
expect([[
Xnc substitution on
two or three LXNES
]])
- command("cnoremap ,T //Y/<left><left><left>")
- feed(":%s")
+ command('cnoremap ,T //Y/<left><left><left>')
+ feed(':%s')
poke_eventloop()
- feed(",T")
+ feed(',T')
poke_eventloop()
- feed("X<enter>")
+ feed('X<enter>')
expect([[
Ync substitution on
two or three LYNES
]])
- command("cnoremap ;T s//Z/<left><left><left>")
- feed(":%")
+ command('cnoremap ;T s//Z/<left><left><left>')
+ feed(':%')
poke_eventloop()
- feed(";T")
+ feed(';T')
poke_eventloop()
- feed("Y<enter>")
+ feed('Y<enter>')
expect([[
Znc substitution on
two or three LZNES
]])
- end
+ end
end)
it('still works with a broken mapping', function()
@@ -1654,8 +1649,8 @@ describe("'inccommand' and :cnoremap", function()
refresh(case, true)
command("cnoremap <expr> x execute('bwipeout!')[-1].'x'")
- feed(":%s/tw/tox<enter>")
- screen:expect{any=[[{14:^E565:]]}
+ feed(':%s/tw/tox<enter>')
+ screen:expect { any = [[{14:^E565:]] }
feed('<c-c>')
-- error thrown b/c of the mapping
@@ -1672,10 +1667,10 @@ describe("'inccommand' and :cnoremap", function()
refresh(case)
command("cnoremap <expr> x cursor(1, 1)[-1].'x'")
- feed(":%s/tw/tox")
+ feed(':%s/tw/tox')
poke_eventloop()
- feed("/g<enter>")
- expect(default_text:gsub("tw", "tox"))
+ feed('/g<enter>')
+ expect(default_text:gsub('tw', 'tox'))
end
end)
@@ -1684,10 +1679,10 @@ describe("'inccommand' and :cnoremap", function()
refresh(case)
command("cnoremap <expr> x execute('set inccommand=')[-1]")
- feed(":%s/tw/tox")
+ feed(':%s/tw/tox')
poke_eventloop()
- feed("a/g<enter>")
- expect(default_text:gsub("tw", "toa"))
+ feed('a/g<enter>')
+ expect(default_text:gsub('tw', 'toa'))
end
end)
@@ -1697,13 +1692,12 @@ describe("'inccommand' and :cnoremap", function()
source([[cnoremap x <C-\>eextend(g:, {'fo': getcmdline()})
\.fo<CR><C-c>:new<CR>:bw!<CR>:<C-r>=remove(g:, 'fo')<CR>x]])
- feed(":%s/tw/tox")
+ feed(':%s/tw/tox')
poke_eventloop()
- feed("/<enter>")
- expect(default_text:gsub("tw", "tox"))
+ feed('/<enter>')
+ expect(default_text:gsub('tw', 'tox'))
end
end)
-
end)
describe("'inccommand' autocommands", function()
@@ -1744,9 +1738,9 @@ describe("'inccommand' autocommands", function()
}
local function bufferlist(t)
- local s = ""
+ local s = ''
for _, buffer in pairs(t) do
- s = s .. ", " .. tostring(buffer)
+ s = s .. ', ' .. tostring(buffer)
end
return s
end
@@ -1758,12 +1752,12 @@ describe("'inccommand' autocommands", function()
end
local function register_autocmd(event)
- meths.set_var(event .. "_fired", {})
- command("autocmd " .. event .. " * call add(g:" .. event .. "_fired, expand('<abuf>'))")
+ meths.set_var(event .. '_fired', {})
+ command('autocmd ' .. event .. ' * call add(g:' .. event .. "_fired, expand('<abuf>'))")
end
it('are not fired when splitting', function()
- common_setup(nil, "split", default_text)
+ common_setup(nil, 'split', default_text)
local eventsObserved = {}
for event, _ in pairs(eventsExpected) do
@@ -1771,44 +1765,47 @@ describe("'inccommand' autocommands", function()
register_autocmd(event)
end
- feed(":%s/tw")
+ feed(':%s/tw')
for event, _ in pairs(eventsExpected) do
- eventsObserved[event].open = meths.get_var(event .. "_fired")
- meths.set_var(event .. "_fired", {})
+ eventsObserved[event].open = meths.get_var(event .. '_fired')
+ meths.set_var(event .. '_fired', {})
end
- feed("/<enter>")
+ feed('/<enter>')
for event, _ in pairs(eventsExpected) do
- eventsObserved[event].close = meths.get_var(event .. "_fired")
+ eventsObserved[event].close = meths.get_var(event .. '_fired')
end
for event, _ in pairs(eventsExpected) do
- eq(event .. bufferlist(eventsExpected[event].open),
- event .. bufferlist(eventsObserved[event].open))
- eq(event .. bufferlist(eventsExpected[event].close),
- event .. bufferlist(eventsObserved[event].close))
+ eq(
+ event .. bufferlist(eventsExpected[event].open),
+ event .. bufferlist(eventsObserved[event].open)
+ )
+ eq(
+ event .. bufferlist(eventsExpected[event].close),
+ event .. bufferlist(eventsObserved[event].close)
+ )
end
end)
-
end)
describe("'inccommand' split windows", function()
local screen
local function refresh()
clear()
- screen = Screen.new(40,30)
- common_setup(screen, "split", default_text)
+ screen = Screen.new(40, 30)
+ common_setup(screen, 'split', default_text)
end
it('work after more splits', function()
refresh()
- feed("gg")
- command("vsplit")
- command("split")
- feed(":%s/tw")
+ feed('gg')
+ command('vsplit')
+ command('split')
+ feed(':%s/tw')
screen:expect([[
Inc substitution on │Inc substitution on|
{12:tw}o lines │{12:tw}o lines |
@@ -1826,12 +1823,12 @@ describe("'inccommand' split windows", function()
:%s/tw^ |
]])
- feed("<esc>")
- command("only")
- command("split")
- command("vsplit")
+ feed('<esc>')
+ command('only')
+ command('split')
+ command('vsplit')
- feed(":%s/tw")
+ feed(':%s/tw')
screen:expect([[
Inc substitution on │Inc substitution on|
{12:tw}o lines │{12:tw}o lines |
@@ -1851,20 +1848,20 @@ describe("'inccommand' split windows", function()
end)
local settings = {
- "splitbelow",
- "splitright",
- "noequalalways",
- "equalalways eadirection=ver",
- "equalalways eadirection=hor",
- "equalalways eadirection=both",
+ 'splitbelow',
+ 'splitright',
+ 'noequalalways',
+ 'equalalways eadirection=ver',
+ 'equalalways eadirection=hor',
+ 'equalalways eadirection=both',
}
- it("are not affected by various settings", function()
+ it('are not affected by various settings', function()
for _, setting in pairs(settings) do
refresh()
- command("set " .. setting)
+ command('set ' .. setting)
- feed(":%s/tw")
+ feed(':%s/tw')
screen:expect([[
Inc substitution on |
@@ -1883,7 +1880,7 @@ describe("'inccommand' split windows", function()
it("don't open if there's not enough room", function()
refresh()
screen:try_resize(40, 3)
- feed("gg:%s/tw")
+ feed('gg:%s/tw')
screen:expect([[
Inc substitution on |
{12:tw}o lines |
@@ -1897,43 +1894,43 @@ describe("'inccommand' with 'gdefault'", function()
clear()
end)
- it("does not lock up #7244", function()
- common_setup(nil, "nosplit", "{")
- command("set gdefault")
- feed(":s/{\\n")
- eq({mode='c', blocking=false}, nvim("get_mode"))
- feed("/A<Enter>")
- expect("A")
- eq({mode='n', blocking=false}, nvim("get_mode"))
+ it('does not lock up #7244', function()
+ common_setup(nil, 'nosplit', '{')
+ command('set gdefault')
+ feed(':s/{\\n')
+ eq({ mode = 'c', blocking = false }, nvim('get_mode'))
+ feed('/A<Enter>')
+ expect('A')
+ eq({ mode = 'n', blocking = false }, nvim('get_mode'))
end)
- it("with multiline text and range, does not lock up #7244", function()
- common_setup(nil, "nosplit", "{\n\n{")
- command("set gdefault")
- feed(":%s/{\\n")
- eq({mode='c', blocking=false}, nvim("get_mode"))
- feed("/A<Enter>")
- expect("A\nA")
- eq({mode='n', blocking=false}, nvim("get_mode"))
+ it('with multiline text and range, does not lock up #7244', function()
+ common_setup(nil, 'nosplit', '{\n\n{')
+ command('set gdefault')
+ feed(':%s/{\\n')
+ eq({ mode = 'c', blocking = false }, nvim('get_mode'))
+ feed('/A<Enter>')
+ expect('A\nA')
+ eq({ mode = 'n', blocking = false }, nvim('get_mode'))
end)
- it("does not crash on zero-width matches #7485", function()
- common_setup(nil, "split", default_text)
- command("set gdefault")
- feed("gg")
- feed("Vj")
- feed(":s/\\%V")
- eq({mode='c', blocking=false}, nvim("get_mode"))
- feed("<Esc>")
- eq({mode='n', blocking=false}, nvim("get_mode"))
+ it('does not crash on zero-width matches #7485', function()
+ common_setup(nil, 'split', default_text)
+ command('set gdefault')
+ feed('gg')
+ feed('Vj')
+ feed(':s/\\%V')
+ eq({ mode = 'c', blocking = false }, nvim('get_mode'))
+ feed('<Esc>')
+ eq({ mode = 'n', blocking = false }, nvim('get_mode'))
end)
- it("removes highlights after abort for a zero-width match", function()
- local screen = Screen.new(30,5)
- common_setup(screen, "nosplit", default_text)
- command("set gdefault")
+ it('removes highlights after abort for a zero-width match', function()
+ local screen = Screen.new(30, 5)
+ common_setup(screen, 'nosplit', default_text)
+ command('set gdefault')
- feed(":%s/\\%1c/a/")
+ feed(':%s/\\%1c/a/')
screen:expect([[
{12:a}Inc substitution on |
{12:a}two lines |
@@ -1942,7 +1939,7 @@ describe("'inccommand' with 'gdefault'", function()
:%s/\%1c/a/^ |
]])
- feed("<Esc>")
+ feed('<Esc>')
screen:expect([[
Inc substitution on |
two lines |
@@ -1951,21 +1948,20 @@ describe("'inccommand' with 'gdefault'", function()
|
]])
end)
-
end)
-describe(":substitute", function()
+describe(':substitute', function()
local screen
before_each(function()
clear()
- screen = Screen.new(30,15)
+ screen = Screen.new(30, 15)
end)
- it("inccommand=split, highlights multiline substitutions", function()
- common_setup(screen, "split", multiline_text)
- feed("gg")
+ it('inccommand=split, highlights multiline substitutions', function()
+ common_setup(screen, 'split', multiline_text)
+ feed('gg')
- feed(":%s/2\\_.*X")
+ feed(':%s/2\\_.*X')
screen:expect([[
1 {12:2 3} |
{12:A B C} |
@@ -1982,7 +1978,7 @@ describe(":substitute", function()
:%s/2\_.*X^ |
]])
- feed("/MMM")
+ feed('/MMM')
screen:expect([[
1 {12:MMM} Y Z |
7 8 9 |
@@ -1995,7 +1991,7 @@ describe(":substitute", function()
:%s/2\_.*X/MMM^ |
]])
- feed("\\rK\\rLLL")
+ feed('\\rK\\rLLL')
screen:expect([[
1 {12:MMM} |
{12:K} |
@@ -2012,11 +2008,11 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, highlights multiline substitutions", function()
- common_setup(screen, "nosplit", multiline_text)
- feed("gg")
+ it('inccommand=nosplit, highlights multiline substitutions', function()
+ common_setup(screen, 'nosplit', multiline_text)
+ feed('gg')
- feed(":%s/2\\_.*X/MMM")
+ feed(':%s/2\\_.*X/MMM')
screen:expect([[
1 {12:MMM} Y Z |
7 8 9 |
@@ -2025,7 +2021,7 @@ describe(":substitute", function()
:%s/2\_.*X/MMM^ |
]])
- feed("\\rK\\rLLL")
+ feed('\\rK\\rLLL')
screen:expect([[
1 {12:MMM} |
{12:K} |
@@ -2037,12 +2033,12 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, highlights multiple matches on a line", function()
- common_setup(screen, "split", multimatch_text)
- command("set gdefault")
- feed("gg")
+ it('inccommand=split, highlights multiple matches on a line', function()
+ common_setup(screen, 'split', multimatch_text)
+ command('set gdefault')
+ feed('gg')
- feed(":%s/a/XLK")
+ feed(':%s/a/XLK')
screen:expect([[
{12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r|
x |
@@ -2057,12 +2053,12 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, highlights multiple matches on a line", function()
- common_setup(screen, "nosplit", multimatch_text)
- command("set gdefault")
- feed("gg")
+ it('inccommand=nosplit, highlights multiple matches on a line', function()
+ common_setup(screen, 'nosplit', multimatch_text)
+ command('set gdefault')
+ feed('gg')
- feed(":%s/a/XLK")
+ feed(':%s/a/XLK')
screen:expect([[
{12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r|
x |
@@ -2072,11 +2068,11 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, with \\zs", function()
- common_setup(screen, "split", multiline_text)
- feed("gg")
+ it('inccommand=split, with \\zs', function()
+ common_setup(screen, 'split', multiline_text)
+ feed('gg')
- feed(":%s/[0-9]\\n\\zs[A-Z]/OKO")
+ feed(':%s/[0-9]\\n\\zs[A-Z]/OKO')
screen:expect([[
{12:OKO} B C |
4 5 6 |
@@ -2094,11 +2090,11 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, with \\zs", function()
- common_setup(screen, "nosplit", multiline_text)
- feed("gg")
+ it('inccommand=nosplit, with \\zs', function()
+ common_setup(screen, 'nosplit', multiline_text)
+ feed('gg')
- feed(":%s/[0-9]\\n\\zs[A-Z]/OKO")
+ feed(':%s/[0-9]\\n\\zs[A-Z]/OKO')
screen:expect([[
1 2 3 |
{12:OKO} B C |
@@ -2111,10 +2107,10 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, substitutions of different length", function()
- common_setup(screen, "split", "T T123 T2T TTT T090804\nx")
+ it('inccommand=split, substitutions of different length', function()
+ common_setup(screen, 'split', 'T T123 T2T TTT T090804\nx')
- feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g")
+ feed(':%s/T\\([0-9]\\+\\)/\\1\\1/g')
screen:expect([[
T {12:123123} {12:22}T TTT {12:090804090804} |
x |
@@ -2128,10 +2124,10 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, substitutions of different length", function()
- common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx")
+ it('inccommand=nosplit, substitutions of different length', function()
+ common_setup(screen, 'nosplit', 'T T123 T2T TTT T090804\nx')
- feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g")
+ feed(':%s/T\\([0-9]\\+\\)/\\1\\1/g')
screen:expect([[
T {12:123123} {12:22}T TTT {12:090804090804} |
x |
@@ -2140,7 +2136,7 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, contraction of lines", function()
+ it('inccommand=split, contraction of lines', function()
local text = [[
T T123 T T123 T2T TT T23423424
x
@@ -2149,8 +2145,8 @@ describe(":substitute", function()
alx
]]
- common_setup(screen, "split", text)
- feed(":%s/[QR]\\n")
+ common_setup(screen, 'split', text)
+ feed(':%s/[QR]\\n')
screen:expect([[
afa {12:Q} |
adf la;lkd {12:R} |
@@ -2166,7 +2162,7 @@ describe(":substitute", function()
:%s/[QR]\n^ |
]])
- feed("/KKK")
+ feed('/KKK')
screen:expect([[
T T123 T T123 T2T TT T23423424|
x |
@@ -2181,7 +2177,7 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, contraction of lines", function()
+ it('inccommand=nosplit, contraction of lines', function()
local text = [[
T T123 T T123 T2T TT T23423424
x
@@ -2190,8 +2186,8 @@ describe(":substitute", function()
alx
]]
- common_setup(screen, "nosplit", text)
- feed(":%s/[QR]\\n/KKK")
+ common_setup(screen, 'nosplit', text)
+ feed(':%s/[QR]\\n/KKK')
screen:expect([[
T T123 T T123 T2T TT T23423424|
x |
@@ -2202,7 +2198,7 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, contraction of two subsequent NL chars", function()
+ it('inccommand=split, contraction of two subsequent NL chars', function()
local text = [[
AAA AA
@@ -2214,9 +2210,10 @@ describe(":substitute", function()
-- This used to crash, but more than 20 highlight entries are required
-- to reproduce it (so that the marktree has multiple nodes)
- common_setup(screen, "split", string.rep(text,10))
- feed(":%s/\\n\\n/<c-v><c-m>/g")
- screen:expect{grid=[[
+ common_setup(screen, 'split', string.rep(text, 10))
+ feed(':%s/\\n\\n/<c-v><c-m>/g')
+ screen:expect {
+ grid = [[
CCC CC |
AAA AA |
BBB BB |
@@ -2232,11 +2229,12 @@ describe(":substitute", function()
| 7|{12: }AAA AA |
{10:[Preview] }|
:%s/\n\n/{17:^M}/g^ |
- ]]}
+ ]],
+ }
assert_alive()
end)
- it("inccommand=nosplit, contraction of two subsequent NL chars", function()
+ it('inccommand=nosplit, contraction of two subsequent NL chars', function()
local text = [[
AAA AA
@@ -2246,9 +2244,10 @@ describe(":substitute", function()
]]
- common_setup(screen, "nosplit", string.rep(text,10))
- feed(":%s/\\n\\n/<c-v><c-m>/g")
- screen:expect{grid=[[
+ common_setup(screen, 'nosplit', string.rep(text, 10))
+ feed(':%s/\\n\\n/<c-v><c-m>/g')
+ screen:expect {
+ grid = [[
CCC CC |
AAA AA |
BBB BB |
@@ -2264,13 +2263,14 @@ describe(":substitute", function()
CCC CC |
|
:%s/\n\n/{17:^M}/g^ |
- ]]}
+ ]],
+ }
assert_alive()
end)
- it("inccommand=split, multibyte text", function()
- common_setup(screen, "split", multibyte_text)
- feed(":%s/£.*ѫ/X¥¥")
+ it('inccommand=split, multibyte text', function()
+ common_setup(screen, 'split', multibyte_text)
+ feed(':%s/£.*ѫ/X¥¥')
screen:expect([[
a{12:X¥¥}¥KOL |
£ ¥ libm |
@@ -2286,7 +2286,7 @@ describe(":substitute", function()
:%s/£.*ѫ/X¥¥^ |
]])
- feed("\\ra££ ¥")
+ feed('\\ra££ ¥')
screen:expect([[
a{12:X¥¥} |
{12:a££ ¥}¥KOL |
@@ -2306,9 +2306,9 @@ describe(":substitute", function()
]])
end)
- it("inccommand=nosplit, multibyte text", function()
- common_setup(screen, "nosplit", multibyte_text)
- feed(":%s/£.*ѫ/X¥¥")
+ it('inccommand=nosplit, multibyte text', function()
+ common_setup(screen, 'nosplit', multibyte_text)
+ feed(':%s/£.*ѫ/X¥¥')
screen:expect([[
{12:X¥¥} PEPPERS |
{12:X¥¥} |
@@ -2320,7 +2320,7 @@ describe(":substitute", function()
:%s/£.*ѫ/X¥¥^ |
]])
- feed("\\ra££ ¥")
+ feed('\\ra££ ¥')
screen:expect([[
{12:X¥¥} |
{12:a££ ¥} PEPPERS |
@@ -2336,11 +2336,11 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, small cmdwinheight", function()
- common_setup(screen, "split", long_multiline_text)
- command("set cmdwinheight=2")
+ it('inccommand=split, small cmdwinheight', function()
+ common_setup(screen, 'split', long_multiline_text)
+ command('set cmdwinheight=2')
- feed(":%s/[a-z]")
+ feed(':%s/[a-z]')
screen:expect([[
X Y Z |
7 8 9 |
@@ -2359,7 +2359,7 @@ describe(":substitute", function()
:%s/[a-z]^ |
]])
- feed("/JLKR £")
+ feed('/JLKR £')
screen:expect([[
X Y Z |
7 8 9 |
@@ -2378,7 +2378,7 @@ describe(":substitute", function()
:%s/[a-z]/JLKR £^ |
]])
- feed("\\rѫ ab \\rXXXX")
+ feed('\\rѫ ab \\rXXXX')
screen:expect([[
7 8 9 |
K L M |
@@ -2398,11 +2398,11 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, large cmdwinheight", function()
- common_setup(screen, "split", long_multiline_text)
- command("set cmdwinheight=11")
+ it('inccommand=split, large cmdwinheight', function()
+ common_setup(screen, 'split', long_multiline_text)
+ command('set cmdwinheight=11')
- feed(":%s/. .$")
+ feed(':%s/. .$')
screen:expect([[
t {12:œ ¥} |
{11:[No Name] [+] }|
@@ -2421,7 +2421,7 @@ describe(":substitute", function()
:%s/. .$^ |
]])
- feed("/ YYY")
+ feed('/ YYY')
screen:expect([[
t {12: YYY} |
{11:[No Name] [+] }|
@@ -2440,7 +2440,7 @@ describe(":substitute", function()
:%s/. .$/ YYY^ |
]])
- feed("\\r KKK")
+ feed('\\r KKK')
screen:expect([[
a {12: YYY} |
{11:[No Name] [+] }|
@@ -2460,8 +2460,8 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, lookaround", function()
- common_setup(screen, "split", "something\neverything\nsomeone")
+ it('inccommand=split, lookaround', function()
+ common_setup(screen, 'split', 'something\neverything\nsomeone')
feed([[:%s/\(some\)\@<lt>=thing/one/]])
screen:expect([[
some{12:one} |
@@ -2475,7 +2475,7 @@ describe(":substitute", function()
:%s/\(some\)\@<=thing/one/^ |
]])
- feed("<C-c>")
+ feed('<C-c>')
feed('gg')
poke_eventloop()
feed([[:%s/\(some\)\@<lt>!thing/one/]])
@@ -2524,7 +2524,7 @@ describe(":substitute", function()
it("doesn't prompt to swap cmd range", function()
screen = Screen.new(50, 8) -- wide to avoid hit-enter prompt
- common_setup(screen, "split", default_text)
+ common_setup(screen, 'split', default_text)
feed(':2,1s/tw/MO/g')
-- substitution preview should have been made, without prompting
@@ -2565,19 +2565,19 @@ it(':substitute with inccommand during :terminal activity', function()
end
retry(2, 40000, function()
clear()
- local screen = Screen.new(30,15)
+ local screen = Screen.new(30, 15)
- command("set cmdwinheight=3")
+ command('set cmdwinheight=3')
feed(([[:terminal "%s" REP 5000 xxx<cr>]]):format(testprg('shell-test')))
command('file term')
- feed('G') -- Follow :terminal output.
+ feed('G') -- Follow :terminal output.
command('new')
common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
command('wincmd =')
feed('gg')
feed(':%s/foo/ZZZ')
- sleep(20) -- Allow some terminal activity.
+ sleep(20) -- Allow some terminal activity.
poke_eventloop()
screen:sleep(0)
screen:expect_unchanged()
@@ -2586,7 +2586,7 @@ end)
it(':substitute with inccommand, timer-induced :redraw #9777', function()
clear()
- local screen = Screen.new(30,12)
+ local screen = Screen.new(30, 12)
command('set cmdwinheight=3')
command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})')
command('call timer_start(10, {-> execute("redrawstatus")}, {"repeat":-1})')
@@ -2594,7 +2594,7 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function()
feed('gg')
feed(':%s/foo/ZZZ')
- sleep(20) -- Allow some timer activity.
+ sleep(20) -- Allow some timer activity.
screen:expect([[
{12:ZZZ} bar baz |
bar baz fox |
@@ -2611,12 +2611,17 @@ end)
it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function()
clear()
- local screen = Screen.new(30,6)
+ local screen = Screen.new(30, 6)
common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
command('hi! link NormalFloat CursorLine')
local float_buf = meths.create_buf(false, true)
meths.open_win(float_buf, false, {
- relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false,
+ relative = 'editor',
+ height = 1,
+ width = 5,
+ row = 3,
+ col = 0,
+ focusable = false,
})
feed(':')
screen:expect([[
@@ -2636,7 +2641,7 @@ it(':substitute with inccommand, allows :redraw before first separator is typed
{15:~ }|
:%s^ |
]])
- meths.buf_set_lines(float_buf, 0, -1, true, {'foo'})
+ meths.buf_set_lines(float_buf, 0, -1, true, { 'foo' })
command('redraw')
screen:expect([[
foo bar baz |
@@ -2720,7 +2725,7 @@ end)
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
clear()
- local screen = Screen.new(10,5)
+ local screen = Screen.new(10, 5)
command('set undolevels=-1')
common_setup(screen, 'split', 'test')
feed(':%s/test')
@@ -2805,10 +2810,31 @@ end)
it('long :%s/ with inccommand does not collapse cmdline', function()
clear()
- local screen = Screen.new(10,5)
+ local screen = Screen.new(10, 5)
common_setup(screen, 'nosplit')
- feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
- 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A')
+ feed(
+ ':%s/AAAAAAA',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A',
+ 'A'
+ )
screen:expect([[
|
{11: }|
diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua
index 20e9dbdafa..d30575a9f9 100644
--- a/test/functional/ui/inccommand_user_spec.lua
+++ b/test/functional/ui/inccommand_user_spec.lua
@@ -236,16 +236,16 @@ describe("'inccommand' for user commands", function()
clear()
screen = Screen.new(40, 17)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Yellow1},
- [2] = {foreground = Screen.colors.Blue1, bold = true},
- [3] = {reverse = true},
- [4] = {reverse = true, bold = true},
- [5] = {foreground = Screen.colors.Blue},
+ [1] = { background = Screen.colors.Yellow1 },
+ [2] = { foreground = Screen.colors.Blue1, bold = true },
+ [3] = { reverse = true },
+ [4] = { reverse = true, bold = true },
+ [5] = { foreground = Screen.colors.Blue },
})
screen:attach()
exec_lua(setup_replace_cmd)
command('set cmdwinheight=5')
- insert[[
+ insert [[
text on line 1
more text on line 2
oh no, even more text
@@ -504,21 +504,21 @@ describe("'inccommand' with multiple buffers", function()
clear()
screen = Screen.new(40, 17)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Yellow1},
- [2] = {foreground = Screen.colors.Blue1, bold = true},
- [3] = {reverse = true},
- [4] = {reverse = true, bold = true}
+ [1] = { background = Screen.colors.Yellow1 },
+ [2] = { foreground = Screen.colors.Blue1, bold = true },
+ [3] = { reverse = true },
+ [4] = { reverse = true, bold = true },
})
screen:attach()
exec_lua(setup_replace_cmd)
command('set cmdwinheight=10')
- insert[[
+ insert [[
foo bar baz
bar baz foo
baz foo bar
]]
command('vsplit | enew')
- insert[[
+ insert [[
bar baz foo
baz foo bar
foo bar baz
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index a3ab1a4ab6..92bc6a7f76 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -15,14 +15,17 @@ before_each(clear)
describe('mappings', function()
local add_mapping = function(mapping, send)
- local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '"
- ..send:gsub('<', '<lt>').."')<cr>"
+ local cmd = 'nnoremap '
+ .. mapping
+ .. " :call rpcnotify(1, 'mapped', '"
+ .. send:gsub('<', '<lt>')
+ .. "')<cr>"
feed_command(cmd)
end
local check_mapping = function(mapping, expected)
feed(mapping)
- eq({'notification', 'mapped', {expected}}, next_msg())
+ eq({ 'notification', 'mapped', { expected } }, next_msg())
end
before_each(function()
@@ -35,26 +38,26 @@ describe('mappings', function()
add_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
add_mapping('<c-d-a>', '<c-d-a>')
add_mapping('<d-1>', '<d-1>')
- add_mapping('<khome>','<khome>')
- add_mapping('<kup>','<kup>')
- add_mapping('<kpageup>','<kpageup>')
- add_mapping('<kleft>','<kleft>')
- add_mapping('<korigin>','<korigin>')
- add_mapping('<kright>','<kright>')
- add_mapping('<kend>','<kend>')
- add_mapping('<kdown>','<kdown>')
- add_mapping('<kpagedown>','<kpagedown>')
- add_mapping('<kinsert>','<kinsert>')
- add_mapping('<kdel>','<kdel>')
- add_mapping('<kdivide>','<kdivide>')
- add_mapping('<kmultiply>','<kmultiply>')
- add_mapping('<kminus>','<kminus>')
- add_mapping('<kplus>','<kplus>')
- add_mapping('<kenter>','<kenter>')
- add_mapping('<kcomma>','<kcomma>')
- add_mapping('<kequal>','<kequal>')
- add_mapping('<f38>','<f38>')
- add_mapping('<f63>','<f63>')
+ add_mapping('<khome>', '<khome>')
+ add_mapping('<kup>', '<kup>')
+ add_mapping('<kpageup>', '<kpageup>')
+ add_mapping('<kleft>', '<kleft>')
+ add_mapping('<korigin>', '<korigin>')
+ add_mapping('<kright>', '<kright>')
+ add_mapping('<kend>', '<kend>')
+ add_mapping('<kdown>', '<kdown>')
+ add_mapping('<kpagedown>', '<kpagedown>')
+ add_mapping('<kinsert>', '<kinsert>')
+ add_mapping('<kdel>', '<kdel>')
+ add_mapping('<kdivide>', '<kdivide>')
+ add_mapping('<kmultiply>', '<kmultiply>')
+ add_mapping('<kminus>', '<kminus>')
+ add_mapping('<kplus>', '<kplus>')
+ add_mapping('<kenter>', '<kenter>')
+ add_mapping('<kcomma>', '<kcomma>')
+ add_mapping('<kequal>', '<kequal>')
+ add_mapping('<f38>', '<f38>')
+ add_mapping('<f63>', '<f63>')
end)
it('ok', function()
@@ -75,44 +78,44 @@ describe('mappings', function()
check_mapping('<c-d-a>', '<c-d-a>')
check_mapping('<d-c-a>', '<c-d-a>')
check_mapping('<d-1>', '<d-1>')
- check_mapping('<khome>','<khome>')
- check_mapping('<KP7>','<khome>')
- check_mapping('<kup>','<kup>')
- check_mapping('<KP8>','<kup>')
- check_mapping('<kpageup>','<kpageup>')
- check_mapping('<KP9>','<kpageup>')
- check_mapping('<kleft>','<kleft>')
- check_mapping('<KP4>','<kleft>')
- check_mapping('<korigin>','<korigin>')
- check_mapping('<KP5>','<korigin>')
- check_mapping('<kright>','<kright>')
- check_mapping('<KP6>','<kright>')
- check_mapping('<kend>','<kend>')
- check_mapping('<KP1>','<kend>')
- check_mapping('<kdown>','<kdown>')
- check_mapping('<KP2>','<kdown>')
- check_mapping('<kpagedown>','<kpagedown>')
- check_mapping('<KP3>','<kpagedown>')
- check_mapping('<kinsert>','<kinsert>')
- check_mapping('<KP0>','<kinsert>')
- check_mapping('<kdel>','<kdel>')
- check_mapping('<KPPeriod>','<kdel>')
- check_mapping('<kdivide>','<kdivide>')
- check_mapping('<KPDiv>','<kdivide>')
- check_mapping('<kmultiply>','<kmultiply>')
- check_mapping('<KPMult>','<kmultiply>')
- check_mapping('<kminus>','<kminus>')
- check_mapping('<KPMinus>','<kminus>')
- check_mapping('<kplus>','<kplus>')
- check_mapping('<KPPlus>','<kplus>')
- check_mapping('<kenter>','<kenter>')
- check_mapping('<KPEnter>','<kenter>')
- check_mapping('<kcomma>','<kcomma>')
- check_mapping('<KPComma>','<kcomma>')
- check_mapping('<kequal>','<kequal>')
- check_mapping('<KPEquals>','<kequal>')
- check_mapping('<f38>','<f38>')
- check_mapping('<f63>','<f63>')
+ check_mapping('<khome>', '<khome>')
+ check_mapping('<KP7>', '<khome>')
+ check_mapping('<kup>', '<kup>')
+ check_mapping('<KP8>', '<kup>')
+ check_mapping('<kpageup>', '<kpageup>')
+ check_mapping('<KP9>', '<kpageup>')
+ check_mapping('<kleft>', '<kleft>')
+ check_mapping('<KP4>', '<kleft>')
+ check_mapping('<korigin>', '<korigin>')
+ check_mapping('<KP5>', '<korigin>')
+ check_mapping('<kright>', '<kright>')
+ check_mapping('<KP6>', '<kright>')
+ check_mapping('<kend>', '<kend>')
+ check_mapping('<KP1>', '<kend>')
+ check_mapping('<kdown>', '<kdown>')
+ check_mapping('<KP2>', '<kdown>')
+ check_mapping('<kpagedown>', '<kpagedown>')
+ check_mapping('<KP3>', '<kpagedown>')
+ check_mapping('<kinsert>', '<kinsert>')
+ check_mapping('<KP0>', '<kinsert>')
+ check_mapping('<kdel>', '<kdel>')
+ check_mapping('<KPPeriod>', '<kdel>')
+ check_mapping('<kdivide>', '<kdivide>')
+ check_mapping('<KPDiv>', '<kdivide>')
+ check_mapping('<kmultiply>', '<kmultiply>')
+ check_mapping('<KPMult>', '<kmultiply>')
+ check_mapping('<kminus>', '<kminus>')
+ check_mapping('<KPMinus>', '<kminus>')
+ check_mapping('<kplus>', '<kplus>')
+ check_mapping('<KPPlus>', '<kplus>')
+ check_mapping('<kenter>', '<kenter>')
+ check_mapping('<KPEnter>', '<kenter>')
+ check_mapping('<kcomma>', '<kcomma>')
+ check_mapping('<KPComma>', '<kcomma>')
+ check_mapping('<kequal>', '<kequal>')
+ check_mapping('<KPEquals>', '<kequal>')
+ check_mapping('<f38>', '<f38>')
+ check_mapping('<f63>', '<f63>')
end)
it('support meta + multibyte char mapping', function()
@@ -262,11 +265,11 @@ it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8.
end)
it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function()
- local screen = Screen.new(60,8)
+ local screen = Screen.new(60, 8)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
- [2] = {bold = true, reverse = true}, -- MsgSeparator
- [3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
+ [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [2] = { bold = true, reverse = true }, -- MsgSeparator
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg
})
screen:attach()
command([[nnoremap <C-6> <Cmd>echo 'hit ctrl-6'<CR>]])
@@ -312,18 +315,18 @@ describe('input non-printable chars', function()
end)
it("doesn't crash when echoing them back", function()
- write_file("Xtest-overwrite", [[foobar]])
- local screen = Screen.new(60,8)
+ write_file('Xtest-overwrite', [[foobar]])
+ local screen = Screen.new(60, 8)
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue1};
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
- [3] = {bold = true, foreground = Screen.colors.SeaGreen4};
- [4] = {bold = true, reverse = true};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [4] = { bold = true, reverse = true },
}
screen:attach()
- command("set shortmess-=F")
+ command('set shortmess-=F')
- feed_command("e Xtest-overwrite")
+ feed_command('e Xtest-overwrite')
screen:expect([[
^foobar |
{1:~ }|*6
@@ -332,8 +335,8 @@ describe('input non-printable chars', function()
-- The timestamp is in second resolution, wait two seconds to be sure.
screen:sleep(2000)
- write_file("Xtest-overwrite", [[smurf]])
- feed_command("w")
+ write_file('Xtest-overwrite', [[smurf]])
+ feed_command('w')
screen:expect([[
foobar |
{1:~ }|*3
@@ -343,7 +346,7 @@ describe('input non-printable chars', function()
{3:Do you really want to write to it (y/n)?}^ |
]])
- feed("u")
+ feed('u')
screen:expect([[
foobar |
{1:~ }|*2
@@ -354,7 +357,7 @@ describe('input non-printable chars', function()
{3:Do you really want to write to it (y/n)?}^ |
]])
- feed("\005")
+ feed('\005')
screen:expect([[
foobar |
{1:~ }|
@@ -366,7 +369,7 @@ describe('input non-printable chars', function()
{3:Do you really want to write to it (y/n)?}^ |
]])
- feed("n")
+ feed('n')
screen:expect([[
foobar |
{4: }|
@@ -378,7 +381,7 @@ describe('input non-printable chars', function()
{3:Press ENTER or type command to continue}^ |
]])
- feed("<cr>")
+ feed('<cr>')
screen:expect([[
^foobar |
{1:~ }|*6
@@ -387,9 +390,14 @@ describe('input non-printable chars', function()
end)
end)
-describe("event processing and input", function()
+describe('event processing and input', function()
it('not blocked by event bursts', function()
- meths.set_keymap('', '<f2>', "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", {noremap=true})
+ meths.set_keymap(
+ '',
+ '<f2>',
+ "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>",
+ { noremap = true }
+ )
exec_lua [[
winning = false
@@ -405,9 +413,9 @@ describe("event processing and input", function()
burst(true)
]]
- eq({'notification', 'start', {}}, next_msg())
+ eq({ 'notification', 'start', {} }, next_msg())
feed '<f2>'
- eq({'notification', 'stop', {}}, next_msg())
+ eq({ 'notification', 'stop', {} }, next_msg())
end)
end)
@@ -416,8 +424,8 @@ describe('display is updated', function()
before_each(function()
screen = Screen.new(60, 8)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
- [2] = {bold = true}, -- ModeMsg
+ [1] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText
+ [2] = { bold = true }, -- ModeMsg
})
screen:attach()
end)
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index 2dcc8c5858..ca02fa6403 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -39,32 +39,33 @@ describe('Diff mode screen with 3 diffs open', function()
screen = Screen.new(100, 16)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
- [6] = {foreground = Screen.colors.Blue1, bold = true};
- [7] = {reverse = true, bold = true};
- [8] = {background = Screen.colors.Red1, bold = true};
- [10] = {foreground = Screen.colors.Brown};
- [9] = {background = Screen.colors.Plum1};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray },
+ [6] = { foreground = Screen.colors.Blue1, bold = true },
+ [7] = { reverse = true, bold = true },
+ [8] = { background = Screen.colors.Red1, bold = true },
+ [10] = { foreground = Screen.colors.Brown },
+ [9] = { background = Screen.colors.Plum1 },
})
feed('<c-w>=')
feed(':windo set nu!<cr>')
end)
- describe('setup the diff screen to look like a merge conflict with 3 files in diff mode', function()
- before_each(function()
-
- local f1 = [[
+ describe(
+ 'setup the diff screen to look like a merge conflict with 3 files in diff mode',
+ function()
+ before_each(function()
+ local f1 = [[
common line
AAA
AAA
AAA
]]
- local f2 = [[
+ local f2 = [[
common line
<<<<<<< HEAD
@@ -77,7 +78,7 @@ describe('Diff mode screen with 3 diffs open', function()
BBB
>>>>>>> branch1
]]
- local f3 = [[
+ local f3 = [[
common line
BBB
@@ -85,16 +86,16 @@ describe('Diff mode screen with 3 diffs open', function()
BBB
]]
- write_file(fname, f1, false)
- write_file(fname_2, f2, false)
- write_file(fname_3, f3, false)
- reread()
- end)
+ write_file(fname, f1, false)
+ write_file(fname_2, f2, false)
+ write_file(fname_3, f3, false)
+ reread()
+ end)
- it('get from window 1', function()
- feed('1<c-w>w')
- feed(':2,6diffget screen-1.2<cr>')
- screen:expect([[
+ it('get from window 1', function()
+ feed('1<c-w>w')
+ feed(':2,6diffget screen-1.2<cr>')
+ screen:expect([[
{1: }{10: 1 }^ │{1: }{10: 1 } │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: 3 }{9:<<<<<<< HEAD }│{1: }{10: 3 }{9:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -111,12 +112,12 @@ describe('Diff mode screen with 3 diffs open', function()
{7:<-functional-diff-screen-1.3 [+] }{3:<est-functional-diff-screen-1.2 Xtest-functional-diff-screen-1 }|
:2,6diffget screen-1.2 |
]])
- end)
+ end)
- it('get from window 2', function()
- feed('2<c-w>w')
- feed(':5,7diffget screen-1.3<cr>')
- screen:expect([[
+ it('get from window 2', function()
+ feed('2<c-w>w')
+ feed(':5,7diffget screen-1.3<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -130,12 +131,12 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<functional-diff-screen-1.2 [+] }{3:Xtest-functional-diff-screen-1 }|
:5,7diffget screen-1.3 |
]])
- end)
+ end)
- it('get from window 3', function()
- feed('3<c-w>w')
- feed(':5,6diffget screen-1.2<cr>')
- screen:expect([[
+ it('get from window 3', function()
+ feed('3<c-w>w')
+ feed(':5,6diffget screen-1.2<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 } │{1: }{10: 1 }^ |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -152,12 +153,12 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 <est-functional-diff-screen-1.2 }{7:<st-functional-diff-screen-1 [+] }|
:5,6diffget screen-1.2 |
]])
- end)
+ end)
- it('put from window 2 - part', function()
- feed('2<c-w>w')
- feed(':6,8diffput screen-1<cr>')
- screen:expect([[
+ it('put from window 2 - part', function()
+ feed('2<c-w>w')
+ feed(':6,8diffput screen-1<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -174,12 +175,11 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<est-functional-diff-screen-1.2 }{3:<st-functional-diff-screen-1 [+] }|
:6,8diffput screen-1 |
]])
-
- end)
- it('put from window 2 - part to end', function()
- feed('2<c-w>w')
- feed(':6,11diffput screen-1<cr>')
- screen:expect([[
+ end)
+ it('put from window 2 - part to end', function()
+ feed('2<c-w>w')
+ feed(':6,11diffput screen-1<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -196,9 +196,9 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<est-functional-diff-screen-1.2 }{3:<st-functional-diff-screen-1 [+] }|
:6,11diffput screen-1 |
]])
-
- end)
- end)
+ end)
+ end
+ )
end)
describe('Diff mode screen with 2 diffs open', function()
@@ -230,16 +230,16 @@ describe('Diff mode screen with 2 diffs open', function()
screen = Screen.new(100, 20)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
- [6] = {foreground = Screen.colors.Blue1, bold = true};
- [7] = {reverse = true, bold = true};
- [8] = {background = Screen.colors.Red1, bold = true};
- [10] = {foreground = Screen.colors.Brown};
- [9] = {background = Screen.colors.Plum1};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray },
+ [6] = { foreground = Screen.colors.Blue1, bold = true },
+ [7] = { reverse = true, bold = true },
+ [8] = { background = Screen.colors.Red1, bold = true },
+ [10] = { foreground = Screen.colors.Brown },
+ [9] = { background = Screen.colors.Plum1 },
})
feed('<c-w>=')
feed(':windo set nu!<cr>')
@@ -352,7 +352,6 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:4,17diffget |
]])
-
end)
it('get all from window 1', function()
feed('1<c-w>w')
@@ -757,7 +756,6 @@ something
{3:Xtest-functional-diff-screen-1.2 [+] }{7:Xtest-functional-diff-screen-1 }|
:e |
]])
-
end)
end)
describe('setup a diff with 2 files and set linematch:30', function()
@@ -949,10 +947,12 @@ something
reread()
end)
- it('enable linematch for the longest diff block by increasing the number argument passed to linematch', function()
- feed('1<c-w>w')
- -- linematch is disabled for the longest diff because it's combined line length is over 10
- screen:expect([[
+ it(
+ 'enable linematch for the longest diff block by increasing the number argument passed to linematch',
+ function()
+ feed('1<c-w>w')
+ -- linematch is disabled for the longest diff because it's combined line length is over 10
+ screen:expect([[
{1: }{10: 1 }^common line │{1: }{10: 1 }common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -974,10 +974,10 @@ something
{7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }|
:e |
]])
- -- enable it by increasing the number
- feed(":set diffopt-=linematch:10<cr>")
- feed(":set diffopt+=linematch:30<cr>")
- screen:expect([[
+ -- enable it by increasing the number
+ feed(':set diffopt-=linematch:10<cr>')
+ feed(':set diffopt+=linematch:30<cr>')
+ screen:expect([[
{1: }{10: 1 }^common line │{1: }{10: 1 }common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -999,7 +999,8 @@ something
{7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }|
:set diffopt+=linematch:30 |
]])
- end)
+ end
+ )
it('get all from second window', function()
feed('2<c-w>w')
feed(':1,12diffget<cr>')
@@ -1047,10 +1048,12 @@ something
:1,19diffget |
]])
end)
- it('get part of the non linematched diff block in window 2 line 7 - 8 (non line matched block)', function()
- feed('2<c-w>w')
- feed(':7,8diffget<cr>')
- screen:expect([[
+ it(
+ 'get part of the non linematched diff block in window 2 line 7 - 8 (non line matched block)',
+ function()
+ feed('2<c-w>w')
+ feed(':7,8diffget<cr>')
+ screen:expect([[
{1: }{10: 1 }common line │{1: }{10: 1 }^common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -1072,11 +1075,14 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:7,8diffget |
]])
- end)
- it('get part of the non linematched diff block in window 2 line 8 - 10 (line matched block)', function()
- feed('2<c-w>w')
- feed(':8,10diffget<cr>')
- screen:expect([[
+ end
+ )
+ it(
+ 'get part of the non linematched diff block in window 2 line 8 - 10 (line matched block)',
+ function()
+ feed('2<c-w>w')
+ feed(':8,10diffget<cr>')
+ screen:expect([[
{1: }{10: 1 }common line │{1: }{10: 1 }^common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -1098,7 +1104,8 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:8,10diffget |
]])
- end)
+ end
+ )
end)
end)
@@ -1111,13 +1118,13 @@ describe('regressions', function()
screen = Screen.new(100, 20)
screen:attach()
-- line must be greater than MATCH_CHAR_MAX_LEN
- helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1000)..'hello' })
+ helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1000) .. 'hello' })
helpers.exec 'vnew'
- helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' })
+ helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010) .. 'world' })
helpers.exec 'windo diffthis'
end)
- it("properly computes filler lines for hunks bigger than linematch limit", function()
+ it('properly computes filler lines for hunks bigger than linematch limit', function()
clear()
feed(':set diffopt+=linematch:10<cr>')
screen = Screen.new(100, 20)
@@ -1131,7 +1138,8 @@ describe('regressions', function()
helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' })
helpers.exec 'windo diffthis'
feed('<C-e>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }{2:------------------------------------------------}│{1: }{3:^1 }|
{1: }{2:------------------------------------------------}│{1: }{3:2 }|
{1: }{2:------------------------------------------------}│{1: }{3:3 }|
@@ -1152,12 +1160,18 @@ describe('regressions', function()
{1: }29 │{1: }{3:18 }|
{4:[No Name] [+] }{5:[No Name] [+] }|
|
- ]], attr_ids={
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey};
- [2] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1};
- [3] = {background = Screen.colors.LightBlue};
- [4] = {reverse = true};
- [5] = {reverse = true, bold = true};
- }}
+ ]],
+ attr_ids = {
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey },
+ [2] = {
+ bold = true,
+ background = Screen.colors.LightCyan,
+ foreground = Screen.colors.Blue1,
+ },
+ [3] = { background = Screen.colors.LightBlue },
+ [4] = { reverse = true },
+ [5] = { reverse = true, bold = true },
+ },
+ }
end)
end)
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 85895b2c36..2a402437fd 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -27,18 +27,18 @@ describe('ui/ext_messages', function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true})
+ screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true })
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {bold = true},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {foreground = Screen.colors.Blue1},
- [6] = {bold = true, reverse = true},
- [7] = {background = Screen.colors.Yellow},
- [8] = {foreground = Screen.colors.Red},
- [9] = {special = Screen.colors.Red, undercurl = true},
- [10] = {foreground = Screen.colors.Brown};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { foreground = Screen.colors.Blue1 },
+ [6] = { bold = true, reverse = true },
+ [7] = { background = Screen.colors.Yellow },
+ [8] = { foreground = Screen.colors.Red },
+ [9] = { special = Screen.colors.Red, undercurl = true },
+ [10] = { foreground = Screen.colors.Brown },
})
end)
after_each(function()
@@ -48,19 +48,26 @@ describe('ui/ext_messages', function()
it('msg_clear follows msg_show kind of confirm', function()
feed('iline 1<esc>')
feed(':call confirm("test")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line ^1 |
{1:~ }|*4
- ]], messages={ {
- content = {{"\ntest\n[O]k: ", 4}},
- kind = 'confirm',
- }}}
+ ]],
+ messages = {
+ {
+ content = { { '\ntest\n[O]k: ', 4 } },
+ kind = 'confirm',
+ },
+ },
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line ^1 |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function()
@@ -68,246 +75,335 @@ describe('ui/ext_messages', function()
-- kind=confirm
feed(':echo confirm("test")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line 1 |
line ^2 |
{1:~ }|*3
- ]], messages={ {
- content = {{"\ntest\n[O]k: ", 4}},
- kind = 'confirm',
- }}}
+ ]],
+ messages = {
+ {
+ content = { { '\ntest\n[O]k: ', 4 } },
+ kind = 'confirm',
+ },
+ },
+ }
feed('<cr><cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line 1 |
line ^2 |
{1:~ }|*3
- ]], messages={ {
- content = { { "\ntest\n[O]k: ", 4 } },
- kind = "confirm"
- }, {
- content = { { "1" } },
- kind = "echo"
- }, {
- content = { { "Press ENTER or type command to continue", 4 } },
- kind = "return_prompt"
- } }}
+ ]],
+ messages = {
+ {
+ content = { { '\ntest\n[O]k: ', 4 } },
+ kind = 'confirm',
+ },
+ {
+ content = { { '1' } },
+ kind = 'echo',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
feed('<cr><cr>')
-- kind=confirm_sub
feed(':%s/i/X/gc<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
l{7:i}ne 1 |
l{8:i}ne ^2 |
{1:~ }|*3
- ]], attr_ids={
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {bold = true},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {foreground = Screen.colors.Blue1},
- [6] = {bold = true, reverse = true},
- [7] = {reverse = true},
- [8] = {background = Screen.colors.Yellow},
- }, messages={ {
- content = { { "replace with X (y/n/a/q/l/^E/^Y)?", 4 } },
- kind = "confirm_sub"
- } }}
+ ]],
+ attr_ids = {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { foreground = Screen.colors.Blue1 },
+ [6] = { bold = true, reverse = true },
+ [7] = { reverse = true },
+ [8] = { background = Screen.colors.Yellow },
+ },
+ messages = {
+ {
+ content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 4 } },
+ kind = 'confirm_sub',
+ },
+ },
+ }
feed('nq')
-- kind=wmsg (editing readonly file)
command('write ' .. fname)
command('set readonly nohls')
feed('G$x')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line 1 |
{MATCH:.*}|
{1:~ }|*3
- ]], attr_ids={
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {foreground = Screen.colors.Red},
- }, messages={ {
- content = { { "W10: Warning: Changing a readonly file", 7 } },
- kind = "wmsg"
- }
- }}
+ ]],
+ attr_ids = {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [7] = { foreground = Screen.colors.Red },
+ },
+ messages = {
+ {
+ content = { { 'W10: Warning: Changing a readonly file', 7 } },
+ kind = 'wmsg',
+ },
+ },
+ }
-- kind=wmsg ('wrapscan' after search reaches EOF)
feed('uG$/i<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
l^ine 1 |
line 2 |
{1:~ }|*3
- ]], attr_ids={
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {bold = true},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {foreground = Screen.colors.Blue1},
- [6] = {bold = true, reverse = true},
- [7] = {foreground = Screen.colors.Red},
- }, messages={ {
- content = { { "search hit BOTTOM, continuing at TOP", 7 } },
- kind = "wmsg"
- } }}
+ ]],
+ attr_ids = {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { foreground = Screen.colors.Blue1 },
+ [6] = { bold = true, reverse = true },
+ [7] = { foreground = Screen.colors.Red },
+ },
+ messages = {
+ {
+ content = { { 'search hit BOTTOM, continuing at TOP', 7 } },
+ kind = 'wmsg',
+ },
+ },
+ }
-- kind=emsg after :throw
feed(':throw "foo"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
l^ine 1 |
line 2 |
{1:~ }|*3
- ]], messages={ {
- content = { { "Error detected while processing :", 2 } },
- kind = "emsg"
- }, {
- content = { { "E605: Exception not caught: foo", 2 } },
- kind = ""
- }, {
- content = { { "Press ENTER or type command to continue", 4 } },
- kind = "return_prompt"
- } }
+ ]],
+ messages = {
+ {
+ content = { { 'Error detected while processing :', 2 } },
+ kind = 'emsg',
+ },
+ {
+ content = { { 'E605: Exception not caught: foo', 2 } },
+ kind = '',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
}
-- kind=quickfix after :cnext
feed('<c-c>')
command("caddexpr [expand('%').':1:line1',expand('%').':2:line2']")
feed(':cnext<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
line 1 |
^line 2 |
{1:~ }|*3
- ]], messages={ {
- content = { { "(2 of 2): line2" } },
- kind = "quickfix"
- } }}
+ ]],
+ messages = {
+ {
+ content = { { '(2 of 2): line2' } },
+ kind = 'quickfix',
+ },
+ },
+ }
end)
it(':echoerr', function()
feed(':echoerr "raa"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{"raa", 2}},
- kind = "echoerr",
- }}}
+ ]],
+ messages = { {
+ content = { { 'raa', 2 } },
+ kind = 'echoerr',
+ } },
+ }
-- cmdline in a later input cycle clears error message
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], cmdline={{
- firstc = ":",
- content = {{ "" }},
- pos = 0,
- }}}
-
+ ]],
+ cmdline = { {
+ firstc = ':',
+ content = { { '' } },
+ pos = 0,
+ } },
+ }
feed('echoerr "bork" | echoerr "fail"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "bork", 2 }},
- kind = "echoerr"
- }, {
- content = {{ "fail", 2 }},
- kind = "echoerr"
- }, {
- content = {{ "Press ENTER or type command to continue", 4 }},
- kind = "return_prompt"
- }}}
+ ]],
+ messages = {
+ {
+ content = { { 'bork', 2 } },
+ kind = 'echoerr',
+ },
+ {
+ content = { { 'fail', 2 } },
+ kind = 'echoerr',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
feed(':echoerr "extrafail"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = { { "bork", 2 } },
- kind = "echoerr"
- }, {
- content = { { "fail", 2 } },
- kind = "echoerr"
- }, {
- content = { { "extrafail", 2 } },
- kind = "echoerr"
- }, {
- content = { { "Press ENTER or type command to continue", 4 } },
- kind = "return_prompt"
- }}}
+ ]],
+ messages = {
+ {
+ content = { { 'bork', 2 } },
+ kind = 'echoerr',
+ },
+ {
+ content = { { 'fail', 2 } },
+ kind = 'echoerr',
+ },
+ {
+ content = { { 'extrafail', 2 } },
+ kind = 'echoerr',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
-- cmdline without interleaving wait/display keeps the error message
feed(':echoerr "problem" | let x = input("foo> ")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "problem", 2 }},
- kind = "echoerr"
- }}, cmdline={{
- prompt = "foo> ",
- content = {{ "" }},
- pos = 0,
- }}}
+ ]],
+ messages = { {
+ content = { { 'problem', 2 } },
+ kind = 'echoerr',
+ } },
+ cmdline = {
+ {
+ prompt = 'foo> ',
+ content = { { '' } },
+ pos = 0,
+ },
+ },
+ }
feed('solution<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
eq('solution', eval('x'))
- feed(":messages<cr>")
- screen:expect{grid=[[
+ feed(':messages<cr>')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], msg_history={
- {kind="echoerr", content={{"raa", 2}}},
- {kind="echoerr", content={{"bork", 2}}},
- {kind="echoerr", content={{"fail", 2}}},
- {kind="echoerr", content={{"extrafail", 2}}},
- {kind="echoerr", content={{"problem", 2}}}
- }, messages={{
- content = {{ "Press ENTER or type command to continue", 4 }},
- kind = "return_prompt"
- }}}
+ ]],
+ msg_history = {
+ { kind = 'echoerr', content = { { 'raa', 2 } } },
+ { kind = 'echoerr', content = { { 'bork', 2 } } },
+ { kind = 'echoerr', content = { { 'fail', 2 } } },
+ { kind = 'echoerr', content = { { 'extrafail', 2 } } },
+ { kind = 'echoerr', content = { { 'problem', 2 } } },
+ },
+ messages = {
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
feed '<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it(':echoerr multiline', function()
exec_lua([[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]])
feed(':echoerr g:multi<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "bork\nfail", 2 }},
- kind = "echoerr"
- }}}
+ ]],
+ messages = { {
+ content = { { 'bork\nfail', 2 } },
+ kind = 'echoerr',
+ } },
+ }
feed(':messages<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "Press ENTER or type command to continue", 4 }},
- kind = "return_prompt"
- }}, msg_history={{
- content = {{ "bork\nfail", 2 }},
- kind = "echoerr"
- }}}
+ ]],
+ messages = {
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ msg_history = {
+ {
+ content = { { 'bork\nfail', 2 } },
+ kind = 'echoerr',
+ },
+ },
+ }
end)
it('shortmess-=S', function()
@@ -315,151 +411,213 @@ describe('ui/ext_messages', function()
feed('iline 1\nline 2<esc>')
feed('/line<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:^line} 1 |
{7:line} 2 |
{1:~ }|*3
- ]], messages={
- {content = {{"/line W [1/2]"}}, kind = "search_count"}
- }}
+ ]],
+ messages = {
+ { content = { { '/line W [1/2]' } }, kind = 'search_count' },
+ },
+ }
feed('n')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:line} 1 |
{7:^line} 2 |
{1:~ }|*3
- ]], messages={
- {content = {{"/line [2/2]"}}, kind = "search_count"}
- }}
+ ]],
+ messages = {
+ { content = { { '/line [2/2]' } }, kind = 'search_count' },
+ },
+ }
end)
it(':hi Group output', function()
feed(':hi ErrorMsg<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={
- {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "},
- {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " },
- {"guifg=", 5 }, { "White " }, { "guibg=", 5 }, { "Red" }},
- kind = ""}
- }}
+ ]],
+ messages = {
+ {
+ content = {
+ { '\nErrorMsg ' },
+ { 'xxx', 2 },
+ { ' ' },
+ { 'ctermfg=', 5 },
+ { '15 ' },
+ { 'ctermbg=', 5 },
+ { '1 ' },
+ { 'guifg=', 5 },
+ { 'White ' },
+ { 'guibg=', 5 },
+ { 'Red' },
+ },
+ kind = '',
+ },
+ },
+ }
end)
it("doesn't crash with column adjustment #10069", function()
feed(':let [x,y] = [1,2]<cr>')
feed(':let x y<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={
- {content = {{ "x #1" }}, kind = ""},
- {content = {{ "y #2" }}, kind = ""},
- {content = {{ "Press ENTER or type command to continue", 4 }}, kind = "return_prompt"}
- }}
+ ]],
+ messages = {
+ { content = { { 'x #1' } }, kind = '' },
+ { content = { { 'y #2' } }, kind = '' },
+ { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' },
+ },
+ }
end)
it('&showmode', function()
command('imap <f2> <cmd>echomsg "stuff"<cr>')
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={{"-- INSERT --", 3}}}
+ ]],
+ showmode = { { '-- INSERT --', 3 } },
+ }
feed('alphpabet<cr>alphanum<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
^ |
{1:~ }|*2
- ]], showmode={ { "-- INSERT --", 3 } }}
+ ]],
+ showmode = { { '-- INSERT --', 3 } },
+ }
feed('<c-x>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
^ |
{1:~ }|*2
- ]], showmode={ { "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)", 3 } }}
+ ]],
+ showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 3 } },
+ }
feed('<c-p>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
alphanum^ |
{1:~ }|*2
- ]], popupmenu={
- anchor = { 1, 2, 0 },
- items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
- pos = 1
- }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }}
+ ]],
+ popupmenu = {
+ anchor = { 1, 2, 0 },
+ items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
+ pos = 1,
+ },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } },
+ }
-- echomsg and showmode don't overwrite each other, this is the same
-- as the TUI behavior with cmdheight=2 or larger.
feed('<f2>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
alphanum^ |
{1:~ }|*2
- ]], popupmenu={
- anchor = { 1, 2, 0 },
- items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
- pos = 1
- }, messages={ {
- content = { { "stuff" } },
- kind = "echomsg"
- } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }}
+ ]],
+ popupmenu = {
+ anchor = { 1, 2, 0 },
+ items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
+ pos = 1,
+ },
+ messages = { {
+ content = { { 'stuff' } },
+ kind = 'echomsg',
+ } },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } },
+ }
feed('<c-p>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
alphpabet^ |
{1:~ }|*2
- ]], popupmenu={
- anchor = { 1, 2, 0 },
- items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
- pos = 0
- }, messages={ {
- content = { { "stuff" } },
- kind = "echomsg"
- } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 2 of 2", 4 } }}
-
- feed("<esc>:messages<cr>")
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ anchor = { 1, 2, 0 },
+ items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
+ pos = 0,
+ },
+ messages = { {
+ content = { { 'stuff' } },
+ kind = 'echomsg',
+ } },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 2 of 2', 4 } },
+ }
+
+ feed('<esc>:messages<cr>')
+ screen:expect {
+ grid = [[
alphpabet |
alphanum |
alphpabe^t |
{1:~ }|*2
- ]], msg_history={{
- content = {{ "stuff" }},
- kind = "echomsg",
- }}, messages={{
- content = {{ "Press ENTER or type command to continue", 4}},
- kind = "return_prompt"
- }}}
+ ]],
+ msg_history = { {
+ content = { { 'stuff' } },
+ kind = 'echomsg',
+ } },
+ messages = {
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
end)
it('&showmode with macro-recording message', function()
feed('qq')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "recording @q", 3 } }}
+ ]],
+ showmode = { { 'recording @q', 3 } },
+ }
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "-- INSERT --recording @q", 3 } }}
+ ]],
+ showmode = { { '-- INSERT --recording @q', 3 } },
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "recording @q", 3 } }}
+ ]],
+ showmode = { { 'recording @q', 3 } },
+ }
feed('q')
screen:expect([[
@@ -469,84 +627,127 @@ describe('ui/ext_messages', function()
end)
it('shows macro-recording message with &noshowmode', function()
- command("set noshowmode")
+ command('set noshowmode')
feed('qq')
-- also check mode to avoid immediate success
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "recording @q", 3 } }, mode="normal"}
+ ]],
+ showmode = { { 'recording @q', 3 } },
+ mode = 'normal',
+ }
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "recording @q", 3 } }, mode="insert"}
+ ]],
+ showmode = { { 'recording @q', 3 } },
+ mode = 'insert',
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "recording @q", 3 } }, mode="normal"}
+ ]],
+ showmode = { { 'recording @q', 3 } },
+ mode = 'normal',
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
it('supports &showcmd and &ruler', function()
command('set showcmd ruler')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], ruler={ { "0,0-1 All" } }}
+ ]],
+ ruler = { { '0,0-1 All' } },
+ }
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], showmode={ { "-- INSERT --", 3 } }, ruler={ { "0,1 All" } }}
+ ]],
+ showmode = { { '-- INSERT --', 3 } },
+ ruler = { { '0,1 All' } },
+ }
feed('abcde<cr>12345<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
1234^5 |
{1:~ }|*3
- ]], ruler={ { "2,5 All" } }}
+ ]],
+ ruler = { { '2,5 All' } },
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
1234^5 |
{1:~ }|*3
- ]], showcmd={ { "d" } }, ruler={ { "2,5 All" } }}
+ ]],
+ showcmd = { { 'd' } },
+ ruler = { { '2,5 All' } },
+ }
feed('<esc>^')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
^12345 |
{1:~ }|*3
- ]], ruler={ { "2,1 All" } }}
+ ]],
+ ruler = { { '2,1 All' } },
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
^12345 |
{1:~ }|*3
- ]], showcmd={ { "d" } }, ruler={ { "2,1 All" } }}
+ ]],
+ showcmd = { { 'd' } },
+ ruler = { { '2,1 All' } },
+ }
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
^12345 |
{1:~ }|*3
- ]], showcmd={ { "di" } }, ruler={ { "2,1 All" } }}
+ ]],
+ showcmd = { { 'di' } },
+ ruler = { { '2,1 All' } },
+ }
feed('w')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
abcde |
^ |
{1:~ }|*3
- ]], ruler={ { "2,0-1 All" } }}
+ ]],
+ ruler = { { '2,0-1 All' } },
+ }
-- when ruler is part of statusline it is not externalized.
-- this will be added as part of future ext_statusline support
- command("set laststatus=2")
+ command('set laststatus=2')
screen:expect([[
abcde |
^ |
@@ -557,75 +758,108 @@ describe('ui/ext_messages', function()
it('keeps history of message of different kinds', function()
feed(':echomsg "howdy"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "howdy" }}, kind = "echomsg"}
- }}
+ ]],
+ messages = { {
+ content = { { 'howdy' } },
+ kind = 'echomsg',
+ } },
+ }
-- always test a message without kind. If this one gets promoted to a
-- category, add a new message without kind.
feed('<c-c>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "Type :qa and press <Enter> to exit Nvim" }},
- kind = ""}
- }}
+ ]],
+ messages = {
+ {
+ content = { { 'Type :qa and press <Enter> to exit Nvim' } },
+ kind = '',
+ },
+ },
+ }
feed(':echoerr "bork"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "bork", 2 }}, kind = "echoerr"}
- }}
+ ]],
+ messages = { {
+ content = { { 'bork', 2 } },
+ kind = 'echoerr',
+ } },
+ }
feed(':echo "xyz"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "xyz" }}, kind = "echo"}
- }}
+ ]],
+ messages = { {
+ content = { { 'xyz' } },
+ kind = 'echo',
+ } },
+ }
feed(':call nosuchfunction()<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{ "E117: Unknown function: nosuchfunction", 2 }},
- kind = "emsg"}
- }}
+ ]],
+ messages = {
+ {
+ content = { { 'E117: Unknown function: nosuchfunction', 2 } },
+ kind = 'emsg',
+ },
+ },
+ }
feed(':messages<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], msg_history={
- {kind="echomsg", content={{"howdy"}}},
- {kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}},
- {kind="echoerr", content={{"bork", 2}}},
- {kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}}
- }, messages={{
- content = {{ "Press ENTER or type command to continue", 4}},
- kind = "return_prompt"
- }}}
+ ]],
+ msg_history = {
+ { kind = 'echomsg', content = { { 'howdy' } } },
+ { kind = '', content = { { 'Type :qa and press <Enter> to exit Nvim' } } },
+ { kind = 'echoerr', content = { { 'bork', 2 } } },
+ { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 2 } } },
+ },
+ messages = {
+ {
+ content = { { 'Press ENTER or type command to continue', 4 } },
+ kind = 'return_prompt',
+ },
+ },
+ }
end)
it('implies ext_cmdline and ignores cmdheight', function()
eq(0, eval('&cmdheight'))
feed(':set cmdheight=1')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], cmdline={{
- content = { { "set cmdheight=1" } },
- firstc = ":",
- pos = 15 }
- }}
+ ]],
+ cmdline = {
+ {
+ content = { { 'set cmdheight=1' } },
+ firstc = ':',
+ pos = 15,
+ },
+ },
+ }
feed('<cr>')
screen:expect([[
@@ -635,14 +869,19 @@ describe('ui/ext_messages', function()
eq(0, eval('&cmdheight'))
feed(':set cmdheight=0')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], cmdline={{
- content = { { "set cmdheight=0" } },
- firstc = ":",
- pos = 15 }
- }}
+ ]],
+ cmdline = {
+ {
+ content = { { 'set cmdheight=0' } },
+ firstc = ':',
+ pos = 15,
+ },
+ },
+ }
feed('<cr>')
screen:expect([[
^ |
@@ -653,34 +892,52 @@ describe('ui/ext_messages', function()
it('supports multiline messages from lua', function()
feed(':lua error("such\\nmultiline\\nerror")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{[[E5108: Error executing lua [string ":lua"]:1: such
+ ]],
+ messages = {
+ {
+ content = {
+ {
+ [[E5108: Error executing lua [string ":lua"]:1: such
multiline
error
stack traceback:
[C]: in function 'error'
- [string ":lua"]:1: in main chunk]], 2}},
- kind = "lua_error",
- }}}
+ [string ":lua"]:1: in main chunk]],
+ 2,
+ },
+ },
+ kind = 'lua_error',
+ },
+ },
+ }
end)
it('supports multiline messages from rpc', function()
feed(':call rpcrequest(1, "test_method")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={{
- content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}},
- kind = "rpc_error"
- }}, request_cb=function (name)
- if name == "test_method" then
- set_method_error("complete\nerror\n\nmessage")
- end
- end}
+ ]],
+ messages = {
+ {
+ content = {
+ { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2 },
+ },
+ kind = 'rpc_error',
+ },
+ },
+ request_cb = function(name)
+ if name == 'test_method' then
+ set_method_error('complete\nerror\n\nmessage')
+ end
+ end,
+ }
end)
it('supports multiline messages for :map', function()
@@ -690,10 +947,18 @@ stack traceback:
command('nnoremap j k')
feed(':map<cr>')
- screen:expect{messages={{
- content = {{ "\nn Q @@\nn Y y$\nn j " }, { "*", 5 }, { " k" }},
- kind = ''
- }}}
+ screen:expect {
+ messages = {
+ {
+ content = {
+ { '\nn Q @@\nn Y y$\nn j ' },
+ { '*', 5 },
+ { ' k' },
+ },
+ kind = '',
+ },
+ },
+ }
end)
it('wildmode=list', function()
@@ -702,18 +967,23 @@ stack traceback:
command('set wildmenu wildmode=list')
feed(':set wildm<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*6
- ]], messages={{
- content = {{'wildmenu wildmode'}},
+ ]],
+ messages = { {
+ content = { { 'wildmenu wildmode' } },
kind = '',
- }},
- cmdline={{
- firstc = ':',
- content = {{ 'set wildm' }},
- pos = 9,
- }}}
+ } },
+ cmdline = {
+ {
+ firstc = ':',
+ content = { { 'set wildm' } },
+ pos = 9,
+ },
+ },
+ }
end)
it('hides prompt_for_number messages', function()
@@ -721,70 +991,110 @@ stack traceback:
feed('ihelllo<esc>')
feed('z=')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:helllo} |
{1:~ }|*3
{1:^~ }|
- ]], messages={
- {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""}
- }}
+ ]],
+ messages = {
+ {
+ content = {
+ {
+ 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
+ kind = '',
+ },
+ },
+ }
feed('1')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{9:helllo} |
{1:~ }|*3
{1:^~ }|
- ]], messages={
- {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""},
- { content = { { "1" } }, kind = "" }
- }}
+ ]],
+ messages = {
+ {
+ content = {
+ {
+ 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
+ kind = '',
+ },
+ { content = { { '1' } }, kind = '' },
+ },
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^Hello |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it('supports nvim_echo messages with multiple attrs', function()
- async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {})
- screen:expect{grid=[[
+ async_meths.echo(
+ { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } },
+ true,
+ {}
+ )
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={
- { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" }
- }}
+ ]],
+ messages = {
+ { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' },
+ },
+ }
feed ':ls<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={
- { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = "" }
- }}
+ ]],
+ messages = {
+ { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' },
+ },
+ }
feed ':messages<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]], messages={
- { content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" }
- }, msg_history={
- { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" }
- }}
+ ]],
+ messages = {
+ { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' },
+ },
+ msg_history = {
+ { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' },
+ },
+ }
feed '<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
end)
it('does not truncate messages', function()
- command('write '.. fname)
- screen:expect({messages={
- {content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = "" }
- }})
+ command('write ' .. fname)
+ screen:expect({
+ messages = {
+ { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' },
+ },
+ })
end)
end)
@@ -793,26 +1103,27 @@ describe('ui/builtin messages', function()
before_each(function()
clear()
screen = Screen.new(60, 7)
- screen:attach({rgb=true, ext_popupmenu=true})
- screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue1};
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
- [3] = {bold = true, reverse = true};
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4};
- [5] = {foreground = Screen.colors.Blue1};
- [6] = {bold = true, foreground = Screen.colors.Magenta};
- [7] = {background = Screen.colors.Grey20};
- [8] = {reverse = true};
- [9] = {background = Screen.colors.LightRed};
- [10] = {background = Screen.colors.Yellow};
- [11] = {foreground = Screen.colors.Brown};
+ screen:attach({ rgb = true, ext_popupmenu = true })
+ screen:set_default_attr_ids {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true, reverse = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { foreground = Screen.colors.Blue1 },
+ [6] = { bold = true, foreground = Screen.colors.Magenta },
+ [7] = { background = Screen.colors.Grey20 },
+ [8] = { reverse = true },
+ [9] = { background = Screen.colors.LightRed },
+ [10] = { background = Screen.colors.Yellow },
+ [11] = { foreground = Screen.colors.Brown },
}
end)
it('supports multiline messages from rpc', function()
feed(':call rpcrequest(1, "test_method")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3: }|
{2:Error invoking 'test_method' on channel 1:} |
{2:complete} |
@@ -820,15 +1131,17 @@ describe('ui/builtin messages', function()
|
{2:message} |
{4:Press ENTER or type command to continue}^ |
- ]], request_cb=function (name)
- if name == "test_method" then
- set_method_error("complete\nerror\n\nmessage")
- end
- end}
+ ]],
+ request_cb = function(name)
+ if name == 'test_method' then
+ set_method_error('complete\nerror\n\nmessage')
+ end
+ end,
+ }
end)
it(':hi Group output', function()
- screen:try_resize(70,7)
+ screen:try_resize(70, 7)
feed(':hi ErrorMsg<cr>')
screen:expect([[
|
@@ -840,7 +1153,7 @@ describe('ui/builtin messages', function()
]])
feed('<cr>')
- screen:try_resize(30,7)
+ screen:try_resize(30, 7)
feed(':hi ErrorMsg<cr>')
screen:expect([[
:hi ErrorMsg |
@@ -854,14 +1167,13 @@ describe('ui/builtin messages', function()
feed('<cr>')
-- screen size doesn't affect internal output #10285
- eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
- exec_capture("hi ErrorMsg"))
+ eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', exec_capture('hi ErrorMsg'))
end)
it(':syntax list langGroup output', function()
- command("syntax on")
- command("set syntax=vim")
- screen:try_resize(110,7)
+ command('syntax on')
+ command('set syntax=vim')
+ screen:try_resize(110, 7)
feed(':syntax list vimComment<cr>')
screen:expect([[
{6:--- Syntax items ---} |
@@ -874,7 +1186,7 @@ describe('ui/builtin messages', function()
]])
feed('<cr>')
- screen:try_resize(55,7)
+ screen:try_resize(55, 7)
feed(':syntax list vimComment<cr>')
screen:expect([[
|
@@ -889,12 +1201,14 @@ describe('ui/builtin messages', function()
-- ignore final whitespace inside string
-- luacheck: push ignore
- eq([[--- Syntax items ---
+ eq(
+ [[--- Syntax items ---
vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vimCommentGroup,vimCommentString
match /\<endif\s\+".*$/ms=s+5,lc=5 contains=@vimCommentGroup,vimCommentString
match /\<else\s\+".*$/ms=s+4,lc=4 contains=@vimCommentGroup,vimCommentString
links to Comment]],
- exec_capture('syntax list vimComment'))
+ exec_capture('syntax list vimComment')
+ )
-- luacheck: pop
end)
@@ -914,74 +1228,91 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
endfunc
]])
feed(':call T1()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
message T1 |
- ]]}
+ ]],
+ }
feed(':call T2()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
message T2 |
- ]]}
+ ]],
+ }
feed(':call T3()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
message T3 |
- ]]}
+ ]],
+ }
end)
it('supports ruler with laststatus=0', function()
- command("set ruler laststatus=0")
- screen:expect{grid=[[
+ command('set ruler laststatus=0')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
0,0-1 All |
- ]]}
+ ]],
+ }
- command("hi MsgArea guibg=#333333")
- screen:expect{grid=[[
+ command('hi MsgArea guibg=#333333')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
{7: 0,0-1 All }|
- ]]}
+ ]],
+ }
- command("set rulerformat=%15(%c%V\\ %p%%%)")
- screen:expect{grid=[[
+ command('set rulerformat=%15(%c%V\\ %p%%%)')
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
{7: 0,0-1 100% }|
- ]]}
+ ]],
+ }
end)
it('supports echo with CRLF line separators', function()
feed(':echo "line 1\\r\\nline 2"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3: }|
line 1 |
line 2 |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed('<cr>:echo "abc\\rz"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
zbc |
- ]]}
+ ]],
+ }
end)
it('redraws UPD_NOT_VALID correctly after message', function()
-- edge case: only one window was set UPD_NOT_VALID. Original report
-- used :make, but fake it using one command to set the current
-- window UPD_NOT_VALID and another to show a long message.
- command("set more")
+ command('set more')
feed(':new<cr><c-w><c-w>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{8:[No Name] }|
@@ -989,10 +1320,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{1:~ }|
{3:[No Name] }|
:new |
- ]]}
+ ]],
+ }
feed(':set colorcolumn=10 | digraphs<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
:set colorcolumn=10 | digraphs |
NU {5:^@} 10 SH {5:^A} 1 SX {5:^B} 2 EX {5:^C} 3 |
ET {5:^D} 4 EQ {5:^E} 5 AK {5:^F} 6 BL {5:^G} 7 |
@@ -1000,10 +1333,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
FF {5:^L} 12 CR {5:^M} 13 SO {5:^N} 14 SI {5:^O} 15 |
DL {5:^P} 16 D1 {5:^Q} 17 D2 {5:^R} 18 D3 {5:^S} 19 |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{8:[No Name] }|
@@ -1011,11 +1346,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{1:~ }|
{3:[No Name] }|
|
- ]]}
+ ]],
+ }
-- edge case: just covers statusline
feed(':set colorcolumn=5 | lua error("x\\n\\nx")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|
{2:x} |
@@ -1023,10 +1360,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{2: [C]: in function 'error'} |
{2: [string ":lua"]:1: in main chunk} |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{8:[No Name] }|
@@ -1034,33 +1373,43 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{1:~ }|
{3:[No Name] }|
|
- ]]}
+ ]],
+ }
-- edge case: just covers lowest window line
feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|*2
{2:x} |
{2:stack traceback:} |
{2: [C]: in function 'error'} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|*2
{2:x} |
{2:stack traceback:} |
{2: [C]: in function 'error'} |
{2: [string ":lua"]:1: in main chunk} |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
end)
it('supports nvim_echo messages with multiple attrs', function()
- async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {})
- screen:expect{grid=[[
+ async_meths.echo(
+ { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } },
+ true,
+ {}
+ )
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
@@ -1068,17 +1417,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
|
{2:very }{11:color} |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed '<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*5
|
- ]]}
+ ]],
+ }
feed ':messages<cr>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
@@ -1086,12 +1439,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
|
{2:very }{11:color} |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
end)
it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function()
command('set number')
- meths.buf_set_lines(0, 0, 0, true, {'aaa', 'bbb', 'ccc'})
+ meths.buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' })
feed('gggQ<CR><CR>1<CR><CR>vi')
screen:expect([[
Entering Ex mode. Type "visual" to go to Normal mode. |
@@ -1127,17 +1481,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
endfunc
]]):format(to_block))
feed(':call PrintAndWait()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
{3: }|
aaa |
bbb^ |
- ]], timeout=timeout}
+ ]],
+ timeout = timeout,
+ }
if type(to_unblock) == 'string' then
feed(to_unblock)
end
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{3: }|
@@ -1145,7 +1503,8 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
bbb |
ccc |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
end
it('getchar()', function()
@@ -1161,12 +1520,15 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
end)
end)
- it('consecutive calls to win_move_statusline() work after multiline message #21014',function()
- async_meths.exec([[
+ it('consecutive calls to win_move_statusline() work after multiline message #21014', function()
+ async_meths.exec(
+ [[
echo "\n"
call win_move_statusline(0, -4)
call win_move_statusline(0, 4)
- ]], false)
+ ]],
+ false
+ )
screen:expect([[
|
{1:~ }|*3
@@ -1210,17 +1572,17 @@ describe('ui/ext_messages', function()
local screen
before_each(function()
- clear{args_rm={'--headless'}, args={"--cmd", "set shortmess-=I"}}
+ clear { args_rm = { '--headless' }, args = { '--cmd', 'set shortmess-=I' } }
screen = Screen.new(80, 24)
- screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true})
+ screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true })
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {bold = true},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {foreground = Screen.colors.Blue1},
- [6] = {reverse = true},
- [7] = {bold = true, reverse = true},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = { bold = true },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { foreground = Screen.colors.Blue1 },
+ [6] = { reverse = true },
+ [7] = { bold = true, reverse = true },
})
end)
@@ -1246,14 +1608,15 @@ describe('ui/ext_messages', function()
{1:~ }|*5
]])
- feed("<c-l>")
+ feed('<c-l>')
screen:expect([[
^ |
{1:~ }|*23
]])
- feed(":intro<cr>")
- screen:expect{grid=[[
+ feed(':intro<cr>')
+ screen:expect {
+ grid = [[
^ |
|*4
{MATCH:.*}|
@@ -1270,55 +1633,66 @@ describe('ui/ext_messages', function()
|
{MATCH:.*}|*2
|*5
- ]], messages={
- {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" }
- }}
+ ]],
+ messages = {
+ { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' },
+ },
+ }
end)
it('supports global statusline', function()
- feed(":set laststatus=3<cr>")
- feed(":sp<cr>")
- feed(":set cmdheight<cr>")
- screen:expect({grid=[[
+ feed(':set laststatus=3<cr>')
+ feed(':sp<cr>')
+ feed(':set cmdheight<cr>')
+ screen:expect({
+ grid = [[
^ |
{1:~ }|*10
────────────────────────────────────────────────────────────────────────────────|
|
{1:~ }|*10
{7:[No Name] }|
- ]], messages={
- {content = { { " cmdheight=0" } }, kind = "" }
- }})
+ ]],
+ messages = {
+ { content = { { ' cmdheight=0' } }, kind = '' },
+ },
+ })
- feed("<c-w>+")
- feed(":set laststatus<cr>")
- screen:expect({grid=[[
+ feed('<c-w>+')
+ feed(':set laststatus<cr>')
+ screen:expect({
+ grid = [[
^ |
{1:~ }|*11
────────────────────────────────────────────────────────────────────────────────|
|
{1:~ }|*9
{7:[No Name] }|
- ]], messages={
- {content = { { " laststatus=3" } }, kind = "" }
- }})
+ ]],
+ messages = {
+ { content = { { ' laststatus=3' } }, kind = '' },
+ },
+ })
- feed(":set mouse=a<cr>")
+ feed(':set mouse=a<cr>')
meths.input_mouse('left', 'press', '', 0, 12, 10)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 11, 10)
- feed("<c-l>")
- feed(":set cmdheight<cr>")
- screen:expect({grid=[[
+ feed('<c-l>')
+ feed(':set cmdheight<cr>')
+ screen:expect({
+ grid = [[
^ |
{1:~ }|*10
────────────────────────────────────────────────────────────────────────────────|
|
{1:~ }|*10
{7:[No Name] }|
- ]], messages={
- {content = { { " cmdheight=0" } }, kind = "" }
- }})
+ ]],
+ messages = {
+ { content = { { ' cmdheight=0' } }, kind = '' },
+ },
+ })
end)
end)
@@ -1326,9 +1700,9 @@ describe('ui/msg_puts_printf', function()
it('output multibyte characters correctly', function()
local screen
local cmd = ''
- local locale_dir = test_build_dir..'/share/locale/ja/LC_MESSAGES'
+ local locale_dir = test_build_dir .. '/share/locale/ja/LC_MESSAGES'
- clear({env={LANG='ja_JP.UTF-8'}})
+ clear({ env = { LANG = 'ja_JP.UTF-8' } })
screen = Screen.new(25, 5)
screen:attach()
@@ -1340,7 +1714,7 @@ describe('ui/msg_puts_printf', function()
cmd = 'chcp 932 > NULL & '
end
else
- if (exc_exec('lang ja_JP.UTF-8') ~= 0) then
+ if exc_exec('lang ja_JP.UTF-8') ~= 0 then
pending('Locale ja_JP.UTF-8 not supported', function() end)
return
elseif is_ci() then
@@ -1350,11 +1724,13 @@ describe('ui/msg_puts_printf', function()
end
end
- os.execute('cmake -E make_directory '..locale_dir)
- os.execute('cmake -E copy '..test_build_dir..'/src/nvim/po/ja.mo '..locale_dir..'/nvim.mo')
+ os.execute('cmake -E make_directory ' .. locale_dir)
+ os.execute(
+ 'cmake -E copy ' .. test_build_dir .. '/src/nvim/po/ja.mo ' .. locale_dir .. '/nvim.mo'
+ )
- cmd = cmd..'"'..nvim_prog..'" -u NONE -i NONE -Es -V1'
- command([[call termopen(']]..cmd..[[')]])
+ cmd = cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -V1'
+ command([[call termopen(']] .. cmd .. [[')]])
screen:expect([[
^Exモードに入ります. ノー |
マルモードに戻るには"visu|
@@ -1363,7 +1739,7 @@ describe('ui/msg_puts_printf', function()
|
]])
- os.execute('cmake -E remove_directory '..test_build_dir..'/share')
+ os.execute('cmake -E remove_directory ' .. test_build_dir .. '/share')
end)
end)
@@ -1375,88 +1751,108 @@ describe('pager', function()
screen = Screen.new(35, 8)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red, special=Screen.colors.Yellow},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {special = Screen.colors.Yellow},
- [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4},
- [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100},
- [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100},
- [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100},
- [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')},
- [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber ('0x2b8452')},
- [12] = {bold = true, reverse = true},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [3] = {
+ foreground = Screen.colors.Grey100,
+ background = Screen.colors.Red,
+ special = Screen.colors.Yellow,
+ },
+ [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [5] = { special = Screen.colors.Yellow },
+ [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 },
+ [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 },
+ [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 },
+ [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 },
+ [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') },
+ [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') },
+ [12] = { bold = true, reverse = true },
})
- command("set more")
+ command('set more')
- exec_lua('_G.x = ...', [[
+ exec_lua(
+ '_G.x = ...',
+ [[
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud xercitation
ullamco laboris nisi ut
-aliquip ex ea commodo consequat.]])
+aliquip ex ea commodo consequat.]]
+ )
end)
it('can be quit with echon', function()
- screen:try_resize(25,5)
+ screen:try_resize(25, 5)
feed(':echon join(map(range(0, &lines*10), "v:val"), "\\n")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
0 |
1 |
2 |
3 |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
end)
it('can be quit with Lua #11224 #16537', function()
-- NOTE: adds "4" to message history, although not displayed initially
-- (triggered the more prompt).
- screen:try_resize(40,5)
+ screen:try_resize(40, 5)
feed(':lua for i=0,10 do print(i) end<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
0 |
1 |
2 |
3 |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
feed(':mess<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
0 |
1 |
2 |
3 |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
1 |
2 |
3 |
4 |
{4:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
end)
it('handles wrapped lines with line scroll', function()
feed(':lua error(_G.x)<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string }|
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
@@ -1465,10 +1861,12 @@ aliquip ex ea commodo consequat.]])
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
{2:adipisicing elit, sed do eiusmod te}|
@@ -1477,10 +1875,12 @@ aliquip ex ea commodo consequat.]])
{2:a aliqua.} |
{2:Ut enim ad minim veniam, quis nostr}|
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('k')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string }|
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
@@ -1489,10 +1889,12 @@ aliquip ex ea commodo consequat.]])
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
{2:adipisicing elit, sed do eiusmod te}|
@@ -1501,12 +1903,14 @@ aliquip ex ea commodo consequat.]])
{2:a aliqua.} |
{2:Ut enim ad minim veniam, quis nostr}|
{4:-- More --}^ |
- ]]}
+ ]],
+ }
end)
it('handles wrapped lines with page scroll', function()
feed(':lua error(_G.x)<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string }|
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
@@ -1515,9 +1919,11 @@ aliquip ex ea commodo consequat.]])
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:mpor} |
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
@@ -1526,9 +1932,11 @@ aliquip ex ea commodo consequat.]])
{2:ullamco laboris nisi ut} |
{2:aliquip ex ea commodo consequat.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string }|
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
@@ -1537,9 +1945,11 @@ aliquip ex ea commodo consequat.]])
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:mpor} |
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
@@ -1548,14 +1958,16 @@ aliquip ex ea commodo consequat.]])
{2:ullamco laboris nisi ut} |
{2:aliquip ex ea commodo consequat.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
end)
it('handles wrapped lines with line scroll and MsgArea highlight', function()
- command("hi MsgArea guisp=Yellow")
+ command('hi MsgArea guisp=Yellow')
feed(':lua error(_G.x)<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:E5108: Error executing lua [string }|
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
@@ -1564,10 +1976,12 @@ aliquip ex ea commodo consequat.]])
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
{3:adipisicing elit, sed do eiusmod te}|
@@ -1576,10 +1990,12 @@ aliquip ex ea commodo consequat.]])
{3:a aliqua.}{5: }|
{3:Ut enim ad minim veniam, quis nostr}|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('k')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:E5108: Error executing lua [string }|
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
@@ -1588,10 +2004,12 @@ aliquip ex ea commodo consequat.]])
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
{3:adipisicing elit, sed do eiusmod te}|
@@ -1600,13 +2018,15 @@ aliquip ex ea commodo consequat.]])
{3:a aliqua.}{5: }|
{3:Ut enim ad minim veniam, quis nostr}|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
end)
it('handles wrapped lines with page scroll and MsgArea highlight', function()
- command("hi MsgArea guisp=Yellow")
+ command('hi MsgArea guisp=Yellow')
feed(':lua error(_G.x)<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:E5108: Error executing lua [string }|
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
@@ -1615,9 +2035,11 @@ aliquip ex ea commodo consequat.]])
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:mpor}{5: }|
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
@@ -1626,9 +2048,11 @@ aliquip ex ea commodo consequat.]])
{3:ullamco laboris nisi ut}{5: }|
{3:aliquip ex ea commodo consequat.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('u')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:E5108: Error executing lua [string }|
{3:":lua"]:1: Lorem ipsum dolor sit am}|
{3:et, consectetur}{5: }|
@@ -1637,9 +2061,11 @@ aliquip ex ea commodo consequat.]])
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:mpor}{5: }|
{3:incididunt ut labore et dolore magn}|
{3:a aliqua.}{5: }|
@@ -1648,52 +2074,60 @@ aliquip ex ea commodo consequat.]])
{3:ullamco laboris nisi ut}{5: }|
{3:aliquip ex ea commodo consequat.}{5: }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
end)
it('preserves MsgArea highlighting after more prompt', function()
- screen:try_resize(70,6)
- command("hi MsgArea guisp=Yellow")
- command("map x Lorem ipsum labore et dolore magna aliqua")
- command("map y adipisicing elit")
- command("map z incididunt ut")
- command("map a labore et dolore")
- command("map b ex ea commodo")
- command("map xx yy")
- command("map xy yz")
+ screen:try_resize(70, 6)
+ command('hi MsgArea guisp=Yellow')
+ command('map x Lorem ipsum labore et dolore magna aliqua')
+ command('map y adipisicing elit')
+ command('map z incididunt ut')
+ command('map a labore et dolore')
+ command('map b ex ea commodo')
+ command('map xx yy')
+ command('map xy yz')
feed(':map<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5: a labore et dolore }|
{5: b ex ea commodo }|
{5: xy yz }|
{5: xx yy }|
{5: x Lorem ipsum labore et dolore magna aliqua }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5: b ex ea commodo }|
{5: xy yz }|
{5: xx yy }|
{5: x Lorem ipsum labore et dolore magna aliqua }|
{5: y adipisicing elit }|
{6:-- More --}{5:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5: xy yz }|
{5: xx yy }|
{5: x Lorem ipsum labore et dolore magna aliqua }|
{5: y adipisicing elit }|
{5: z incididunt ut }|
{6:Press ENTER or type command to continue}{5:^ }|
- ]]}
+ ]],
+ }
end)
it('clears "-- more --" message', function()
- command("hi MsgArea guisp=Yellow blend=10")
+ command('hi MsgArea guisp=Yellow blend=10')
feed(':echon join(range(20), "\\n")<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:0}{8: }|
{9:1}{10: }|
{9:2}{10: }|
@@ -1702,10 +2136,12 @@ aliquip ex ea commodo consequat.]])
{9:5}{10: }|
{9:6}{10: }|
{11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:1}{8: }|
{9:2}{10: }|
{9:3}{10: }|
@@ -1714,10 +2150,12 @@ aliquip ex ea commodo consequat.]])
{9:6}{10: }|
{9:7}{10: }|
{11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
- ]]}
+ ]],
+ }
feed('k')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:0}{8: }|
{9:1}{10: }|
{9:2}{10: }|
@@ -1726,10 +2164,12 @@ aliquip ex ea commodo consequat.]])
{9:5}{10: }|
{9:6}{10: }|
{11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
- ]]}
+ ]],
+ }
feed('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{7:1}{8: }|
{9:2}{10: }|
{9:3}{10: }|
@@ -1738,26 +2178,30 @@ aliquip ex ea commodo consequat.]])
{9:6}{10: }|
{9:7}{10: }|
{11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
- ]]}
+ ]],
+ }
end)
it('with :!cmd does not crash on resize', function()
skip(funcs.executable('sleep') == 0, 'missing "sleep" command')
feed(':!sleep 1<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*4
{12: }|
:!sleep 1 |
|
- ]]}
+ ]],
+ }
-- not processed while command is executing
async_meths.ui_try_resize(35, 5)
-- TODO(bfredl): ideally it should be processed just
-- before the "press ENTER" prompt though
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{12: }|
@@ -1765,19 +2209,23 @@ aliquip ex ea commodo consequat.]])
|
{4:Press ENTER or type command to cont}|
{4:inue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*3
|
- ]]}
+ ]],
+ }
end)
it('can be resized', function()
feed(':lua error(_G.x)<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [string }|
{2:":lua"]:1: Lorem ipsum dolor sit am}|
{2:et, consectetur} |
@@ -1786,22 +2234,26 @@ aliquip ex ea commodo consequat.]])
{2:incididunt ut labore et dolore magn}|
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
-- responds to resize, but text is not reflown
screen:try_resize(45, 5)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:adipisicing elit, sed do eiusmod te} |
{2:mpor} |
{2:incididunt ut labore et dolore magn} |
{2:a aliqua.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
-- can create empty space, as the command hasn't output the text below yet.
-- text is not reflown; existing lines get cut
screen:try_resize(30, 12)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
:lua error(_G.x) |
{2:E5108: Error executing lua [st}|
{2:":lua"]:1: Lorem ipsum dolor s}|
@@ -1812,12 +2264,14 @@ aliquip ex ea commodo consequat.]])
{2:a aliqua.} |
|*3
{4:-- More --}^ |
- ]]}
+ ]],
+ }
-- continues in a mostly consistent state, but only new lines are
-- wrapped at the new screen size.
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:E5108: Error executing lua [st}|
{2:":lua"]:1: Lorem ipsum dolor s}|
{2:et, consectetur} |
@@ -1830,10 +2284,12 @@ aliquip ex ea commodo consequat.]])
{2:ullamco laboris nisi ut} |
{2:aliquip ex ea commodo consequa}|
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:":lua"]:1: Lorem ipsum dolor s}|
{2:et, consectetur} |
{2:adipisicing elit, sed do eiusm}|
@@ -1846,20 +2302,24 @@ aliquip ex ea commodo consequat.]])
{2:aliquip ex ea commodo consequa}|
{2:t.} |
{4:-- More --}^ |
- ]]}
+ ]],
+ }
feed('q')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*10
|
- ]]}
+ ]],
+ }
end)
it('with cmdheight=0 does not crash with g<', function()
command('set cmdheight=0')
feed(':ls<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{12: }|
@@ -1868,16 +2328,20 @@ aliquip ex ea commodo consequat.]])
line 1 |
{4:Press ENTER or type command to cont}|
{4:inue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*7
- ]]}
+ ]],
+ }
feed('g<lt>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{12: }|
@@ -1886,12 +2350,15 @@ aliquip ex ea commodo consequat.]])
line 1 |
{4:Press ENTER or type command to cont}|
{4:inue}^ |
- ]]}
+ ]],
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|*7
- ]]}
+ ]],
+ }
end)
end)
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua
index 3d5f94cdce..8d7fae3e91 100644
--- a/test/functional/ui/mode_spec.lua
+++ b/test/functional/ui/mode_spec.lua
@@ -11,36 +11,45 @@ describe('ui mode_change event', function()
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},
- [4] = {background=Screen.colors.Red, foreground=Screen.colors.White}, -- ErrorMsg
+ 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 },
+ [4] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg
})
end)
it('works in normal mode', function()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="operator"}
+ ]],
+ mode = 'operator',
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
-- oldtest: Test_mouse_shape_after_failed_change()
@@ -49,165 +58,226 @@ describe('ui mode_change event', function()
command('set nomodifiable')
feed('c')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="operator"}
+ ]],
+ mode = 'operator',
+ }
feed('c')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{4:E21: Cannot make changes, 'modifiable' is off} |
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
-- oldtest: Test_mouse_shape_after_cancelling_gr()
it('is restored to Normal mode after cancelling "gr"', function()
feed('gr')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="replace"}
+ ]],
+ mode = 'replace',
+ }
feed('<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
it('works in insert mode', function()
feed('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{2:-- INSERT --} |
- ]], mode="insert"}
+ ]],
+ mode = 'insert',
+ }
feed('word<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
wor^d |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
local matchtime = 0
- command("set showmatch")
+ command('set showmatch')
retry(nil, nil, function()
matchtime = matchtime + 1
- local screen_timeout = 1000 * matchtime -- fail faster for retry.
+ local screen_timeout = 1000 * matchtime -- fail faster for retry.
- command("set matchtime=" .. matchtime) -- tenths of seconds
+ command('set matchtime=' .. matchtime) -- tenths of seconds
feed('a(stuff')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
word(stuff^ |
{0:~ }|*2
{2:-- INSERT --} |
- ]], mode="insert", timeout=screen_timeout}
+ ]],
+ mode = 'insert',
+ timeout = screen_timeout,
+ }
feed(')')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
word^(stuff) |
{0:~ }|*2
{2:-- INSERT --} |
- ]], mode="showmatch", timeout=screen_timeout}
+ ]],
+ mode = 'showmatch',
+ timeout = screen_timeout,
+ }
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
word(stuff)^ |
{0:~ }|*2
{2:-- INSERT --} |
- ]], mode="insert", timeout=screen_timeout}
+ ]],
+ mode = 'insert',
+ timeout = screen_timeout,
+ }
end)
end)
it('works in replace mode', function()
feed('R')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
{2:-- REPLACE --} |
- ]], mode="replace"}
+ ]],
+ mode = 'replace',
+ }
feed('word<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
wor^d |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
it('works in cmdline mode', function()
feed(':')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
:^ |
- ]], mode="cmdline_normal"}
+ ]],
+ mode = 'cmdline_normal',
+ }
feed('x<left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
:^x |
- ]], mode="cmdline_insert"}
+ ]],
+ mode = 'cmdline_insert',
+ }
feed('<insert>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
:^x |
- ]], mode="cmdline_replace"}
-
+ ]],
+ mode = 'cmdline_replace',
+ }
feed('<right>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
:x^ |
- ]], mode="cmdline_normal"}
+ ]],
+ mode = 'cmdline_normal',
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
it('works in visual mode', function()
- insert("text")
+ insert('text')
feed('v')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tex^t |
{0:~ }|*2
{2:-- VISUAL --} |
- ]], mode="visual"}
+ ]],
+ mode = 'visual',
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tex^t |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
command('set selection=exclusive')
feed('v')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tex^t |
{0:~ }|*2
{2:-- VISUAL --} |
- ]], mode="visual_select"}
+ ]],
+ mode = 'visual_select',
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tex^t |
{0:~ }|*2
|
- ]], mode="normal"}
+ ]],
+ mode = 'normal',
+ }
end)
end)
-
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 448b39994b..d1479c13fe 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -21,21 +21,21 @@ describe('ui/mouse/input', function()
screen = Screen.new(25, 5)
screen:attach()
screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {background = Screen.colors.LightGrey},
- [2] = {bold = true},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { background = Screen.colors.LightGrey },
+ [2] = { bold = true },
[3] = {
foreground = Screen.colors.Blue,
background = Screen.colors.LightGrey,
bold = true,
},
- [4] = {reverse = true},
- [5] = {bold = true, reverse = true},
- [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [7] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [8] = {foreground = Screen.colors.Brown},
+ [4] = { reverse = true },
+ [5] = { bold = true, reverse = true },
+ [6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [7] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [8] = { foreground = Screen.colors.Brown },
})
- command("set mousemodel=extend")
+ command('set mousemodel=extend')
feed('itesting<cr>mouse<cr>support and selection<esc>')
screen:expect([[
testing |
@@ -48,13 +48,16 @@ describe('ui/mouse/input', function()
it('single left click moves cursor', function()
feed('<LeftMouse><2,1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
testing |
mo^use |
support and selection |
{0:~ }|
|
- ]], mouse_enabled=true}
+ ]],
+ mouse_enabled = true,
+ }
feed('<LeftMouse><0,0>')
screen:expect([[
^testing |
@@ -68,13 +71,16 @@ describe('ui/mouse/input', function()
it("in external ui works with unset 'mouse'", function()
meths.set_option_value('mouse', '', {})
feed('<LeftMouse><2,1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
testing |
mo^use |
support and selection |
{0:~ }|
|
- ]], mouse_enabled=false}
+ ]],
+ mouse_enabled = false,
+ }
feed('<LeftMouse><0,0>')
screen:expect([[
^testing |
@@ -135,11 +141,11 @@ describe('ui/mouse/input', function()
describe('tab drag', function()
before_each(function()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true }
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ tab = { background = Screen.colors.LightGrey, underline = true },
+ sel = { bold = true },
+ fill = { reverse = true },
})
end)
@@ -182,12 +188,15 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftMouse><11,0>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r{0:$} |
{0:~ }|*2
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
feed('<LeftDrag><6,0>')
screen:expect([[
{sel: + bar }{tab: + foo }{fill: }{tab:X}|
@@ -243,12 +252,15 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftDrag><4,1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
this is fo^o |
{0:~ }|*2
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
feed('<LeftDrag><14,1>')
screen:expect([[
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
@@ -270,19 +282,25 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftMouse><11,0>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r{0:$} |
{0:~ }|*2
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
feed('<LeftDrag><11,1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r{0:$} |
{0:~ }|*2
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
feed('<LeftDrag><6,1>')
screen:expect([[
{sel: + bar }{tab: + foo }{fill: }{tab:X}|
@@ -311,12 +329,15 @@ describe('ui/mouse/input', function()
|
]])
feed('<LeftDrag><4,1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
this is fo^o |
{0:~ }|*2
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
feed('<LeftDrag><7,1>')
screen:expect([[
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
@@ -329,11 +350,11 @@ describe('ui/mouse/input', function()
describe('tabline', function()
before_each(function()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true }
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ tab = { background = Screen.colors.LightGrey, underline = true },
+ sel = { bold = true },
+ fill = { reverse = true },
})
end)
@@ -428,30 +449,28 @@ describe('ui/mouse/input', function()
meths.set_var('reply', {})
end
- local test_click = function(name, click_str, click_num, mouse_button,
- modifiers)
-
+ local test_click = function(name, click_str, click_num, mouse_button, modifiers)
local function doit(do_click)
eq(1, funcs.has('tablineat'))
- do_click(0,3)
- check_reply({0, click_num, mouse_button, modifiers})
- do_click(0,4)
+ do_click(0, 3)
+ check_reply({ 0, click_num, mouse_button, modifiers })
+ do_click(0, 4)
check_reply({})
- do_click(0,6)
- check_reply({5, click_num, mouse_button, modifiers, 2})
- do_click(0,13)
- check_reply({5, click_num, mouse_button, modifiers, 2})
+ do_click(0, 6)
+ check_reply({ 5, click_num, mouse_button, modifiers, 2 })
+ do_click(0, 13)
+ check_reply({ 5, click_num, mouse_button, modifiers, 2 })
end
it(name .. ' works (pseudokey)', function()
- doit(function (row,col)
- feed(click_str .. '<' .. col .. ',' .. row .. '>')
+ doit(function(row, col)
+ feed(click_str .. '<' .. col .. ',' .. row .. '>')
end)
end)
it(name .. ' works (nvim_input_mouse)', function()
- doit(function (row,col)
- local buttons = {l='left',m='middle',r='right'}
+ doit(function(row, col)
+ local buttons = { l = 'left', m = 'middle', r = 'right' }
local modstr = (click_num > 1) and tostring(click_num) or ''
for char in string.gmatch(modifiers, '%w') do
modstr = modstr .. char .. '-' -- - not needed but should be accepted
@@ -463,16 +482,24 @@ describe('ui/mouse/input', function()
test_click('single left click', '<LeftMouse>', 1, 'l', ' ')
test_click('shifted single left click', '<S-LeftMouse>', 1, 'l', 's ')
- test_click('shifted single left click with alt modifier',
- '<S-A-LeftMouse>', 1, 'l', 's a ')
- test_click('shifted single left click with alt and ctrl modifiers',
- '<S-C-A-LeftMouse>', 1, 'l', 'sca ')
+ test_click('shifted single left click with alt modifier', '<S-A-LeftMouse>', 1, 'l', 's a ')
+ test_click(
+ 'shifted single left click with alt and ctrl modifiers',
+ '<S-C-A-LeftMouse>',
+ 1,
+ 'l',
+ 'sca '
+ )
-- <C-RightMouse> does not work
- test_click('shifted single right click with alt modifier',
- '<S-A-RightMouse>', 1, 'r', 's a ')
+ test_click('shifted single right click with alt modifier', '<S-A-RightMouse>', 1, 'r', 's a ')
-- Modifiers do not work with MiddleMouse
- test_click('shifted single middle click with alt and ctrl modifiers',
- '<MiddleMouse>', 1, 'm', ' ')
+ test_click(
+ 'shifted single middle click with alt and ctrl modifiers',
+ '<MiddleMouse>',
+ 1,
+ 'm',
+ ' '
+ )
-- Modifiers do not work with N-*Mouse
test_click('double left click', '<2-LeftMouse>', 2, 'l', ' ')
test_click('triple left click', '<3-LeftMouse>', 3, 'l', ' ')
@@ -524,15 +551,15 @@ describe('ui/mouse/input', function()
it('left drag changes visual selection after tab click', function()
screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true },
- vis = { background=Screen.colors.LightGrey }
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ tab = { background = Screen.colors.LightGrey, underline = true },
+ sel = { bold = true },
+ fill = { reverse = true },
+ vis = { background = Screen.colors.LightGrey },
})
feed_command('silent file foo | tabnew | file bar')
insert('this is bar')
- feed_command('tabprevious') -- go to first tab
+ feed_command('tabprevious') -- go to first tab
screen:expect([[
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
testing |
@@ -540,7 +567,7 @@ describe('ui/mouse/input', function()
support and selectio^n |
:tabprevious |
]])
- feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab
+ feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab
helpers.poke_eventloop()
feed('<LeftMouse><0,1>')
screen:expect([[
@@ -559,7 +586,7 @@ describe('ui/mouse/input', function()
end)
it('left drag changes visual selection in split layout', function()
- screen:try_resize(53,14)
+ screen:try_resize(53, 14)
command('set mouse=a')
command('vsplit')
command('wincmd l')
@@ -567,7 +594,8 @@ describe('ui/mouse/input', function()
command('enew')
feed('ifoo\nbar<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
testing │testing |
mouse │mouse |
support and selection │support and selection |
@@ -578,10 +606,12 @@ describe('ui/mouse/input', function()
{0:~ }│{0:~ }|*4
{4:[No Name] [+] }{5:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
meths.input_mouse('left', 'press', '', 0, 6, 27)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
testing │testing |
mouse │mouse |
support and selection │support and selection |
@@ -592,10 +622,12 @@ describe('ui/mouse/input', function()
{0:~ }│{0:~ }|*4
{4:[No Name] [+] }{5:[No Name] [+] }|
|
- ]]}
+ ]],
+ }
meths.input_mouse('left', 'drag', '', 0, 7, 30)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
testing │testing |
mouse │mouse |
support and selection │support and selection |
@@ -606,7 +638,8 @@ describe('ui/mouse/input', function()
{0:~ }│{0:~ }|*4
{4:[No Name] [+] }{5:[No Name] [+] }|
{2:-- VISUAL --} |
- ]]}
+ ]],
+ }
end)
it('two clicks will enter VISUAL and dragging selects words', function()
@@ -943,9 +976,9 @@ describe('ui/mouse/input', function()
it('horizontal scrolling (pseudokey)', function()
command('set sidescroll=0')
- feed("<esc>:set nowrap<cr>")
+ feed('<esc>:set nowrap<cr>')
- feed("a <esc>20Ab<esc>")
+ feed('a <esc>20Ab<esc>')
screen:expect([[
|*2
bbbbbbbbbbbbbbb^b |
@@ -953,7 +986,7 @@ describe('ui/mouse/input', function()
|
]])
- feed("<ScrollWheelLeft><0,0>")
+ feed('<ScrollWheelLeft><0,0>')
screen:expect([[
|*2
n bbbbbbbbbbbbbbbbbbb^b |
@@ -961,7 +994,7 @@ describe('ui/mouse/input', function()
|
]])
- feed("^<ScrollWheelRight><0,0>")
+ feed('^<ScrollWheelRight><0,0>')
screen:expect([[
g |
|
@@ -973,9 +1006,9 @@ describe('ui/mouse/input', function()
it('horizontal scrolling (nvim_input_mouse)', function()
command('set sidescroll=0')
- feed("<esc>:set nowrap<cr>")
+ feed('<esc>:set nowrap<cr>')
- feed("a <esc>20Ab<esc>")
+ feed('a <esc>20Ab<esc>')
screen:expect([[
|*2
bbbbbbbbbbbbbbb^b |
@@ -991,7 +1024,7 @@ describe('ui/mouse/input', function()
|
]])
- feed("^")
+ feed('^')
meths.input_mouse('wheel', 'right', '', 0, 0, 0)
screen:expect([[
g |
@@ -1006,7 +1039,7 @@ describe('ui/mouse/input', function()
command('set nowrap')
command('set sidescrolloff=4')
- feed("I <esc>020ib<esc>0")
+ feed('I <esc>020ib<esc>0')
screen:expect([[
testing |
mouse |
@@ -1118,7 +1151,6 @@ describe('ui/mouse/input', function()
{0:~ }|*2
|
]])
-
end) -- level 1 - non wrapped
it('(level 1) click on wrapped lines', function()
@@ -1175,7 +1207,6 @@ describe('ui/mouse/input', function()
]])
end) -- level 1 - wrapped
-
it('(level 2) click on non-wrapped lines', function()
feed_command('let &conceallevel=2', 'echo')
@@ -1209,7 +1240,7 @@ describe('ui/mouse/input', function()
|
]])
- feed('<esc><LeftMouse><0,2>') -- Weirdness
+ feed('<esc><LeftMouse><0,2>') -- Weirdness
screen:expect([[
Section{0:>>--->--->---}t1 |
{0:>--->--->---} t2 t3 t4 |
@@ -1273,7 +1304,7 @@ describe('ui/mouse/input', function()
{sm:-- INSERT --} |
]])
- feed('<LeftMouse><0,2>') -- Weirdness
+ feed('<LeftMouse><0,2>') -- Weirdness
screen:expect([[
Section{0:>>--->--->---}t1 |
{0:>--->--->---} t2 t3 t4 |
@@ -1438,7 +1469,7 @@ describe('ui/mouse/input', function()
]])
feed('<esc><LeftMouse><20,2>')
- feed('zH') -- FIXME: unnecessary horizontal scrolling
+ feed('zH') -- FIXME: unnecessary horizontal scrolling
screen:expect([[
Section{0:>>--->--->---}t1 |
{0:>--->--->---} t2 t3 t4 |
@@ -1531,7 +1562,6 @@ describe('ui/mouse/input', function()
✨🐈^✨ |
|*2
]])
-
end) -- level 3 - wrapped
end
@@ -1600,7 +1630,6 @@ describe('ui/mouse/input', function()
end)
test_mouse_click_conceal()
end)
-
end)
it('getmousepos() works correctly', function()
@@ -1612,15 +1641,15 @@ describe('ui/mouse/input', function()
insert('hello')
command('vsplit')
local opts = {
- relative='editor',
- width=12,
- height=1,
- col=8,
- row=1,
- anchor='NW',
- style='minimal',
- border='single',
- focusable=1
+ relative = 'editor',
+ width = 12,
+ height = 1,
+ col = 8,
+ row = 1,
+ anchor = 'NW',
+ style = 'minimal',
+ border = 'single',
+ focusable = 1,
}
local float = meths.open_win(meths.get_current_buf(), false, opts)
command('redraw')
@@ -1665,8 +1694,12 @@ describe('ui/mouse/input', function()
local line = 0
local column = 0
local coladd = 0
- if win_row > 0 and win_row < opts.height + 1
- and win_col > 0 and win_col < opts.width + 1 then
+ if
+ win_row > 0
+ and win_row < opts.height + 1
+ and win_col > 0
+ and win_col < opts.width + 1
+ then
-- Because of border, win_row and win_col don't need to be
-- incremented by 1.
line = math.min(win_row, funcs.line('$'))
@@ -1785,99 +1818,99 @@ describe('ui/mouse/input', function()
vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR>
]])
- meths.win_set_cursor(0, {1, 0})
+ meths.win_set_cursor(0, { 1, 0 })
meths.input_mouse('right', 'press', '', 0, 0, 4)
meths.input_mouse('right', 'release', '', 0, 0, 4)
feed('<Down><Down><CR>')
eq('bar', meths.get_var('menustr'))
- eq({1, 4}, meths.win_get_cursor(0))
+ eq({ 1, 4 }, meths.win_get_cursor(0))
-- Test for right click in visual mode inside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 9})
+ meths.win_set_cursor(0, { 1, 9 })
feed('vee')
meths.input_mouse('right', 'press', '', 0, 0, 11)
meths.input_mouse('right', 'release', '', 0, 0, 11)
feed('<Down><CR>')
- eq({1, 9}, meths.win_get_cursor(0))
+ eq({ 1, 9 }, meths.win_get_cursor(0))
eq('ran away', funcs.getreg('"'))
-- Test for right click in visual mode right before the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 9})
+ meths.win_set_cursor(0, { 1, 9 })
feed('vee')
meths.input_mouse('right', 'press', '', 0, 0, 8)
meths.input_mouse('right', 'release', '', 0, 0, 8)
feed('<Down><CR>')
- eq({1, 8}, meths.win_get_cursor(0))
+ eq({ 1, 8 }, meths.win_get_cursor(0))
eq('', funcs.getreg('"'))
-- Test for right click in visual mode right after the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 9})
+ meths.win_set_cursor(0, { 1, 9 })
feed('vee')
meths.input_mouse('right', 'press', '', 0, 0, 17)
meths.input_mouse('right', 'release', '', 0, 0, 17)
feed('<Down><CR>')
- eq({1, 17}, meths.win_get_cursor(0))
+ eq({ 1, 17 }, meths.win_get_cursor(0))
eq('', funcs.getreg('"'))
-- Test for right click in block-wise visual mode inside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 15})
+ meths.win_set_cursor(0, { 1, 15 })
feed('<C-V>j3l')
meths.input_mouse('right', 'press', '', 0, 1, 16)
meths.input_mouse('right', 'release', '', 0, 1, 16)
feed('<Down><CR>')
- eq({1, 15}, meths.win_get_cursor(0))
+ eq({ 1, 15 }, meths.win_get_cursor(0))
eq('\0224', funcs.getregtype('"'))
-- Test for right click in block-wise visual mode outside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 15})
+ meths.win_set_cursor(0, { 1, 15 })
feed('<C-V>j3l')
meths.input_mouse('right', 'press', '', 0, 1, 1)
meths.input_mouse('right', 'release', '', 0, 1, 1)
feed('<Down><CR>')
- eq({2, 1}, meths.win_get_cursor(0))
+ eq({ 2, 1 }, meths.win_get_cursor(0))
eq('v', funcs.getregtype('"'))
eq('', funcs.getreg('"'))
-- Test for right click in line-wise visual mode inside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 15})
+ meths.win_set_cursor(0, { 1, 15 })
feed('V')
meths.input_mouse('right', 'press', '', 0, 0, 9)
meths.input_mouse('right', 'release', '', 0, 0, 9)
feed('<Down><CR>')
- eq({1, 0}, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
+ eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
eq('V', funcs.getregtype('"'))
eq(1, #funcs.getreg('"', 1, true))
-- Test for right click in multi-line line-wise visual mode inside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 15})
+ meths.win_set_cursor(0, { 1, 15 })
feed('Vj')
meths.input_mouse('right', 'press', '', 0, 1, 19)
meths.input_mouse('right', 'release', '', 0, 1, 19)
feed('<Down><CR>')
- eq({1, 0}, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
+ eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
eq('V', funcs.getregtype('"'))
eq(2, #funcs.getreg('"', 1, true))
-- Test for right click in line-wise visual mode outside the selection
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 15})
+ meths.win_set_cursor(0, { 1, 15 })
feed('V')
meths.input_mouse('right', 'press', '', 0, 1, 9)
meths.input_mouse('right', 'release', '', 0, 1, 9)
feed('<Down><CR>')
- eq({2, 9}, meths.win_get_cursor(0))
+ eq({ 2, 9 }, meths.win_get_cursor(0))
eq('', funcs.getreg('"'))
-- Try clicking outside the window
funcs.setreg('"', '')
- meths.win_set_cursor(0, {2, 1})
+ meths.win_set_cursor(0, { 2, 1 })
feed('vee')
meths.input_mouse('right', 'press', '', 0, 6, 1)
meths.input_mouse('right', 'release', '', 0, 6, 1)
@@ -1889,12 +1922,12 @@ describe('ui/mouse/input', function()
command('wincmd t')
command('rightbelow vsplit')
funcs.setreg('"', '')
- meths.win_set_cursor(0, {1, 9})
+ meths.win_set_cursor(0, { 1, 9 })
feed('vee')
meths.input_mouse('right', 'press', '', 0, 0, 52)
meths.input_mouse('right', 'release', '', 0, 0, 52)
feed('<Down><CR>')
- eq({1, 9}, meths.win_get_cursor(0))
+ eq({ 1, 9 }, meths.win_get_cursor(0))
eq('ran away', funcs.getreg('"'))
-- Test for right click inside visual selection at bottom of window with winbar
@@ -1905,7 +1938,7 @@ describe('ui/mouse/input', function()
meths.input_mouse('right', 'press', '', 0, 4, 61)
meths.input_mouse('right', 'release', '', 0, 4, 61)
feed('<Down><CR>')
- eq({4, 20}, meths.win_get_cursor(0))
+ eq({ 4, 20 }, meths.win_get_cursor(0))
eq('the moon', funcs.getreg('"'))
end)
end)
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index e66e6b2063..8077194533 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -10,28 +10,28 @@ local meths = helpers.meths
local split = helpers.split
local dedent = helpers.dedent
-describe("multibyte rendering", function()
+describe('multibyte rendering', function()
local screen
before_each(function()
clear()
screen = Screen.new(60, 6)
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue},
- [2] = {background = Screen.colors.WebGray},
- [3] = {background = Screen.colors.LightMagenta},
- [4] = {bold = true},
- [5] = {foreground = Screen.colors.Blue},
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { background = Screen.colors.WebGray },
+ [3] = { background = Screen.colors.LightMagenta },
+ [4] = { bold = true },
+ [5] = { foreground = Screen.colors.Blue },
})
end)
- it("works with composed char at start of line", function()
+ it('works with composed char at start of line', function()
insert([[
̊
x]])
- feed("gg")
- -- verify the modifier in fact is alone
- feed_command("ascii")
+ feed('gg')
+ -- verify the modifier in fact is alone
+ feed_command('ascii')
screen:expect([[
^ ̊ |
x |
@@ -40,8 +40,8 @@ describe("multibyte rendering", function()
]])
-- a char inserted before will spontaneously merge with it
- feed("ia<esc>")
- feed_command("ascii")
+ feed('ia<esc>')
+ feed_command('ascii')
screen:expect([[
^å |
x |
@@ -85,7 +85,7 @@ describe("multibyte rendering", function()
]])
-- check double-with char is temporarily hidden when overlapped
- funcs.complete(4, {'xx', 'yy'})
+ funcs.complete(4, { 'xx', 'yy' })
screen:expect([[
ab xx^ |
- {2: xx } |
@@ -107,16 +107,24 @@ describe("multibyte rendering", function()
it('0xffff is shown as 4 hex digits', function()
command([[call setline(1, "\uFFFF!!!")]])
feed('$')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{5:<ffff>}!!^! |
{1:~ }|*4
|
- ]]}
+ ]],
+ }
end)
it('works with a lot of unicode (zalgo) text', function()
screen:try_resize(65, 10)
- meths.buf_set_lines(0,0,-1,true, split(dedent [[
+ meths.buf_set_lines(
+ 0,
+ 0,
+ -1,
+ true,
+ split(
+ dedent [[
L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚
ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊
U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚
@@ -125,11 +133,14 @@ describe("multibyte rendering", function()
ē̟̊̇̕̚s̖̘̘̒̄̑s̛̘̀̊̆̇e̛̝̘̒̏̚ ̉̅̑̂̐̎c̛̟̙̎̋̓i̜̇̒̏̆̆l̟̄́̆̊̌l̍̊̋̃̆̌ủ̗̙̒̔̚m̛̘̘̖̅̍ ̖̙̈̎̂̕d̞̟̏̋̈̔ơ̟̝̌̃̄l̗̙̝̂̉̒õ̒̃̄̄̚ŕ̗̏̏̊̍ê̞̝̞̋̈ ̜̔̒̎̃̚e̞̟̞̒̃̄ư̖̏̄̑̃ ̛̗̜̄̓̎f̛̖̞̅̓̃ü̞̏̆̋̕g̜̝̞̑̑̆i̛̘̐̐̅̚à̜̖̌̆̎t̙̙̎̉̂̍ ̋̔̈̎̎̉n̞̓́̔̊̕ư̘̅̋̔̚l̗̍̒̄̀̚l̞̗̘̙̓̍â̘̔̒̎̚ ̖̓̋̉̃̆p̛̛̘̋̌̀ä̙̔́̒̕r̟̟̖̋̐̋ì̗̙̎̓̓ȃ̔̋̑̚̕t̄́̎̓̂̋ư̏̈̂̑̃r̖̓̋̊̚̚.̒̆̑̆̊̎ ̘̜̍̐̂̚E̞̅̐̇́̂x̄́̈̌̉̕ć̘̃̉̃̕è̘̂̑̏̑p̝̘̑̂̌̆t̔̐̅̍̌̂ȇ̞̈̐̚̕ű̝̞̜́̚ŕ̗̝̉̆́
š̟́̔̏̀ȉ̝̟̝̏̅n̑̆̇̒̆̚t̝̒́̅̋̏ ̗̑̌̋̇̚ơ̙̗̟̆̅c̙̞̙̎̊̎c̘̟̍̔̊̊a̛̒̓̉́̐e̜̘̙̒̅̇ć̝̝̂̇̕ả̓̍̎̂̚t̗̗̗̟̒̃ ̘̒̓̐̇́c̟̞̉̐̓̄ȕ̙̗̅́̏p̛̍̋̈́̅i̖̓̒̍̈̄d̞̃̈̌̆̐a̛̗̝̎̋̉t̞̙̀̊̆̇a̛̙̒̆̉̚t̜̟̘̉̓̚ ̝̘̗̐̇̕n̛̘̑̏̂́ō̑̋̉̏́ň̞̊̆̄̃ ̙̙̙̜̄̏p̒̆̋̋̓̏r̖̖̅̉́̚ơ̜̆̑̈̚i̟̒̀̃̂̌d̛̏̃̍̋̚ë̖̞̙̗̓n̛̘̓̒̅̎t̟̗̙̊̆̚,̘̙̔̊̚̕ ̟̗̘̜̑̔s̜̝̍̀̓̌û̞̙̅̇́n̘̗̝̒̃̎t̗̅̀̅̊̈ ̗̖̅̅̀̄i̛̖̍̅̋̂n̙̝̓̓̎̚ ̞̋̅̋̃̚c̗̒̀̆̌̎ū̞̂̑̌̓ĺ̛̐̍̑́p̝̆̌̎̈̚a̖̙̒̅̈̌ ̝̝̜̂̈̀q̝̖̔̍̒̚ư̔̐̂̎̊ǐ̛̟̖̘̕
o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚]],
- '\n'))
+ '\n'
+ )
+ )
-- tests that we can handle overflow of the buffer
-- for redraw events (4096 bytes) gracefully
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ |
ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ |
U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ |
@@ -140,12 +151,14 @@ describe("multibyte rendering", function()
o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚ |
{1:~ }|
|
- ]]}
+ ]],
+ }
-- nvim will reset the zalgo text^W^W glyph cache if it gets too full.
-- this should be exceedingly rare, but fake it to make sure it works
meths._invalidate_glyph_cache()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ |
ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ |
U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ |
@@ -156,7 +169,9 @@ describe("multibyte rendering", function()
o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚ |
{1:~ }|
|
- ]], reset=true}
+ ]],
+ reset = true,
+ }
end)
it('works with arabic input and arabicshape', function()
@@ -164,18 +179,22 @@ describe("multibyte rendering", function()
command('set noarabicshape')
feed('isghl!<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^!مالس|
{1: ~}|*4
|
- ]]}
+ ]],
+ }
command('set arabicshape')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^!ﻡﻼﺳ|
{1: ~}|*4
|
- ]]}
+ ]],
+ }
end)
it('works with arabic input and arabicshape and norightleft', function()
@@ -183,19 +202,22 @@ describe("multibyte rendering", function()
command('set noarabicshape')
feed('isghl!<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
سلام^! |
{1:~ }|*4
|
- ]]}
+ ]],
+ }
command('set arabicshape')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
ﺱﻼﻣ^! |
{1:~ }|*4
|
- ]]}
-
+ ]],
+ }
end)
it('works with arabicshape and multiple composing chars', function()
@@ -205,21 +227,25 @@ describe("multibyte rendering", function()
-- If we would increase the schar_t size, say from 32 to 64 bytes, we need to extend the
-- test text with even more zalgo energy to still touch this edge case.
- meths.buf_set_lines(0,0,-1,true, {"سلام့̀́̂̃̄̅̆̇̈̉̊̋̌"})
+ meths.buf_set_lines(0, 0, -1, true, { 'سلام့̀́̂̃̄̅̆̇̈̉̊̋̌' })
command('set noarabicshape')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^سلام့̀́̂̃̄̅̆̇̈̉̊̋̌ |
{1:~ }|*4
|
- ]]}
+ ]],
+ }
command('set arabicshape')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ﺱﻼﻣ̀́̂̃̄̅̆̇̈̉̊̋̌ |
{1:~ }|*4
|
- ]]}
+ ]],
+ }
end)
end)
@@ -230,9 +256,9 @@ describe('multibyte rendering: statusline', function()
clear()
screen = Screen.new(40, 4)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {bold = true, reverse = true},
- [3] = {background = Screen.colors.Red, foreground = Screen.colors.Gray100};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { bold = true, reverse = true },
+ [3] = { background = Screen.colors.Red, foreground = Screen.colors.Gray100 },
})
screen:attach()
command('set laststatus=2')
@@ -288,34 +314,40 @@ describe('multibyte rendering: statusline', function()
it('hidden group %( %) does not cause invalid unicode', function()
command("let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡'")
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|
{2: Q≡ }|
|
- ]]}
+ ]],
+ }
end)
it('unprintable chars in filename with default stl', function()
- command("file 🧑‍💻")
+ command('file 🧑‍💻')
-- TODO: this is wrong but avoids a crash
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|
{2:🧑�💻 }|
|
- ]]}
+ ]],
+ }
end)
it('unprintable chars in filename with custom stl', function()
command('set statusline=xx%#ErrorMsg#%f%##yy')
- command("file 🧑‍💻")
+ command('file 🧑‍💻')
-- TODO: this is also wrong but also avoids a crash
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{1:~ }|
{2:xx}{3:🧑<200d>💻}{2:yy }|
|
- ]]}
+ ]],
+ }
end)
end)
diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua
index 4c197ad5b9..98af82a7c5 100644
--- a/test/functional/ui/options_spec.lua
+++ b/test/functional/ui/options_spec.lua
@@ -11,38 +11,38 @@ describe('UI receives option updates', function()
local function reset(screen_opts, clear_opts)
local defaults = {
- ambiwidth='single',
- arabicshape=true,
- emoji=true,
- guifont='',
- guifontwide='',
- linespace=0,
- pumblend=0,
- mousefocus=false,
- mousehide=true,
- mousemoveevent=false,
- showtabline=1,
- termguicolors=false,
- termsync=true,
- ttimeout=true,
- ttimeoutlen=50,
- verbose=0,
- ext_cmdline=false,
- ext_popupmenu=false,
- ext_tabline=false,
- ext_wildmenu=false,
- ext_linegrid=false,
- ext_hlstate=false,
- ext_multigrid=false,
- ext_messages=false,
- ext_termcolors=false,
+ ambiwidth = 'single',
+ arabicshape = true,
+ emoji = true,
+ guifont = '',
+ guifontwide = '',
+ linespace = 0,
+ pumblend = 0,
+ mousefocus = false,
+ mousehide = true,
+ mousemoveevent = false,
+ showtabline = 1,
+ termguicolors = false,
+ termsync = true,
+ ttimeout = true,
+ ttimeoutlen = 50,
+ verbose = 0,
+ ext_cmdline = false,
+ ext_popupmenu = false,
+ ext_tabline = false,
+ ext_wildmenu = false,
+ ext_linegrid = false,
+ ext_hlstate = false,
+ ext_multigrid = false,
+ ext_messages = false,
+ ext_termcolors = false,
}
clear_opts = shallowcopy(clear_opts or {})
clear_opts.args_rm = clear_opts.args_rm or {}
table.insert(clear_opts.args_rm or {}, '--cmd')
clear(clear_opts)
- screen = Screen.new(20,5)
+ screen = Screen.new(20, 5)
screen:attach(screen_opts)
-- NB: UI test suite can be run in both "linegrid" and legacy grid mode.
-- In both cases check that the received value is the one requested.
@@ -50,7 +50,7 @@ describe('UI receives option updates', function()
return defaults
end
- it("for defaults", function()
+ it('for defaults', function()
local expected = reset()
screen:expect(function()
eq(expected, screen.options)
@@ -58,9 +58,9 @@ describe('UI receives option updates', function()
end)
it('on attach #11372', function()
- clear{args_rm={'--headless'}}
+ clear { args_rm = { '--headless' } }
local evs = {}
- screen = Screen.new(20,5)
+ screen = Screen.new(20, 5)
-- Override mouse_on/mouse_off handlers.
function screen:_handle_mouse_on()
table.insert(evs, 'mouse_on')
@@ -70,109 +70,109 @@ describe('UI receives option updates', function()
end
screen:attach()
screen:expect(function()
- eq({'mouse_on'}, evs)
+ eq({ 'mouse_on' }, evs)
end)
- command("set mouse=")
+ command('set mouse=')
screen:expect(function()
- eq({'mouse_on', 'mouse_off'}, evs)
+ eq({ 'mouse_on', 'mouse_off' }, evs)
end)
- command("set mouse&")
+ command('set mouse&')
screen:expect(function()
- eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs)
+ eq({ 'mouse_on', 'mouse_off', 'mouse_on' }, evs)
end)
screen:detach()
- eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs)
+ eq({ 'mouse_on', 'mouse_off', 'mouse_on' }, evs)
screen:attach()
screen:expect(function()
- eq({'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on'}, evs)
+ eq({ 'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on' }, evs)
end)
end)
- it("when setting options", function()
+ it('when setting options', function()
local expected = reset()
local defaults = shallowcopy(expected)
- command("set termguicolors")
+ command('set termguicolors')
expected.termguicolors = true
screen:expect(function()
eq(expected, screen.options)
end)
- command("set pumblend=50")
+ command('set pumblend=50')
expected.pumblend = 50
screen:expect(function()
- eq(expected, screen.options)
+ eq(expected, screen.options)
end)
-- check handling of out-of-bounds value
- command("set pumblend=-1")
+ command('set pumblend=-1')
expected.pumblend = 0
screen:expect(function()
- eq(expected, screen.options)
+ eq(expected, screen.options)
end)
- command("set guifont=Comic\\ Sans")
- expected.guifont = "Comic Sans"
+ command('set guifont=Comic\\ Sans')
+ expected.guifont = 'Comic Sans'
screen:expect(function()
eq(expected, screen.options)
end)
- command("set showtabline=0")
+ command('set showtabline=0')
expected.showtabline = 0
screen:expect(function()
eq(expected, screen.options)
end)
- command("set linespace=13")
+ command('set linespace=13')
expected.linespace = 13
screen:expect(function()
eq(expected, screen.options)
end)
- command("set linespace=-11")
+ command('set linespace=-11')
expected.linespace = -11
screen:expect(function()
eq(expected, screen.options)
end)
- command("set mousefocus")
+ command('set mousefocus')
expected.mousefocus = true
screen:expect(function()
eq(expected, screen.options)
end)
- command("set nomousehide")
+ command('set nomousehide')
expected.mousehide = false
screen:expect(function()
eq(expected, screen.options)
end)
- command("set mousemoveevent")
+ command('set mousemoveevent')
expected.mousemoveevent = true
screen:expect(function()
eq(expected, screen.options)
end)
- command("set nottimeout")
+ command('set nottimeout')
expected.ttimeout = false
screen:expect(function()
eq(expected, screen.options)
end)
- command("set ttimeoutlen=100")
+ command('set ttimeoutlen=100')
expected.ttimeoutlen = 100
screen:expect(function()
eq(expected, screen.options)
end)
- command("set all&")
+ command('set all&')
screen:expect(function()
eq(defaults, screen.options)
end)
end)
it('with UI extensions', function()
- local expected = reset({ext_cmdline=true, ext_wildmenu=true})
+ local expected = reset({ ext_cmdline = true, ext_wildmenu = true })
expected.ext_cmdline = true
expected.ext_wildmenu = true
@@ -194,37 +194,43 @@ describe('UI receives option updates', function()
end)
local function startup_test(headless)
- local expected = reset(nil, {args_rm=(headless and {} or {'--headless'}),
- args={'--cmd', 'set guifont=Comic\\ Sans\\ 12'}})
- expected.guifont = "Comic Sans 12"
+ local expected = reset(nil, {
+ args_rm = (headless and {} or { '--headless' }),
+ args = { '--cmd', 'set guifont=Comic\\ Sans\\ 12' },
+ })
+ expected.guifont = 'Comic Sans 12'
screen:expect(function()
eq(expected, screen.options)
end)
end
- it('from startup options with --headless', function() startup_test(true) end)
- it('from startup options with --embed', function() startup_test(false) end)
+ it('from startup options with --headless', function()
+ startup_test(true)
+ end)
+ it('from startup options with --embed', function()
+ startup_test(false)
+ end)
end)
describe('UI can set terminal option', function()
local screen
before_each(function()
-- by default we implicitly "--cmd 'set bg=light'" which ruins everything
- clear{args_rm={'--cmd'}}
- screen = Screen.new(20,5)
+ clear { args_rm = { '--cmd' } }
+ screen = Screen.new(20, 5)
end)
it('term_name', function()
eq('nvim', eval '&term')
- screen:attach {term_name='xterm'}
+ screen:attach { term_name = 'xterm' }
eq('xterm', eval '&term')
end)
it('term_colors', function()
eq('256', eval '&t_Co')
- screen:attach {term_colors=8}
+ screen:attach { term_colors = 8 }
eq('8', eval '&t_Co')
end)
end)
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 7ed65b52fa..5e340af89c 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -15,17 +15,21 @@ local set_shell_powershell = helpers.set_shell_powershell
local skip = helpers.skip
local is_os = helpers.is_os
-clear() -- for has_powershell()
+clear() -- for has_powershell()
-describe("shell command :!", function()
+describe('shell command :!', function()
local screen
before_each(function()
clear()
screen = child_session.setup_child_nvim({
- '-u', 'NONE',
- '-i', 'NONE',
- '--cmd', 'colorscheme vim',
- '--cmd', helpers.nvim_set .. ' notermguicolors',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ helpers.nvim_set .. ' notermguicolors',
})
screen:expect([[
{1: } |
@@ -36,14 +40,14 @@ describe("shell command :!", function()
end)
after_each(function()
- child_session.feed_data("\3") -- Ctrl-C
+ child_session.feed_data('\3') -- Ctrl-C
end)
- it("displays output without LF/EOF. #4646 #4569 #3772", function()
+ it('displays output without LF/EOF. #4646 #4569 #3772', function()
skip(is_os('win'))
-- NOTE: We use a child nvim (within a :term buffer)
-- to avoid triggering a UI flush.
- child_session.feed_data(":!printf foo; sleep 200\n")
+ child_session.feed_data(':!printf foo; sleep 200\n')
screen:expect([[
|
{4:~ }|*2
@@ -54,18 +58,19 @@ describe("shell command :!", function()
]])
end)
- it("throttles shell-command output greater than ~10KB", function()
+ it('throttles shell-command output greater than ~10KB', function()
skip(is_os('openbsd'), 'FIXME #10804')
skip(is_os('win'))
- child_session.feed_data((":!%s REP 30001 foo\n"):format(testprg('shell-test')))
+ child_session.feed_data((':!%s REP 30001 foo\n'):format(testprg('shell-test')))
-- If we observe any line starting with a dot, then throttling occurred.
-- Avoid false failure on slow systems.
- screen:expect{any="\n%.", timeout=20000}
+ screen:expect { any = '\n%.', timeout = 20000 }
-- Final chunk of output should always be displayed, never skipped.
-- (Throttling is non-deterministic, this test is merely a sanity check.)
- screen:expect([[
+ screen:expect(
+ [[
29997: foo |
29998: foo |
29999: foo |
@@ -73,27 +78,29 @@ describe("shell command :!", function()
|
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]], {
- -- test/functional/helpers.lua defaults to background=light.
- [1] = {reverse = true},
- [3] = {bold = true},
- [10] = {foreground = 2},
- })
+ ]],
+ {
+ -- test/functional/helpers.lua defaults to background=light.
+ [1] = { reverse = true },
+ [3] = { bold = true },
+ [10] = { foreground = 2 },
+ }
+ )
end)
end)
-describe("shell command :!", function()
+describe('shell command :!', function()
before_each(function()
clear()
end)
- it("cat a binary file #4142", function()
+ it('cat a binary file #4142', function()
feed(":exe 'silent !cat '.shellescape(v:progpath)<CR>")
assert_alive()
end)
it([[display \x08 char #4142]], function()
- feed(":silent !echo \08<CR>")
+ feed(':silent !echo \08<CR>')
assert_alive()
end)
@@ -101,32 +108,37 @@ describe("shell command :!", function()
skip(is_os('win'), 'missing printf')
local screen = Screen.new(50, 4)
screen:set_default_attr_ids {
- [1] = {bold = true, reverse = true};
- [2] = {bold = true, foreground = Screen.colors.SeaGreen};
- [3] = {foreground = Screen.colors.Blue};
+ [1] = { bold = true, reverse = true },
+ [2] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [3] = { foreground = Screen.colors.Blue },
}
screen:attach()
-- Print TAB chars. #2958
feed([[:!printf '1\t2\t3'<CR>]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }|
:!printf '1\t2\t3' |
1 2 3 |
{2:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed([[<CR>]])
-- Print BELL control code. #4338
screen.bell = false
feed([[:!printf '\007\007\007\007text'<CR>]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }|
:!printf '\007\007\007\007text' |
text |
{2:Press ENTER or type command to continue}^ |
- ]], condition=function()
- eq(true, screen.bell)
- end}
+ ]],
+ condition = function()
+ eq(true, screen.bell)
+ end,
+ }
feed([[<CR>]])
-- Print BS control code.
@@ -157,12 +169,12 @@ describe("shell command :!", function()
write_file('bang_filter_spec/f1', 'f1')
write_file('bang_filter_spec/f2', 'f2')
write_file('bang_filter_spec/f3', 'f3')
- screen = Screen.new(53,10)
+ screen = Screen.new(53, 10)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Blue1},
- [3] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [4] = {bold = true, reverse = true},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Blue1 },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [4] = { bold = true, reverse = true },
})
screen:attach()
end)
@@ -172,18 +184,19 @@ describe("shell command :!", function()
end)
it("doesn't truncate Last line of shell output #3269", function()
- command(is_os('win')
- and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]]
- or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]])
- local result = (is_os('win')
- and [[:!dir /b bang_filter_spec]]
- or [[:!ls bang_filter_spec ]])
+ command(
+ is_os('win') and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]]
+ or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]]
+ )
+ local result = (
+ is_os('win') and [[:!dir /b bang_filter_spec]] or [[:!ls bang_filter_spec ]]
+ )
feed([[\l]])
screen:expect([[
|
{1:~ }|*2
{4: }|
- ]]..result..[[ |
+ ]] .. result .. [[ |
f1 |
f2 |
f3 |
@@ -195,7 +208,8 @@ describe("shell command :!", function()
it('handles binary and multibyte data', function()
feed_command('!cat test/functional/fixtures/shell_data.txt')
screen.bell = false
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|
{4: }|
@@ -206,20 +220,22 @@ describe("shell command :!", function()
t {2:<ff>} |
|
{3:Press ENTER or type command to continue}^ |
- ]], condition=function()
- eq(true, screen.bell)
- end}
+ ]],
+ condition = function()
+ eq(true, screen.bell)
+ end,
+ }
end)
it('handles multibyte sequences split over buffer boundaries', function()
- command('cd '..nvim_dir)
+ command('cd ' .. nvim_dir)
local cmd = is_os('win') and '!shell-test UTF-8 ' or '!./shell-test UTF-8'
feed_command(cmd)
-- Note: only the first example of split composed char works
screen:expect([[
|
{4: }|
- :]]..cmd..[[ |
+ :]] .. cmd .. [[ |
å |
ref: å̲ |
1: å̲ |
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 8ad5283b94..67a5f2ef77 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -18,16 +18,16 @@ describe('ui/ext_popupmenu', function()
before_each(function()
clear()
screen = Screen.new(60, 8)
- screen:attach({rgb=true, ext_popupmenu=true})
+ screen:attach({ rgb = true, ext_popupmenu = true })
screen:set_default_attr_ids({
- [1] = {bold=true, foreground=Screen.colors.Blue},
- [2] = {bold = true},
- [3] = {reverse = true},
- [4] = {bold = true, reverse = true},
- [5] = {bold = true, foreground = Screen.colors.SeaGreen},
- [6] = {background = Screen.colors.WebGray},
- [7] = {background = Screen.colors.LightMagenta},
- [8] = {foreground = Screen.colors.Red},
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { bold = true },
+ [3] = { reverse = true },
+ [4] = { bold = true, reverse = true },
+ [5] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [6] = { background = Screen.colors.WebGray },
+ [7] = { background = Screen.colors.LightMagenta },
+ [8] = { foreground = Screen.colors.Red },
})
source([[
function! TestComplete() abort
@@ -38,96 +38,116 @@ describe('ui/ext_popupmenu', function()
end)
local expected = {
- {'fo', 'x', 'the foo', 'foo-y'},
- {'bar', '', '', ''},
- {'spam', '', '', ''},
+ { 'fo', 'x', 'the foo', 'foo-y' },
+ { 'bar', '', '', '' },
+ { 'spam', '', '', '' },
}
it('works', function()
feed('o<C-r>=TestComplete()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<c-p>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=-1,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = -1,
+ anchor = { 1, 1, 0 },
+ },
+ }
-- down moves the selection in the menu, but does not insert anything
feed('<down><down>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=1,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 1,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
bar^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]]}
+ ]],
+ }
end)
it('can be controlled by API', function()
feed('o<C-r>=TestComplete()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(1,false,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(1, false, false, {})
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=1,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(2,true,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 1,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(2, true, false, {})
+ screen:expect {
+ grid = [[
|
spam^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=2,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 2,
+ anchor = { 1, 1, 0 },
+ },
+ }
- meths.select_popupmenu_item(0,true,true,{})
+ meths.select_popupmenu_item(0, true, true, {})
screen:expect([[
|
foo^ |
@@ -135,68 +155,82 @@ describe('ui/ext_popupmenu', function()
{2:-- INSERT --} |
]])
-
feed('<c-w><C-r>=TestComplete()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(-1,false,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(-1, false, false, {})
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=-1,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(1,true,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = -1,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(1, true, false, {})
+ screen:expect {
+ grid = [[
|
bar^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=1,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(-1,true,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 1,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(-1, true, false, {})
+ screen:expect {
+ grid = [[
|
^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=-1,
- anchor={1,1,0},
- }}
-
- meths.select_popupmenu_item(0,true,false,{})
- screen:expect{grid=[[
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = -1,
+ anchor = { 1, 1, 0 },
+ },
+ }
+
+ meths.select_popupmenu_item(0, true, false, {})
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
- meths.select_popupmenu_item(-1,true,true,{})
+ meths.select_popupmenu_item(-1, true, true, {})
screen:expect([[
|
^ |
@@ -207,108 +241,133 @@ describe('ui/ext_popupmenu', function()
command('set wildmenu')
command('set wildoptions=pum')
local expected_wildpum = {
- { "define", "", "", "" },
- { "jump", "", "", "" },
- { "list", "", "", "" },
- { "place", "", "", "" },
- { "undefine", "", "", "" },
- { "unplace", "", "", "" },
+ { 'define', '', '', '' },
+ { 'jump', '', '', '' },
+ { 'list', '', '', '' },
+ { 'place', '', '', '' },
+ { 'undefine', '', '', '' },
+ { 'unplace', '', '', '' },
}
feed('<Esc>:sign <Tab>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign define^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = 0,
+ anchor = { 1, 7, 6 },
+ },
+ })
meths.select_popupmenu_item(-1, true, false, {})
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign ^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = -1,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = -1,
+ anchor = { 1, 7, 6 },
+ },
+ })
meths.select_popupmenu_item(5, true, false, {})
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign unplace^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = 5,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = 5,
+ anchor = { 1, 7, 6 },
+ },
+ })
meths.select_popupmenu_item(-1, true, true, {})
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign ^ |
- ]]})
+ ]],
+ })
feed('<Tab>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign define^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = 0,
+ anchor = { 1, 7, 6 },
+ },
+ })
meths.select_popupmenu_item(5, true, true, {})
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|*2
{1:~ }|*5
:sign unplace^ |
- ]]})
+ ]],
+ })
local function test_pum_select_mappings()
screen:set_option('ext_popupmenu', true)
feed('<Esc>A<C-r>=TestComplete()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<f1>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
spam^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=2,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 2,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<f2>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
spam^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=-1,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = -1,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<f3>')
screen:expect([[
@@ -319,48 +378,59 @@ describe('ui/ext_popupmenu', function()
]])
feed('<Esc>:sign <Tab>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|
bar |
{1:~ }|*5
:sign define^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = 0,
+ anchor = { 1, 7, 6 },
+ },
+ })
feed('<f1>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|
bar |
{1:~ }|*5
:sign list^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = 2,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = 2,
+ anchor = { 1, 7, 6 },
+ },
+ })
feed('<f2>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|
bar |
{1:~ }|*5
:sign ^ |
- ]], popupmenu = {
- items = expected_wildpum,
- pos = -1,
- anchor = { 1, 7, 6 },
- }})
+ ]],
+ popupmenu = {
+ items = expected_wildpum,
+ pos = -1,
+ anchor = { 1, 7, 6 },
+ },
+ })
feed('<f3>')
- screen:expect({grid = [[
+ screen:expect({
+ grid = [[
|
bar |
{1:~ }|*5
:sign jump^ |
- ]]})
+ ]],
+ })
-- also should work for builtin popupmenu
screen:set_option('ext_popupmenu', false)
@@ -523,18 +593,18 @@ describe('ui/ext_popupmenu', function()
it('can set pum height', function()
source_complete_month()
local month_expected = {
- {'January', '', '', ''},
- {'February', '', '', ''},
- {'March', '', '', ''},
- {'April', '', '', ''},
- {'May', '', '', ''},
- {'June', '', '', ''},
- {'July', '', '', ''},
- {'August', '', '', ''},
- {'September', '', '', ''},
- {'October', '', '', ''},
- {'November', '', '', ''},
- {'December', '', '', ''},
+ { 'January', '', '', '' },
+ { 'February', '', '', '' },
+ { 'March', '', '', '' },
+ { 'April', '', '', '' },
+ { 'May', '', '', '' },
+ { 'June', '', '', '' },
+ { 'July', '', '', '' },
+ { 'August', '', '', '' },
+ { 'September', '', '', '' },
+ { 'October', '', '', '' },
+ { 'November', '', '', '' },
+ { 'December', '', '', '' },
}
local pum_height = 6
feed('o<C-r>=TestCompleteMonth()<CR>')
@@ -542,29 +612,30 @@ describe('ui/ext_popupmenu', function()
feed('<PageDown>')
-- pos becomes pum_height-2 because it is subtracting 2 to keep some
-- context in ins_compl_key2count()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
January^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=month_expected,
- pos=pum_height-2,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = month_expected,
+ pos = pum_height - 2,
+ anchor = { 1, 1, 0 },
+ },
+ }
end)
it('an error occurs if set 0 or less', function()
meths.ui_pum_set_height(1)
- eq('Expected pum height > 0',
- pcall_err(meths.ui_pum_set_height, 0))
+ eq('Expected pum height > 0', pcall_err(meths.ui_pum_set_height, 0))
end)
it('an error occurs when ext_popupmenu is false', function()
meths.ui_pum_set_height(1)
screen:set_option('ext_popupmenu', false)
- eq('It must support the ext_popupmenu option',
- pcall_err(meths.ui_pum_set_height, 1))
+ eq('It must support the ext_popupmenu option', pcall_err(meths.ui_pum_set_height, 1))
end)
end)
@@ -572,18 +643,18 @@ describe('ui/ext_popupmenu', function()
it('can set pum bounds', function()
source_complete_month()
local month_expected = {
- {'January', '', '', ''},
- {'February', '', '', ''},
- {'March', '', '', ''},
- {'April', '', '', ''},
- {'May', '', '', ''},
- {'June', '', '', ''},
- {'July', '', '', ''},
- {'August', '', '', ''},
- {'September', '', '', ''},
- {'October', '', '', ''},
- {'November', '', '', ''},
- {'December', '', '', ''},
+ { 'January', '', '', '' },
+ { 'February', '', '', '' },
+ { 'March', '', '', '' },
+ { 'April', '', '', '' },
+ { 'May', '', '', '' },
+ { 'June', '', '', '' },
+ { 'July', '', '', '' },
+ { 'August', '', '', '' },
+ { 'September', '', '', '' },
+ { 'October', '', '', '' },
+ { 'November', '', '', '' },
+ { 'December', '', '', '' },
}
local pum_height = 6
feed('o<C-r>=TestCompleteMonth()<CR>')
@@ -593,16 +664,19 @@ describe('ui/ext_popupmenu', function()
feed('<PageDown>')
-- pos becomes pum_height-2 because it is subtracting 2 to keep some
-- context in ins_compl_key2count()
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
January^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=month_expected,
- pos=pum_height-2,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = month_expected,
+ pos = pum_height - 2,
+ anchor = { 1, 1, 0 },
+ },
+ }
end)
it('no error occurs if row or col set less than 0', function()
@@ -613,73 +687,79 @@ describe('ui/ext_popupmenu', function()
it('an error occurs if width or height set 0 or less', function()
meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
- eq('Expected width > 0',
- pcall_err(meths.ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
- eq('Expected height > 0',
- pcall_err(meths.ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0))
+ eq('Expected width > 0', pcall_err(meths.ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
+ eq('Expected height > 0', pcall_err(meths.ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0))
end)
it('an error occurs when ext_popupmenu is false', function()
meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
screen:set_option('ext_popupmenu', false)
- eq('UI must support the ext_popupmenu option',
- pcall_err(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5))
+ eq(
+ 'UI must support the ext_popupmenu option',
+ pcall_err(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
+ )
end)
end)
it('<PageUP>, <PageDown> works without ui_pum_set_height', function()
source_complete_month()
local month_expected = {
- {'January', '', '', ''},
- {'February', '', '', ''},
- {'March', '', '', ''},
- {'April', '', '', ''},
- {'May', '', '', ''},
- {'June', '', '', ''},
- {'July', '', '', ''},
- {'August', '', '', ''},
- {'September', '', '', ''},
- {'October', '', '', ''},
- {'November', '', '', ''},
- {'December', '', '', ''},
+ { 'January', '', '', '' },
+ { 'February', '', '', '' },
+ { 'March', '', '', '' },
+ { 'April', '', '', '' },
+ { 'May', '', '', '' },
+ { 'June', '', '', '' },
+ { 'July', '', '', '' },
+ { 'August', '', '', '' },
+ { 'September', '', '', '' },
+ { 'October', '', '', '' },
+ { 'November', '', '', '' },
+ { 'December', '', '', '' },
}
feed('o<C-r>=TestCompleteMonth()<CR>')
feed('<PageDown>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
January^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=month_expected,
- pos=3,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = month_expected,
+ pos = 3,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<PageUp>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
January^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=month_expected,
- pos=0,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = month_expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
end)
it('works with wildoptions=pum', function()
- screen:try_resize(32,10)
+ screen:try_resize(32, 10)
command('set wildmenu')
command('set wildoptions=pum')
local wild_expected = {
- {'define', '', '', ''},
- {'jump', '', '', ''},
- {'list', '', '', ''},
- {'place', '', '', ''},
- {'undefine', '', '', ''},
- {'unplace', '', '', ''},
+ { 'define', '', '', '' },
+ { 'jump', '', '', '' },
+ { 'list', '', '', '' },
+ { 'place', '', '', '' },
+ { 'undefine', '', '', '' },
+ { 'unplace', '', '', '' },
}
feed(':sign ')
@@ -691,26 +771,35 @@ describe('ui/ext_popupmenu', function()
eq(0, funcs.wildmenumode())
feed('<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*8
:sign define^ |
- ]], popupmenu={items=wild_expected, pos=0, anchor={1, 9, 6}}}
+ ]],
+ popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } },
+ }
eq(1, funcs.wildmenumode())
feed('<left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*8
:sign ^ |
- ]], popupmenu={items=wild_expected, pos=-1, anchor={1, 9, 6}}}
+ ]],
+ popupmenu = { items = wild_expected, pos = -1, anchor = { 1, 9, 6 } },
+ }
feed('<left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*8
:sign unplace^ |
- ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}}
+ ]],
+ popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
+ }
feed('x')
screen:expect([[
@@ -722,19 +811,23 @@ describe('ui/ext_popupmenu', function()
-- #10042: make sure shift-tab also triggers the pum
feed(':sign <S-tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*8
:sign unplace^ |
- ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}}
+ ]],
+ popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
+ }
feed('<esc>')
eq(0, funcs.wildmenumode())
-- check positioning with multibyte char in pattern
- command("e långfile1")
- command("sp långfile2")
+ command('e långfile1')
+ command('sp långfile2')
feed(':b lå<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
{4:långfile2 }|
@@ -742,12 +835,13 @@ describe('ui/ext_popupmenu', function()
{1:~ }|*2
{3:långfile1 }|
:b långfile1^ |
- ]], popupmenu={
- anchor = {1, 9, 3},
- items = {{"långfile1", "", "", "" }, {"långfile2", "", "", ""}},
- pos = 0,
- }}
-
+ ]],
+ popupmenu = {
+ anchor = { 1, 9, 3 },
+ items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
+ pos = 0,
+ },
+ }
end)
it('does not interfere with mousemodel=popup', function()
@@ -760,36 +854,44 @@ describe('ui/ext_popupmenu', function()
menu PopUp.baz :let g:menustr = 'baz'<CR>
]])
feed('o<C-r>=TestComplete()<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
foo^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=0,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = 0,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<c-p>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
^ |
{1:~ }|*5
{2:-- INSERT --} |
- ]], popupmenu={
- items=expected,
- pos=-1,
- anchor={1,1,0},
- }}
+ ]],
+ popupmenu = {
+ items = expected,
+ pos = -1,
+ anchor = { 1, 1, 0 },
+ },
+ }
feed('<esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
^ |
{1:~ }|*5
|
- ]]}
+ ]],
+ }
feed('<RightMouse><0,0>')
screen:expect([[
|
@@ -815,51 +917,51 @@ describe("builtin popupmenu 'pumblend'", function()
it('RGB-color', function()
local screen = Screen.new(60, 14)
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Yellow},
- [2] = {bold = true, reverse = true},
- [3] = {bold = true, foreground = Screen.colors.Brown},
- [4] = {foreground = Screen.colors.Blue1},
- [5] = {reverse = true},
- [6] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey45},
- [7] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey0},
- [8] = {background = tonumber('0x191919'), foreground = Screen.colors.Grey0},
- [9] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5')},
- [10] = {background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0},
- [11] = {foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true},
- [12] = {foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true},
- [13] = {background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0},
- [14] = {background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5')},
- [15] = {background = tonumber('0xffc1ff'), foreground = tonumber('0x080202')},
- [16] = {background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9')},
- [17] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff')},
- [18] = {background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff')},
- [19] = {background = Screen.colors.Gray45, foreground = Screen.colors.Grey55},
- [20] = {bold = true},
- [21] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [22] = {background = Screen.colors.WebGray},
- [23] = {background = Screen.colors.Grey0},
- [24] = {background = Screen.colors.LightMagenta},
- [25] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey25},
- [26] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey0},
- [27] = {background = Screen.colors.Gray50, foreground = Screen.colors.Grey0},
- [28] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f')},
- [29] = {background = tonumber('0xffddff'), foreground = Screen.colors.Grey0},
- [30] = {foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true},
- [31] = {foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true},
- [32] = {foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true},
- [33] = {background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0},
- [34] = {background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f')},
- [35] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a')},
- [36] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294')},
- [37] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff')},
- [38] = {background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff')},
- [39] = {background = Screen.colors.Grey0, foreground = tonumber('0xffddff')},
- [40] = {background = Screen.colors.Gray25, foreground = Screen.colors.Grey75},
- [41] = {background = tonumber('0xffddff'), foreground = tonumber('0x00003f')},
- [42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')},
- [43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')},
- [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')},
- [45] = {background = Screen.colors.WebGray, blend=0},
+ [1] = { background = Screen.colors.Yellow },
+ [2] = { bold = true, reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.Brown },
+ [4] = { foreground = Screen.colors.Blue1 },
+ [5] = { reverse = true },
+ [6] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey45 },
+ [7] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey0 },
+ [8] = { background = tonumber('0x191919'), foreground = Screen.colors.Grey0 },
+ [9] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5') },
+ [10] = { background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0 },
+ [11] = { foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true },
+ [12] = { foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true },
+ [13] = { background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0 },
+ [14] = { background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5') },
+ [15] = { background = tonumber('0xffc1ff'), foreground = tonumber('0x080202') },
+ [16] = { background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9') },
+ [17] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff') },
+ [18] = { background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff') },
+ [19] = { background = Screen.colors.Gray45, foreground = Screen.colors.Grey55 },
+ [20] = { bold = true },
+ [21] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [22] = { background = Screen.colors.WebGray },
+ [23] = { background = Screen.colors.Grey0 },
+ [24] = { background = Screen.colors.LightMagenta },
+ [25] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey25 },
+ [26] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey0 },
+ [27] = { background = Screen.colors.Gray50, foreground = Screen.colors.Grey0 },
+ [28] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f') },
+ [29] = { background = tonumber('0xffddff'), foreground = Screen.colors.Grey0 },
+ [30] = { foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true },
+ [31] = { foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true },
+ [32] = { foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true },
+ [33] = { background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0 },
+ [34] = { background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f') },
+ [35] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a') },
+ [36] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294') },
+ [37] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff') },
+ [38] = { background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff') },
+ [39] = { background = Screen.colors.Grey0, foreground = tonumber('0xffddff') },
+ [40] = { background = Screen.colors.Gray25, foreground = Screen.colors.Grey75 },
+ [41] = { background = tonumber('0xffddff'), foreground = tonumber('0x00003f') },
+ [42] = { foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5') },
+ [43] = { background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f') },
+ [44] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') },
+ [45] = { background = Screen.colors.WebGray, blend = 0 },
})
screen:attach()
command('syntax on')
@@ -1013,18 +1115,18 @@ describe("builtin popupmenu 'pumblend'", function()
it('256-color (non-RGB)', function()
local screen = Screen.new(60, 8)
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.Grey0, background = tonumber('0x000007')},
- [2] = {foreground = tonumber('0x000055'), background = tonumber('0x000007')},
- [3] = {foreground = tonumber('0x00008f'), background = Screen.colors.Grey0},
- [4] = {foreground = Screen.colors.Grey0, background = tonumber('0x0000e1')},
- [5] = {foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1')},
- [6] = {foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8')},
- [7] = {foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8')},
- [8] = {foreground = tonumber('0x00000c')},
- [9] = {bold = true},
- [10] = {foreground = tonumber('0x000002')},
+ [1] = { foreground = Screen.colors.Grey0, background = tonumber('0x000007') },
+ [2] = { foreground = tonumber('0x000055'), background = tonumber('0x000007') },
+ [3] = { foreground = tonumber('0x00008f'), background = Screen.colors.Grey0 },
+ [4] = { foreground = Screen.colors.Grey0, background = tonumber('0x0000e1') },
+ [5] = { foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1') },
+ [6] = { foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8') },
+ [7] = { foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8') },
+ [8] = { foreground = tonumber('0x00000c') },
+ [9] = { bold = true },
+ [10] = { foreground = tonumber('0x000002') },
})
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
command('set notermguicolors pumblend=10')
insert([[
Lorem ipsum dolor sit amet, consectetur
@@ -1056,21 +1158,21 @@ describe('builtin popupmenu', function()
screen = Screen.new(32, 20)
screen:set_default_attr_ids({
-- popup selected item / scrollbar track
- ['s'] = {background = Screen.colors.WebGray},
+ ['s'] = { background = Screen.colors.WebGray },
-- popup non-selected item
- ['n'] = {background = Screen.colors.LightMagenta},
+ ['n'] = { background = Screen.colors.LightMagenta },
-- popup scrollbar knob
- ['c'] = {background = Screen.colors.Grey0},
- [1] = {bold = true, foreground = Screen.colors.Blue},
- [2] = {bold = true},
- [3] = {reverse = true},
- [4] = {bold = true, reverse = true},
- [5] = {bold = true, foreground = Screen.colors.SeaGreen},
- [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [7] = {background = Screen.colors.Yellow}, -- Search
- [8] = {foreground = Screen.colors.Red},
+ ['c'] = { background = Screen.colors.Grey0 },
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { bold = true },
+ [3] = { reverse = true },
+ [4] = { bold = true, reverse = true },
+ [5] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [7] = { background = Screen.colors.Yellow }, -- Search
+ [8] = { foreground = Screen.colors.Red },
})
- screen:attach({ext_multigrid=multigrid})
+ screen:attach({ ext_multigrid = multigrid })
end)
it('with preview-window above', function()
@@ -1078,7 +1180,8 @@ describe('builtin popupmenu', function()
feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
feed('<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:--------------------------------]|*8
{3:[No Name] [Preview][+] }|
@@ -1104,9 +1207,11 @@ describe('builtin popupmenu', function()
{n:ff }{c: }|
{n:gg }{s: }|
{n:hh }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 2, 0, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 2, 0, false, 100 },
+ },
+ }
else
screen:expect([[
aa bb cc dd ee ff gg hh ii jj |
@@ -1133,7 +1238,8 @@ describe('builtin popupmenu', function()
feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
feed('<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:--------------------------------]|*9
{4:[No Name] [+] }|
@@ -1159,9 +1265,11 @@ describe('builtin popupmenu', function()
{n:ff }{c: }|
{n:gg }{s: }|
{n:hh }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 2, 0, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 2, 0, false, 100 },
+ },
+ }
else
screen:expect([[
aa bb cc dd ee ff gg hh ii jj |
@@ -1190,7 +1298,8 @@ describe('builtin popupmenu', function()
feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>')
feed('<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:--------------------------------]|*4
{3:[No Name] [Preview][+] }|
@@ -1232,9 +1341,11 @@ describe('builtin popupmenu', function()
{n:kk }{c: }|
{n:ll }{s: }|
{n:mm }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "SW", 2, 12, 0, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'SW', 2, 12, 0, false, 100 },
+ },
+ }
else
screen:expect([[
aa |
@@ -1267,7 +1378,8 @@ describe('builtin popupmenu', function()
feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
feed('<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:--------------------------------]|*8
{3:[No Name] [Preview][+] }|
@@ -1305,9 +1417,11 @@ describe('builtin popupmenu', function()
{n:gg }{c: }|
{n:hh }{c: }|
{n:ii }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "SW", 2, 8, 0, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'SW', 2, 8, 0, false, 100 },
+ },
+ }
else
screen:expect([[
aa |
@@ -1340,7 +1454,8 @@ describe('builtin popupmenu', function()
feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
feed('<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:--------------------------------]|*9
{4:[No Name] [+] }|
@@ -1377,9 +1492,11 @@ describe('builtin popupmenu', function()
{n:ff }{c: }|
{n:gg }{s: }|
{n:hh }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "SW", 2, 8, 0, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'SW', 2, 8, 0, false, 100 },
+ },
+ }
else
screen:expect([[
{s:aa }{c: } |
@@ -1468,7 +1585,7 @@ describe('builtin popupmenu', function()
end)
end
- describe("floating window preview #popup", function()
+ describe('floating window preview #popup', function()
it('pum popup preview', function()
--row must > 10
screen:try_resize(30, 11)
@@ -1494,7 +1611,8 @@ describe('builtin popupmenu', function()
--floating preview in right
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:------------------------------]|*10
[3:------------------------------]|
@@ -1510,26 +1628,32 @@ describe('builtin popupmenu', function()
{s:one }|
{n:two }|
{n:three }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 1, 0, false, 100};
- [4] = {{id = 1001}, "NW", 1, 1, 15, true, 50};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 1, 0, false, 100 },
+ [4] = { { id = 1001 }, 'NW', 1, 1, 15, true, 50 },
+ },
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
one^ |
{s:one }{n:1info}{1: }|
{n:two }{1: }|
{n:three }{1: }|
{1:~ }|*6
{2:-- }{5:match 1 of 3} |
- ]], unchanged = true}
+ ]],
+ unchanged = true,
+ }
end
-- test nvim_complete_set_info
feed('<C-N><C-N>')
helpers.sleep(10)
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:------------------------------]|*10
[3:------------------------------]|
@@ -1545,19 +1669,23 @@ describe('builtin popupmenu', function()
{n:one }|
{n:two }|
{s:three }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 1, 0, false, 100};
- [4] = {{id = 1001}, "NW", 1, 1, 15, true, 50};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 1, 0, false, 100 },
+ [4] = { { id = 1001 }, 'NW', 1, 1, 15, true, 50 },
+ },
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
three^ |
{n:one 3info}{1: }|
{n:two }{1: }|
{s:three }{1: }|
{1:~ }|*6
{2:-- }{5:match 3 of 3} |
- ]]}
+ ]],
+ }
end
-- make sure info has set
feed('<C-y>')
@@ -1568,7 +1696,8 @@ describe('builtin popupmenu', function()
insert(('test'):rep(5))
feed('i<C-x><C-o>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:------------------------------]|*10
[3:------------------------------]|
@@ -1584,22 +1713,43 @@ describe('builtin popupmenu', function()
## grid 6
{n:1info}|
{n: }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 1, 19, false, 100};
- [6] = {{id = 1002}, "NW", 1, 1, 1, true, 50};
- }, win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 23, linecount = 1, sum_scroll_delta = 0};
- [6] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 1, 19, false, 100 },
+ [6] = { { id = 1002 }, 'NW', 1, 1, 1, true, 50 },
+ },
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 23,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ [6] = {
+ win = { id = 1002 },
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
itesttesttesttesttesone^t |
{1:~}{n:1info}{1: }{s: one }{1: }|
{1:~}{n: }{1: }{n: two }{1: }|
{1:~ }{n: three }{1: }|
{1:~ }|*6
{2:-- }{5:match 1 of 3} |
- ]]}
+ ]],
+ }
end
end)
end)
@@ -1609,7 +1759,8 @@ describe('builtin popupmenu', function()
insert('aaa aab aac\n')
feed(':vsplit<cr>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:--------------------]│[2:-----------]|*6
{4:[No Name] [+] }{3:<Name] [+] }|
@@ -1624,7 +1775,8 @@ describe('builtin popupmenu', function()
aaa aab aac |
^ |
{1:~ }|*4
- ]]}
+ ]],
+ }
else
screen:expect([[
aaa aab aac │aaa aab aac|
@@ -1637,7 +1789,8 @@ describe('builtin popupmenu', function()
feed('ibbb a<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:--------------------]│[2:-----------]|*6
{4:[No Name] [+] }{3:<Name] [+] }|
@@ -1656,9 +1809,11 @@ describe('builtin popupmenu', function()
{s: aaa }|
{n: aab }|
{n: aac }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 4, 2, 3, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 4, 2, 3, false, 100 },
+ },
+ }
else
screen:expect([[
aaa aab aac │aaa aab aac|
@@ -1674,7 +1829,8 @@ describe('builtin popupmenu', function()
feed('<esc><c-w><c-w>oc a<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:-----------]│[2:--------------------]|*6
{3:<Name] [+] }{4:[No Name] [+] }|
@@ -1695,9 +1851,11 @@ describe('builtin popupmenu', function()
{s: aaa }|
{n: aab }|
{n: aac }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 3, 1, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 3, 1, false, 100 },
+ },
+ }
else
screen:expect([[
aaa aab aac│aaa aab aac |
@@ -1713,7 +1871,8 @@ describe('builtin popupmenu', function()
feed('bcdef ccc a<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:-----------]│[2:--------------------]|*6
{3:<Name] [+] }{4:[No Name] [+] }|
@@ -1736,9 +1895,11 @@ describe('builtin popupmenu', function()
{n: aab }|
{n: aac }|
{n: aaabcdef}|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 3, 11, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 3, 11, false, 100 },
+ },
+ }
else
screen:expect([[
aaa aab aac│aaa aab aac |
@@ -1754,7 +1915,8 @@ describe('builtin popupmenu', function()
feed('\n<c-x><c-n>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[4:-----------]│[2:--------------------]|*6
{3:<Name] [+] }{4:[No Name] [+] }|
@@ -1778,9 +1940,11 @@ describe('builtin popupmenu', function()
{s: aaa }{c: }|
{n: aab }{s: }|
{n: aac }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 2, 4, -1, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 2, 4, -1, false, 100 },
+ },
+ }
else
screen:expect([[
aaa aab aac│aaa aab aac |
@@ -1797,10 +1961,10 @@ describe('builtin popupmenu', function()
if not multigrid then
it('with split and scroll', function()
- screen:try_resize(60,14)
- command("split")
- command("set completeopt+=noinsert")
- command("set mouse=a")
+ screen:try_resize(60, 14)
+ command('split')
+ command('set completeopt+=noinsert')
+ command('set mouse=a')
insert([[
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
@@ -1994,7 +2158,10 @@ describe('builtin popupmenu', function()
{2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
]])
- funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'})
+ funcs.complete(
+ 4,
+ { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }
+ )
screen:expect([[
Est eu^ |
{s: ea }t amet, consectetur |
@@ -2012,7 +2179,7 @@ describe('builtin popupmenu', function()
{2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} |
]])
- funcs.complete(4, {'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'})
+ funcs.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
screen:expect([[
Est eu^ |
{s: ea }r sit amet, consectetur |
@@ -2048,7 +2215,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- funcs.complete(6, {'foo', 'bar'})
+ funcs.complete(6, { 'foo', 'bar' })
screen:expect([[
Esteee^ |
Lo{s: foo }sit amet, consectetur |
@@ -2087,9 +2254,9 @@ describe('builtin popupmenu', function()
it('can be moved due to wrap or resize', function()
feed('isome long prefix before the ')
- command("set completeopt+=noinsert,noselect")
- command("set linebreak")
- funcs.complete(29, {'word', 'choice', 'text', 'thing'})
+ command('set completeopt+=noinsert,noselect')
+ command('set linebreak')
+ funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
some long prefix before the ^ |
{1:~ }{n: word }|
@@ -2123,7 +2290,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- screen:try_resize(30,8)
+ screen:try_resize(30, 8)
screen:expect([[
some long prefix before the |
text^ |
@@ -2135,7 +2302,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- screen:try_resize(50,8)
+ screen:try_resize(50, 8)
screen:expect([[
some long prefix before the text^ |
{1:~ }{n: word }{1: }|
@@ -2146,7 +2313,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- screen:try_resize(25,10)
+ screen:try_resize(25, 10)
screen:expect([[
some long prefix before |
the text^ |
@@ -2158,7 +2325,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- screen:try_resize(12,5)
+ screen:try_resize(12, 5)
screen:expect([[
some long |
prefix |
@@ -2168,14 +2335,14 @@ describe('builtin popupmenu', function()
]])
-- can't draw the pum, but check we don't crash
- screen:try_resize(12,2)
+ screen:try_resize(12, 2)
screen:expect([[
{1:<<<}t^ |
{2:-- INSERT --}|
]])
-- but state is preserved, pum reappears
- screen:try_resize(20,8)
+ screen:try_resize(20, 8)
screen:expect([[
some long prefix |
before the text^ |
@@ -2190,10 +2357,10 @@ describe('builtin popupmenu', function()
it('with VimResized autocmd', function()
feed('isome long prefix before the ')
- command("set completeopt+=noinsert,noselect")
- command("autocmd VimResized * redraw!")
- command("set linebreak")
- funcs.complete(29, {'word', 'choice', 'text', 'thing'})
+ command('set completeopt+=noinsert,noselect')
+ command('autocmd VimResized * redraw!')
+ command('set linebreak')
+ funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
some long prefix before the ^ |
{1:~ }{n: word }|
@@ -2204,7 +2371,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- screen:try_resize(16,10)
+ screen:try_resize(16, 10)
screen:expect([[
some long |
prefix before |
@@ -2219,7 +2386,7 @@ describe('builtin popupmenu', function()
end)
it('with rightleft window', function()
- command("set rl wildoptions+=pum")
+ command('set rl wildoptions+=pum')
feed('isome rightleft ')
screen:expect([[
^ tfelthgir emos|
@@ -2227,8 +2394,8 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- command("set completeopt+=noinsert,noselect")
- funcs.complete(16, {'word', 'choice', 'text', 'thing'})
+ command('set completeopt+=noinsert,noselect')
+ funcs.complete(16, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
^ tfelthgir emos|
{1: }{n: drow }{1: ~}|
@@ -2259,14 +2426,17 @@ describe('builtin popupmenu', function()
-- not rightleft on the cmdline
feed('<esc>:sign ')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
drow tfelthgir emos|
{1: ~}|*18
:sign ^ |
- ]]}
+ ]],
+ }
feed('<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
drow tfelthgir emos|
{1: ~}|*12
{1: }{s: define }{1: ~}|
@@ -2276,7 +2446,8 @@ describe('builtin popupmenu', function()
{1: }{n: undefine }{1: ~}|
{1: }{n: unplace }{1: ~}|
:sign define^ |
- ]]}
+ ]],
+ }
end)
end
@@ -2287,9 +2458,10 @@ describe('builtin popupmenu', function()
command('set completeopt+=noinsert,noselect')
command('set pumheight=2')
feed('isome rightleft ')
- funcs.complete(16, {'word', 'choice', 'text', 'thing'})
+ funcs.complete(16, { 'word', 'choice', 'text', 'thing' })
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------]│[4:--------------------]|*4
{3:[No Name] [+] }{4:[No Name] [+] }|
@@ -2305,9 +2477,11 @@ describe('builtin popupmenu', function()
## grid 5
{c: }{n: drow }|
{s: }{n: eciohc }|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 4, 1, -11, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 4, 1, -11, false, 100 },
+ },
+ }
else
screen:expect([[
tfelthgir emos│ ^ tfelthgir emos|
@@ -2319,9 +2493,10 @@ describe('builtin popupmenu', function()
]])
end
feed('<C-E><CR>')
- funcs.complete(1, {'word', 'choice', 'text', 'thing'})
+ funcs.complete(1, { 'word', 'choice', 'text', 'thing' })
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------]│[4:--------------------]|*4
{3:[No Name] [+] }{4:[No Name] [+] }|
@@ -2339,9 +2514,11 @@ describe('builtin popupmenu', function()
## grid 5
{c: }{n: drow}|
{s: }{n: eciohc}|
- ]], float_pos={
- [5] = {{id = -1}, "NW", 4, 2, 4, false, 100};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'NW', 4, 2, 4, false, 100 },
+ },
+ }
else
screen:expect([[
tfelthgir emos│ tfelthgir emos|
@@ -2353,9 +2530,10 @@ describe('builtin popupmenu', function()
]])
end
feed('<C-E>')
- async_meths.call_function('input', {'', '', 'sign'})
+ async_meths.call_function('input', { '', '', 'sign' })
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------]│[4:--------------------]|*4
{3:[No Name] [+] }{4:[No Name] [+] }|
@@ -2370,7 +2548,8 @@ describe('builtin popupmenu', function()
tfelthgir emos|
|
{1: ~}|*2
- ]]}
+ ]],
+ }
else
screen:expect([[
tfelthgir emos│ tfelthgir emos|
@@ -2383,7 +2562,8 @@ describe('builtin popupmenu', function()
command('set wildoptions+=pum')
feed('<Tab>')
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:-------------------]│[4:--------------------]|*4
{3:[No Name] [+] }{4:[No Name] [+] }|
@@ -2401,9 +2581,11 @@ describe('builtin popupmenu', function()
## grid 5
{s:define }{c: }|
{n:jump }{s: }|
- ]], float_pos={
- [5] = {{id = -1}, "SW", 1, 5, 0, false, 250};
- }}
+ ]],
+ float_pos = {
+ [5] = { { id = -1 }, 'SW', 1, 5, 0, false, 250 },
+ },
+ }
else
screen:expect([[
tfelthgir emos│ tfelthgir emos|
@@ -2418,10 +2600,10 @@ describe('builtin popupmenu', function()
if not multigrid then
it('with multiline messages', function()
- screen:try_resize(40,8)
+ screen:try_resize(40, 8)
feed('ixx<cr>')
command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>')
- funcs.complete(1, {'word', 'choice', 'text', 'thing'})
+ funcs.complete(1, { 'word', 'choice', 'text', 'thing' })
screen:expect([[
xx |
word^ |
@@ -2469,7 +2651,7 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
]])
- command("split")
+ command('split')
screen:expect([[
xx |
choice^ |
@@ -2482,7 +2664,8 @@ describe('builtin popupmenu', function()
]])
meths.input_mouse('wheel', 'down', '', 0, 6, 15)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
xx |
choice^ |
{n:word }{1: }|
@@ -2491,13 +2674,19 @@ describe('builtin popupmenu', function()
{n:thing }{1: }|
{3:[No Name] [+] }|
{2:-- INSERT --} |
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end)
it('with kind, menu and abbr attributes', function()
- screen:try_resize(40,8)
+ screen:try_resize(40, 8)
feed('ixx ')
- funcs.complete(4, {{word='wordey', kind= 'x', menu='extrainfo'}, 'thing', {word='secret', abbr='sneaky', menu='bar'}})
+ funcs.complete(4, {
+ { word = 'wordey', kind = 'x', menu = 'extrainfo' },
+ 'thing',
+ { word = 'secret', abbr = 'sneaky', menu = 'bar' },
+ })
screen:expect([[
xx wordey^ |
{1:~ }{s: wordey x extrainfo }{1: }|
@@ -2536,11 +2725,11 @@ describe('builtin popupmenu', function()
end)
it('wildoptions=pum', function()
- screen:try_resize(32,10)
+ screen:try_resize(32, 10)
command('set wildmenu')
command('set wildoptions=pum')
command('set shellslash')
- command("cd test/functional/fixtures/wildpum")
+ command('cd test/functional/fixtures/wildpum')
feed(':sign ')
screen:expect([[
@@ -2999,8 +3188,8 @@ describe('builtin popupmenu', function()
feed('<Esc>')
-- check positioning with multibyte char in pattern
- command("e långfile1")
- command("sp långfile2")
+ command('e långfile1')
+ command('sp långfile2')
feed(':b lå<tab>')
screen:expect([[
|
@@ -3014,7 +3203,7 @@ describe('builtin popupmenu', function()
]])
-- check doesn't crash on screen resize
- screen:try_resize(20,6)
+ screen:try_resize(20, 6)
screen:expect([[
|
{1:~ }|
@@ -3024,7 +3213,7 @@ describe('builtin popupmenu', function()
:b långfile1^ |
]])
- screen:try_resize(50,15)
+ screen:try_resize(50, 15)
screen:expect([[
|
{1:~ }|
@@ -3052,7 +3241,7 @@ describe('builtin popupmenu', function()
]])
feed('<esc>')
- command("close")
+ command('close')
command('set wildmode=full')
-- special case: when patterns ends with "/", show menu items aligned
@@ -3068,22 +3257,25 @@ describe('builtin popupmenu', function()
end)
it('wildoptions=pum with scrolled messages', function()
- screen:try_resize(40,10)
+ screen:try_resize(40, 10)
command('set wildmenu')
command('set wildoptions=pum')
feed(':echoerr "fail"|echoerr "error"<cr>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*5
{4: }|
{6:fail} |
{6:error} |
{5:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
feed(':sign <tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{1:~ }{s: define }{1: }|
@@ -3093,21 +3285,24 @@ describe('builtin popupmenu', function()
{6:fail} {n: undefine } |
{6:error}{n: unplace } |
:sign define^ |
- ]]}
+ ]],
+ }
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*5
{4: }|
{6:fail} |
{6:error} |
:sign defined^ |
- ]]}
+ ]],
+ }
end)
it('wildoptions=pum and wildmode=longest,full #11622', function()
- screen:try_resize(30,8)
+ screen:try_resize(30, 8)
command('set wildmenu')
command('set wildoptions=pum')
command('set wildmode=longest,full')
@@ -3115,33 +3310,39 @@ describe('builtin popupmenu', function()
-- With 'wildmode' set to 'longest,full', completing a match should display
-- the longest match, the wildmenu should not be displayed.
feed(':sign u<Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*6
:sign un^ |
- ]]}
+ ]],
+ }
eq(0, funcs.wildmenumode())
-- pressing <Tab> should display the wildmenu
feed('<Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*4
{1:~ }{s: undefine }{1: }|
{1:~ }{n: unplace }{1: }|
:sign undefine^ |
- ]]}
+ ]],
+ }
eq(1, funcs.wildmenumode())
-- pressing <Tab> second time should select the next entry in the menu
feed('<Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*4
{1:~ }{n: undefine }{1: }|
{1:~ }{s: unplace }{1: }|
:sign unplace^ |
- ]]}
+ ]],
+ }
end)
it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function()
@@ -3255,14 +3456,15 @@ describe('builtin popupmenu', function()
end
it("'pumheight'", function()
- screen:try_resize(32,8)
+ screen:try_resize(32, 8)
feed('isome long prefix before the ')
- command("set completeopt+=noinsert,noselect")
- command("set linebreak")
- command("set pumheight=2")
- funcs.complete(29, {'word', 'choice', 'text', 'thing'})
+ command('set completeopt+=noinsert,noselect')
+ command('set linebreak')
+ command('set pumheight=2')
+ funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:--------------------------------]|*7
[3:--------------------------------]|
@@ -3274,9 +3476,11 @@ describe('builtin popupmenu', function()
## grid 4
{n: word }{c: }|
{n: choice}{s: }|
- ]], float_pos={
- [4] = {{id = -1}, "NW", 2, 1, 24, false, 100};
- }}
+ ]],
+ float_pos = {
+ [4] = { { id = -1 }, 'NW', 2, 1, 24, false, 100 },
+ },
+ }
else
screen:expect([[
some long prefix before the ^ |
@@ -3289,14 +3493,15 @@ describe('builtin popupmenu', function()
end)
it("'pumwidth'", function()
- screen:try_resize(32,8)
+ screen:try_resize(32, 8)
feed('isome long prefix before the ')
- command("set completeopt+=noinsert,noselect")
- command("set linebreak")
- command("set pumwidth=8")
- funcs.complete(29, {'word', 'choice', 'text', 'thing'})
+ command('set completeopt+=noinsert,noselect')
+ command('set linebreak')
+ command('set pumwidth=8')
+ funcs.complete(29, { 'word', 'choice', 'text', 'thing' })
if multigrid then
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
## grid 1
[2:--------------------------------]|*7
[3:--------------------------------]|
@@ -3310,9 +3515,11 @@ describe('builtin popupmenu', function()
{n: choice}|
{n: text }|
{n: thing }|
- ]], float_pos={
- [4] = {{id = -1}, "NW", 2, 1, 25, false, 100};
- }}
+ ]],
+ float_pos = {
+ [4] = { { id = -1 }, 'NW', 2, 1, 25, false, 100 },
+ },
+ }
else
screen:expect([[
some long prefix before the ^ |
@@ -3328,14 +3535,14 @@ describe('builtin popupmenu', function()
it('does not crash when displayed in the last column with rightleft #12032', function()
local col = 30
- local items = {'word', 'choice', 'text', 'thing'}
+ local items = { 'word', 'choice', 'text', 'thing' }
local max_len = 0
for _, v in ipairs(items) do
max_len = max_len < #v and #v or max_len
end
screen:try_resize(col, 8)
command('set rightleft')
- command('call setline(1, repeat(" ", &columns - '..max_len..'))')
+ command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))')
feed('$i')
funcs.complete(col - max_len, items)
feed('<c-y>')
@@ -3346,9 +3553,10 @@ describe('builtin popupmenu', function()
screen:try_resize(32, 8)
command('set completeopt+=menuone,noselect')
feed('i' .. string.rep(' ', 13))
- funcs.complete(14, {'哦哦哦哦哦哦哦哦哦哦'})
+ funcs.complete(14, { '哦哦哦哦哦哦哦哦哦哦' })
if multigrid then
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*7
[3:--------------------------------]|
@@ -3359,7 +3567,9 @@ describe('builtin popupmenu', function()
{2:-- INSERT --} |
## grid 4
{n: 哦哦哦哦哦哦哦哦哦>}|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 12, false, 100}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 12, false, 100 } },
+ })
else
screen:expect([[
^ |
@@ -3371,17 +3581,18 @@ describe('builtin popupmenu', function()
end)
it('truncates double-width character correctly with scrollbar', function()
- screen:try_resize(32,8)
+ screen:try_resize(32, 8)
command('set completeopt+=noselect')
command('set pumheight=4')
feed('i' .. string.rep(' ', 12))
local items = {}
for _ = 1, 8 do
- table.insert(items, {word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1})
+ table.insert(items, { word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1 })
end
funcs.complete(13, items)
if multigrid then
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*7
[3:--------------------------------]|
@@ -3393,7 +3604,9 @@ describe('builtin popupmenu', function()
## grid 4
{n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2
{n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 11, false, 100}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 11, false, 100 } },
+ })
else
screen:expect([[
^ |
@@ -3419,7 +3632,8 @@ describe('builtin popupmenu', function()
if multigrid then
meths.input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3432,7 +3646,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
feed('<RightMouse><4,0>')
screen:expect([[
@@ -3446,7 +3662,8 @@ describe('builtin popupmenu', function()
end
feed('<Down>')
if multigrid then
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3459,7 +3676,9 @@ describe('builtin popupmenu', function()
{s: foo }|
{n: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
screen:expect([[
^popup menu test |
@@ -3472,7 +3691,8 @@ describe('builtin popupmenu', function()
end
feed('<Down>')
if multigrid then
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3485,7 +3705,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{s: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
screen:expect([[
^popup menu test |
@@ -3498,7 +3720,8 @@ describe('builtin popupmenu', function()
end
feed('<CR>')
if multigrid then
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3507,7 +3730,8 @@ describe('builtin popupmenu', function()
{1:~ }|*4
## grid 3
:let g:menustr = 'bar' |
- ]]})
+ ]],
+ })
else
screen:expect([[
^popup menu test |
@@ -3519,7 +3743,8 @@ describe('builtin popupmenu', function()
if multigrid then
meths.input_mouse('right', 'press', '', 2, 2, 20)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3532,7 +3757,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 3, 19, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 3, 19, false, 250 } },
+ })
else
feed('<RightMouse><20,2>')
screen:expect([[
@@ -3545,7 +3772,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('left', 'press', '', 4, 2, 2)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3554,7 +3782,8 @@ describe('builtin popupmenu', function()
{1:~ }|*4
## grid 3
:let g:menustr = 'baz' |
- ]]})
+ ]],
+ })
else
feed('<LeftMouse><22,5>')
screen:expect([[
@@ -3567,7 +3796,8 @@ describe('builtin popupmenu', function()
if multigrid then
meths.input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3580,7 +3810,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
feed('<RightMouse><4,0>')
screen:expect([[
@@ -3594,7 +3826,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('right', 'drag', '', 2, 3, 6)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3607,7 +3840,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{s: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
feed('<RightDrag><6,3>')
screen:expect([[
@@ -3621,7 +3856,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('right', 'release', '', 2, 1, 6)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3630,7 +3866,8 @@ describe('builtin popupmenu', function()
{1:~ }|*4
## grid 3
:let g:menustr = 'foo' |
- ]]})
+ ]],
+ })
else
feed('<RightRelease><6,1>')
screen:expect([[
@@ -3644,7 +3881,8 @@ describe('builtin popupmenu', function()
eq(false, screen.options.mousemoveevent)
if multigrid then
meths.input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3657,7 +3895,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{n: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
feed('<RightMouse><4,0>')
screen:expect([[
@@ -3672,7 +3912,8 @@ describe('builtin popupmenu', function()
eq(true, screen.options.mousemoveevent)
if multigrid then
meths.input_mouse('move', '', '', 2, 3, 6)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3685,7 +3926,9 @@ describe('builtin popupmenu', function()
{n: foo }|
{n: bar }|
{s: baz }|
- ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'NW', 2, 1, 3, false, 250 } },
+ })
else
feed('<MouseMove><6,3>')
screen:expect([[
@@ -3700,7 +3943,8 @@ describe('builtin popupmenu', function()
eq(true, screen.options.mousemoveevent)
if multigrid then
meths.input_mouse('left', 'press', '', 2, 2, 6)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*5
[3:--------------------------------]|
@@ -3709,7 +3953,8 @@ describe('builtin popupmenu', function()
{1:~ }|*4
## grid 3
:let g:menustr = 'bar' |
- ]]})
+ ]],
+ })
else
feed('<LeftMouse><6,2>')
screen:expect([[
@@ -3724,7 +3969,8 @@ describe('builtin popupmenu', function()
command('set laststatus=0 | botright split')
if multigrid then
meths.input_mouse('right', 'press', '', 5, 1, 20)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3742,7 +3988,9 @@ describe('builtin popupmenu', function()
## grid 5
^popup menu test |
{1:~ }|
- ]], float_pos={[4] = {{id = -1}, "SW", 5, 1, 19, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'SW', 5, 1, 19, false, 250 } },
+ })
else
feed('<RightMouse><20,4>')
screen:expect([[
@@ -3756,7 +4004,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('left', 'press', '', 4, 2, 2)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3770,7 +4019,8 @@ describe('builtin popupmenu', function()
## grid 5
^popup menu test |
{1:~ }|
- ]]})
+ ]],
+ })
else
feed('<LeftMouse><22,3>')
screen:expect([[
@@ -3787,7 +4037,8 @@ describe('builtin popupmenu', function()
command('set winwidth=1 | rightbelow vsplit')
if multigrid then
meths.input_mouse('right', 'press', '', 6, 1, 14)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3808,7 +4059,9 @@ describe('builtin popupmenu', function()
## grid 6
^popup menu test |
{1:~ }|
- ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'SW', 6, 1, 12, false, 250 } },
+ })
else
feed('<RightMouse><30,4>')
screen:expect([[
@@ -3822,7 +4075,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('left', 'press', '', 4, 0, 2)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3839,7 +4093,8 @@ describe('builtin popupmenu', function()
## grid 6
^popup menu test |
{1:~ }|
- ]]})
+ ]],
+ })
else
feed('<LeftMouse><31,1>')
screen:expect([[
@@ -3856,7 +4111,8 @@ describe('builtin popupmenu', function()
command('setlocal winbar=WINBAR')
if multigrid then
meths.input_mouse('right', 'press', '', 6, 1, 14)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3877,7 +4133,9 @@ describe('builtin popupmenu', function()
## grid 6
{2:WINBAR }|
^popup menu test |
- ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}})
+ ]],
+ float_pos = { [4] = { { id = -1 }, 'SW', 6, 1, 12, false, 250 } },
+ })
else
feed('<RightMouse><30,4>')
screen:expect([[
@@ -3891,7 +4149,8 @@ describe('builtin popupmenu', function()
end
if multigrid then
meths.input_mouse('left', 'press', '', 4, 1, 2)
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
## grid 1
[2:--------------------------------]|*2
{3:[No Name] [+] }|
@@ -3908,7 +4167,8 @@ describe('builtin popupmenu', function()
## grid 6
{2:WINBAR }|
^popup menu test |
- ]]})
+ ]],
+ })
else
feed('<LeftMouse><31,2>')
screen:expect([[
@@ -4100,19 +4360,22 @@ describe('builtin popupmenu', function()
hi PmenuExtraSel guifg=Black guibg=Grey
]])
local attrs = screen:get_default_attr_ids()
- attrs.kn = {foreground = Screen.colors.Red, background = Screen.colors.Magenta}
- attrs.ks = {foreground = Screen.colors.Red, background = Screen.colors.Grey}
- attrs.xn = {foreground = Screen.colors.White, background = Screen.colors.Magenta}
- attrs.xs = {foreground = Screen.colors.Black, background = Screen.colors.Grey}
+ attrs.kn = { foreground = Screen.colors.Red, background = Screen.colors.Magenta }
+ attrs.ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey }
+ attrs.xn = { foreground = Screen.colors.White, background = Screen.colors.Magenta }
+ attrs.xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey }
feed('iaw<C-X><C-u>')
- screen:expect([[
+ screen:expect(
+ [[
aword1^ |
{s:aword1 }{ks:W }{xs:extra text 1 }{1: }|
{n:aword2 }{kn:W }{xn:extra text 2 }{1: }|
{n:aword3 }{kn:W }{xn:extra text 3 }{1: }|
{1:~ }|*3
{2:-- }{5:match 1 of 3} |
- ]], attrs)
+ ]],
+ attrs
+ )
end)
end)
end
diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua
index 523e657249..612a2a947d 100644
--- a/test/functional/ui/quickfix_spec.lua
+++ b/test/functional/ui/quickfix_spec.lua
@@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen')
local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, command = helpers.insert, helpers.command
-
describe('quickfix selection highlight', function()
local screen
@@ -14,17 +13,17 @@ describe('quickfix selection highlight', function()
screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
- [2] = {reverse = true},
- [3] = {foreground = Screen.colors.Brown},
- [4] = {bold = true, reverse = true},
- [5] = {background = Screen.colors.Green},
- [6] = {foreground = Screen.colors.Brown, background = Screen.colors.Green},
- [7] = {background = Screen.colors.Red},
- [8] = {foreground = Screen.colors.Brown, background = Screen.colors.Red},
- [9] = {background = Screen.colors.Fuchsia},
- [10] = {foreground = Screen.colors.Red, background = Screen.colors.Fuchsia},
- [11] = {foreground = Screen.colors.Red},
- [12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia},
+ [2] = { reverse = true },
+ [3] = { foreground = Screen.colors.Brown },
+ [4] = { bold = true, reverse = true },
+ [5] = { background = Screen.colors.Green },
+ [6] = { foreground = Screen.colors.Brown, background = Screen.colors.Green },
+ [7] = { background = Screen.colors.Red },
+ [8] = { foreground = Screen.colors.Brown, background = Screen.colors.Red },
+ [9] = { background = Screen.colors.Fuchsia },
+ [10] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
+ [11] = { foreground = Screen.colors.Red },
+ [12] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
})
meths.set_option_value('errorformat', '%m %l', {})
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 096d8a27fb..47e343789a 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -161,8 +161,8 @@ function Screen.new(width, height)
_default_attr_ids = nil,
mouse_enabled = true,
_attrs = {},
- _hl_info = {[0]={}},
- _attr_table = {[0]={{},{}}},
+ _hl_info = { [0] = {} },
+ _attr_table = { [0] = { {}, {} } },
_clear_attrs = nil,
_new_attrs = false,
_width = width,
@@ -170,15 +170,17 @@ function Screen.new(width, height)
_grids = {},
_grid_win_extmarks = {},
_cursor = {
- grid = 1, row = 1, col = 1
+ grid = 1,
+ row = 1,
+ col = 1,
},
_busy = false,
}, Screen)
local function ui(method, ...)
if self.rpc_async then
- self._session:notify('nvim_ui_'..method, ...)
+ self._session:notify('nvim_ui_' .. method, ...)
else
- local status, rv = self._session:request('nvim_ui_'..method, ...)
+ local status, rv = self._session:request('nvim_ui_' .. method, ...)
if not status then
error(rv[2])
end
@@ -248,8 +250,18 @@ end
-- canonical order of ext keys, used to generate asserts
local ext_keys = {
- 'popupmenu', 'cmdline', 'cmdline_block', 'wildmenu_items', 'wildmenu_pos',
- 'messages', 'msg_history', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport'
+ 'popupmenu',
+ 'cmdline',
+ 'cmdline_block',
+ 'wildmenu_items',
+ 'wildmenu_pos',
+ 'messages',
+ 'msg_history',
+ 'showmode',
+ 'showcmd',
+ 'ruler',
+ 'float_pos',
+ 'win_viewport',
}
-- Asserts that the screen state eventually matches an expected state.
@@ -313,28 +325,40 @@ local ext_keys = {
function Screen:expect(expected, attr_ids, ...)
local grid, condition = nil, nil
local expected_rows = {}
- assert(next({...}) == nil, "invalid args to expect()")
- if type(expected) == "table" then
+ assert(next({ ... }) == nil, 'invalid args to expect()')
+ if type(expected) == 'table' then
assert(not (attr_ids ~= nil))
- local is_key = {grid=true, attr_ids=true, condition=true, mouse_enabled=true,
- any=true, mode=true, unchanged=true, intermediate=true,
- reset=true, timeout=true, request_cb=true, hl_groups=true, extmarks=true}
+ local is_key = {
+ grid = true,
+ attr_ids = true,
+ condition = true,
+ mouse_enabled = true,
+ any = true,
+ mode = true,
+ unchanged = true,
+ intermediate = true,
+ reset = true,
+ timeout = true,
+ request_cb = true,
+ hl_groups = true,
+ extmarks = true,
+ }
for _, v in ipairs(ext_keys) do
is_key[v] = true
end
for k, _ in pairs(expected) do
if not is_key[k] then
- error("Screen:expect: Unknown keyword argument '"..k.."'")
+ error("Screen:expect: Unknown keyword argument '" .. k .. "'")
end
end
grid = expected.grid
attr_ids = expected.attr_ids
condition = expected.condition
assert(not (expected.any ~= nil and grid ~= nil))
- elseif type(expected) == "string" then
+ elseif type(expected) == 'string' then
grid = expected
expected = {}
- elseif type(expected) == "function" then
+ elseif type(expected) == 'function' then
assert(not (attr_ids ~= nil))
condition = expected
expected = {}
@@ -380,8 +404,13 @@ function Screen:expect(expected, attr_ids, ...)
if nil == string.find(actual_screen_str, expected.any) then
return (
'Failed to match any screen lines.\n'
- .. 'Expected (anywhere): "' .. expected.any .. '"\n'
- .. 'Actual:\n |' .. table.concat(actual_rows, '\n |') .. '\n\n')
+ .. 'Expected (anywhere): "'
+ .. expected.any
+ .. '"\n'
+ .. 'Actual:\n |'
+ .. table.concat(actual_rows, '\n |')
+ .. '\n\n'
+ )
end
end
@@ -400,8 +429,11 @@ function Screen:expect(expected, attr_ids, ...)
local err_msg = nil
-- `expected` must match the screen lines exactly.
if #actual_rows ~= #expected_rows then
- err_msg = "Expected screen height " .. #expected_rows
- .. ' differs from actual height ' .. #actual_rows .. '.'
+ err_msg = 'Expected screen height '
+ .. #expected_rows
+ .. ' differs from actual height '
+ .. #actual_rows
+ .. '.'
end
local msg_expected_rows = shallowcopy(expected_rows)
local msg_actual_rows = shallowcopy(actual_rows)
@@ -431,11 +463,18 @@ function Screen:expect(expected, attr_ids, ...)
end
if err_msg ~= nil then
return (
- err_msg..'\nExpected:\n |'..table.concat(msg_expected_rows, '\n |')..'\n'
- ..'Actual:\n |'..table.concat(msg_actual_rows, '\n |')..'\n\n'..[[
+ err_msg
+ .. '\nExpected:\n |'
+ .. table.concat(msg_expected_rows, '\n |')
+ .. '\n'
+ .. 'Actual:\n |'
+ .. table.concat(msg_actual_rows, '\n |')
+ .. '\n\n'
+ .. [[
To print the expect() call that would assert the current screen state, use
screen:snapshot_util(). In case of non-deterministic failures, use
-screen:redraw_debug() to show all intermediate screen states.]])
+screen:redraw_debug() to show all intermediate screen states.]]
+ )
end
end
@@ -464,12 +503,18 @@ screen:redraw_debug() to show all intermediate screen states.]])
end
-- Convert assertion errors into invalid screen state descriptions.
- for _, k in ipairs(concat_tables(ext_keys, {'mode', 'mouse_enabled'})) do
+ for _, k in ipairs(concat_tables(ext_keys, { 'mode', 'mouse_enabled' })) do
-- Empty states are considered the default and need not be mentioned.
- if (not (expected[k] == nil and isempty(extstate[k]))) then
+ if not (expected[k] == nil and isempty(extstate[k])) then
local status, res = pcall(eq, expected[k], extstate[k], k)
if not status then
- return (tostring(res)..'\nHint: full state of "'..k..'":\n '..inspect(extstate[k]))
+ return (
+ tostring(res)
+ .. '\nHint: full state of "'
+ .. k
+ .. '":\n '
+ .. inspect(extstate[k])
+ )
end
end
end
@@ -478,7 +523,7 @@ screen:redraw_debug() to show all intermediate screen states.]])
for name, id in pairs(expected.hl_groups) do
local expected_hl = attr_state.ids[id]
local actual_hl = self._attr_table[self.hl_groups[name]][(self._options.rgb and 1) or 2]
- local status, res = pcall(eq, expected_hl, actual_hl, "highlight "..name)
+ local status, res = pcall(eq, expected_hl, actual_hl, 'highlight ' .. name)
if not status then
return tostring(res)
end
@@ -489,9 +534,10 @@ screen:redraw_debug() to show all intermediate screen states.]])
for gridid, expected_marks in pairs(expected.extmarks) do
local stored_marks = self._grid_win_extmarks[gridid]
if stored_marks == nil then
- return 'no win_extmark for grid '..tostring(gridid)
+ return 'no win_extmark for grid ' .. tostring(gridid)
end
- local status, res = pcall(eq, expected_marks, stored_marks, "extmarks for grid "..tostring(gridid))
+ local status, res =
+ pcall(eq, expected_marks, stored_marks, 'extmarks for grid ' .. tostring(gridid))
if not status then
return tostring(res)
end
@@ -499,7 +545,7 @@ screen:redraw_debug() to show all intermediate screen states.]])
for gridid, _ in pairs(self._grid_win_extmarks) do
local expected_marks = expected.extmarks[gridid]
if expected_marks == nil then
- return 'unexpected win_extmark for grid '..tostring(gridid)
+ return 'unexpected win_extmark for grid ' .. tostring(gridid)
end
end
end
@@ -562,8 +608,10 @@ function Screen:_wait(check, flags)
local did_minimal_timeout = false
local function notification_cb(method, args)
- assert(method == 'redraw', string.format(
- 'notification_cb: unexpected method (%s, args=%s)', method, inspect(args)))
+ assert(
+ method == 'redraw',
+ string.format('notification_cb: unexpected method (%s, args=%s)', method, inspect(args))
+ )
did_flush = self:_redraw(args)
if not did_flush then
return
@@ -589,7 +637,7 @@ function Screen:_wait(check, flags)
end
local eof = run_session(self._session, flags.request_cb, notification_cb, nil, minimal_timeout)
if not did_flush then
- err = "no flush received"
+ err = 'no flush received'
elseif not checked then
err = check()
if not err and flags.unchanged then
@@ -600,12 +648,13 @@ function Screen:_wait(check, flags)
if not success_seen and not eof then
did_minimal_timeout = true
- eof = run_session(self._session, flags.request_cb, notification_cb, nil, timeout-minimal_timeout)
+ eof =
+ run_session(self._session, flags.request_cb, notification_cb, nil, timeout - minimal_timeout)
end
local did_warn = false
if warn_immediate and immediate_seen then
- print([[
+ print([[
warning: Screen test succeeded immediately. Try to avoid this unless the
purpose of the test really requires it.]])
@@ -639,21 +688,24 @@ between asynchronous (feed(), nvim_input()) and synchronous API calls.
did_warn = true
end
-
if err then
- if eof then err = err..'\n\n'..eof[2] end
+ if eof then
+ err = err .. '\n\n' .. eof[2]
+ end
busted.fail(err .. '\n\nSnapshot:\n' .. self:_print_snapshot(), 3)
elseif did_warn then
- if eof then print(eof[2]) end
+ if eof then
+ print(eof[2])
+ end
local tb = debug.traceback()
local index = string.find(tb, '\n%s*%[C]')
- print(string.sub(tb,1,index))
+ print(string.sub(tb, 1, index))
end
if flags.intermediate then
- assert(intermediate_seen, "expected intermediate screen state before final screen state")
+ assert(intermediate_seen, 'expected intermediate screen state before final screen state')
elseif flags.unchanged then
- assert(not intermediate_seen, "expected screen state to be unchanged")
+ assert(not intermediate_seen, 'expected screen state to be unchanged')
end
end
@@ -671,17 +723,22 @@ function Screen:_redraw(updates)
-- print('--', inspect(update))
local method = update[1]
for i = 2, #update do
- local handler_name = '_handle_'..method
+ local handler_name = '_handle_' .. method
local handler = self[handler_name]
- assert(handler ~= nil, "missing handler: Screen:"..handler_name)
+ assert(handler ~= nil, 'missing handler: Screen:' .. handler_name)
local status, res = pcall(handler, self, unpack(update[i]))
if not status then
- error(handler_name..' failed'
- ..'\n payload: '..inspect(update)
- ..'\n error: '..tostring(res))
+ error(
+ handler_name
+ .. ' failed'
+ .. '\n payload: '
+ .. inspect(update)
+ .. '\n error: '
+ .. tostring(res)
+ )
end
end
- if k == #updates and method == "flush" then
+ if k == #updates and method == 'flush' then
did_flush = true
end
end
@@ -691,12 +748,15 @@ end
function Screen:_handle_resize(width, height)
self:_handle_grid_resize(1, width, height)
self._scroll_region = {
- top = 1, bot = height, left = 1, right = width
+ top = 1,
+ bot = height,
+ left = 1,
+ right = width,
}
self._grid = self._grids[1]
end
-local function min(x,y)
+local function min(x, y)
if x < y then
return x
else
@@ -709,14 +769,14 @@ function Screen:_handle_grid_resize(grid, width, height)
for _ = 1, height do
local cols = {}
for _ = 1, width do
- table.insert(cols, {text = ' ', attrs = self._clear_attrs, hl_id = 0})
+ table.insert(cols, { text = ' ', attrs = self._clear_attrs, hl_id = 0 })
end
table.insert(rows, cols)
end
if grid > 1 and self._grids[grid] ~= nil then
local old = self._grids[grid]
- for i = 1, min(height,old.height) do
- for j = 1, min(width,old.width) do
+ for i = 1, min(height, old.height) do
+ for j = 1, min(width, old.width) do
rows[i][j] = old.rows[i][j]
end
end
@@ -727,13 +787,12 @@ function Screen:_handle_grid_resize(grid, width, height)
self._cursor.col = 1
end
self._grids[grid] = {
- rows=rows,
- width=width,
- height=height,
+ rows = rows,
+ width = width,
+ height = height,
}
end
-
function Screen:_handle_msg_set_pos(grid, row, scrolled, char)
self.msg_grid = grid
self.msg_grid_pos = row
@@ -741,8 +800,7 @@ function Screen:_handle_msg_set_pos(grid, row, scrolled, char)
self.msg_sep_char = char
end
-function Screen:_handle_flush()
-end
+function Screen:_handle_flush() end
function Screen:_reset()
-- TODO: generalize to multigrid later
@@ -760,15 +818,15 @@ end
function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info)
self._cursor_style_enabled = cursor_style_enabled
for _, item in pairs(mode_info) do
- -- attr IDs are not stable, but their value should be
- if item.attr_id ~= nil then
- item.attr = self._attr_table[item.attr_id][1]
- item.attr_id = nil
- end
- if item.attr_id_lm ~= nil then
- item.attr_lm = self._attr_table[item.attr_id_lm][1]
- item.attr_id_lm = nil
- end
+ -- attr IDs are not stable, but their value should be
+ if item.attr_id ~= nil then
+ item.attr = self._attr_table[item.attr_id][1]
+ item.attr_id = nil
+ end
+ if item.attr_id_lm ~= nil then
+ item.attr_lm = self._attr_table[item.attr_id_lm][1]
+ item.attr_id_lm = nil
+ end
end
self._mode_info = mode_info
end
@@ -780,7 +838,10 @@ function Screen:_handle_clear()
-- 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._grid.height, left = 1, right = self._grid.width
+ top = 1,
+ bot = self._grid.height,
+ left = 1,
+ right = self._grid.width,
}
eq(expected_region, self._scroll_region)
self:_handle_grid_clear(1)
@@ -821,14 +882,24 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height)
startrow = startrow,
startcol = startcol,
width = width,
- height = height
+ height = height,
}
self.float_pos[grid] = nil
end
-function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount, scroll_delta)
+function Screen:_handle_win_viewport(
+ grid,
+ win,
+ topline,
+ botline,
+ curline,
+ curcol,
+ linecount,
+ scroll_delta
+)
-- accumulate scroll delta
- local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta or 0
+ local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta
+ or 0
self.win_viewport[grid] = {
win = win,
topline = topline,
@@ -836,18 +907,18 @@ function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curco
curline = curline,
curcol = curcol,
linecount = linecount,
- sum_scroll_delta = scroll_delta + last_scroll_delta
+ sum_scroll_delta = scroll_delta + last_scroll_delta,
}
end
function Screen:_handle_win_float_pos(grid, ...)
self.win_position[grid] = nil
- self.float_pos[grid] = {...}
+ self.float_pos[grid] = { ... }
end
function Screen:_handle_win_external_pos(grid)
self.win_position[grid] = nil
- self.float_pos[grid] = {external=true}
+ self.float_pos[grid] = { external = true }
end
function Screen:_handle_win_hide(grid)
@@ -863,7 +934,7 @@ function Screen:_handle_win_extmark(grid, ...)
if self._grid_win_extmarks[grid] == nil then
self._grid_win_extmarks[grid] = {}
end
- table.insert(self._grid_win_extmarks[grid], {...})
+ table.insert(self._grid_win_extmarks[grid], { ... })
end
function Screen:_handle_busy_start()
@@ -883,7 +954,7 @@ function Screen:_handle_mouse_off()
end
function Screen:_handle_mode_change(mode, idx)
- assert(mode == self._mode_info[idx+1].name)
+ assert(mode == self._mode_info[idx + 1].name)
self.mode = mode
end
@@ -899,17 +970,16 @@ 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)
+ self:_handle_grid_scroll(1, top - 1, bot, left - 1, right, count, 0)
end
function Screen:_handle_grid_scroll(g, top, bot, left, right, rows, cols)
- top = top+1
- left = left+1
+ top = top + 1
+ left = left + 1
assert(cols == 0)
local grid = self._grids[g]
local start, stop, step
-
if rows > 0 then
start = top
stop = bot - rows
@@ -938,7 +1008,7 @@ function Screen:_handle_grid_scroll(g, top, bot, left, right, rows, cols)
end
function Screen:_handle_hl_attr_define(id, rgb_attrs, cterm_attrs, info)
- self._attr_table[id] = {rgb_attrs, cterm_attrs}
+ self._attr_table[id] = { rgb_attrs, cterm_attrs }
self._hl_info[id] = info
self._new_attrs = true
end
@@ -971,10 +1041,10 @@ end
function Screen:_handle_grid_line(grid, row, col, items)
assert(self._options.ext_linegrid)
assert(#items > 0)
- local line = self._grids[grid].rows[row+1]
- local colpos = col+1
+ local line = self._grids[grid].rows[row + 1]
+ local colpos = col + 1
local hl_id = 0
- for _,item in ipairs(items) do
+ for _, item in ipairs(items) do
local text, hl_id_cell, count = unpack(item)
if hl_id_cell ~= nil then
hl_id = hl_id_cell
@@ -983,7 +1053,7 @@ function Screen:_handle_grid_line(grid, row, col, items)
local cell = line[colpos]
cell.text = text
cell.hl_id = hl_id
- colpos = colpos+1
+ colpos = colpos + 1
end
end
end
@@ -998,11 +1068,11 @@ end
function Screen:_handle_default_colors_set(rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg)
self.default_colors = {
- rgb_fg=rgb_fg,
- rgb_bg=rgb_bg,
- rgb_sp=rgb_sp,
- cterm_fg=cterm_fg,
- cterm_bg=cterm_bg
+ rgb_fg = rgb_fg,
+ rgb_bg = rgb_bg,
+ rgb_sp = rgb_sp,
+ cterm_fg = cterm_fg,
+ cterm_bg = cterm_bg,
}
end
@@ -1039,7 +1109,7 @@ function Screen:_handle_option_set(name, value)
end
function Screen:_handle_popupmenu_show(items, selected, row, col, grid)
- self.popupmenu = {items=items, pos=selected, anchor={grid, row, col}}
+ self.popupmenu = { items = items, pos = selected, anchor = { grid, row, col } }
end
function Screen:_handle_popupmenu_select(selected)
@@ -1051,9 +1121,15 @@ function Screen:_handle_popupmenu_hide()
end
function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level)
- if firstc == '' then firstc = nil end
- if prompt == '' then prompt = nil end
- if indent == 0 then indent = nil end
+ if firstc == '' then
+ firstc = nil
+ end
+ if prompt == '' then
+ prompt = nil
+ end
+ if indent == 0 then
+ indent = nil
+ end
-- check position is valid #10000
local len = 0
@@ -1062,8 +1138,13 @@ function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level
end
assert(pos <= len)
- self.cmdline[level] = {content=content, pos=pos, firstc=firstc,
- prompt=prompt, indent=indent}
+ self.cmdline[level] = {
+ content = content,
+ pos = pos,
+ firstc = firstc,
+ prompt = prompt,
+ indent = indent,
+ }
end
function Screen:_handle_cmdline_hide(level)
@@ -1072,7 +1153,7 @@ end
function Screen:_handle_cmdline_special_char(char, shift, level)
-- cleared by next cmdline_show on the same level
- self.cmdline[level].special = {char, shift}
+ self.cmdline[level].special = { char, shift }
end
function Screen:_handle_cmdline_pos(pos, level)
@@ -1084,7 +1165,7 @@ function Screen:_handle_cmdline_block_show(block)
end
function Screen:_handle_cmdline_block_append(item)
- self.cmdline_block[#self.cmdline_block+1] = item
+ self.cmdline_block[#self.cmdline_block + 1] = item
end
function Screen:_handle_cmdline_block_hide()
@@ -1108,7 +1189,7 @@ function Screen:_handle_msg_show(kind, chunks, replace_last)
if not replace_last or pos == 0 then
pos = pos + 1
end
- self.messages[pos] = {kind=kind, content=chunks}
+ self.messages[pos] = { kind = kind, content = chunks }
end
function Screen:_handle_msg_clear()
@@ -1157,19 +1238,23 @@ function Screen:_row_repr(gridnr, rownr, attr_state, cursor)
local has_windows = self._options.ext_multigrid and gridnr == 1
local row = self._grids[gridnr].rows[rownr]
if has_windows and self.msg_grid and self.msg_grid_pos < rownr then
- return '['..self.msg_grid..':'..string.rep('-',#row)..']'
+ return '[' .. self.msg_grid .. ':' .. string.rep('-', #row) .. ']'
end
while i <= #row do
local did_window = false
if has_windows then
- for id,pos in pairs(self.win_position) do
- if i-1 == pos.startcol and pos.startrow <= rownr-1 and rownr-1 < pos.startrow + pos.height then
+ for id, pos in pairs(self.win_position) do
+ if
+ i - 1 == pos.startcol
+ and pos.startrow <= rownr - 1
+ and rownr - 1 < pos.startrow + pos.height
+ then
if current_attr_id then
-- close current attribute bracket
table.insert(rv, '}')
current_attr_id = nil
end
- table.insert(rv, '['..id..':'..string.rep('-',pos.width)..']')
+ table.insert(rv, '[' .. id .. ':' .. string.rep('-', pos.width) .. ']')
i = i + pos.width
did_window = true
end
@@ -1200,7 +1285,7 @@ function Screen:_row_repr(gridnr, rownr, attr_state, cursor)
end
-- return the line representation, but remove empty attribute brackets and
-- trailing whitespace
- return table.concat(rv, '')--:gsub('%s+$', '')
+ return table.concat(rv, '') --:gsub('%s+$', '')
end
function Screen:_extstate_repr(attr_state)
@@ -1218,29 +1303,29 @@ function Screen:_extstate_repr(attr_state)
local messages = {}
for i, entry in ipairs(self.messages) do
- messages[i] = {kind=entry.kind, content=self:_chunks_repr(entry.content, attr_state)}
+ messages[i] = { kind = entry.kind, content = self:_chunks_repr(entry.content, attr_state) }
end
local msg_history = {}
for i, entry in ipairs(self.msg_history) do
- msg_history[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)}
+ msg_history[i] = { kind = entry[1], content = self:_chunks_repr(entry[2], attr_state) }
end
local win_viewport = (next(self.win_viewport) and self.win_viewport) or nil
return {
- popupmenu=self.popupmenu,
- cmdline=cmdline,
- cmdline_block=cmdline_block,
- wildmenu_items=self.wildmenu_items,
- wildmenu_pos=self.wildmenu_pos,
- messages=messages,
- showmode=self:_chunks_repr(self.showmode, attr_state),
- showcmd=self:_chunks_repr(self.showcmd, attr_state),
- ruler=self:_chunks_repr(self.ruler, attr_state),
- msg_history=msg_history,
- float_pos=self.float_pos,
- win_viewport=win_viewport,
+ popupmenu = self.popupmenu,
+ cmdline = cmdline,
+ cmdline_block = cmdline_block,
+ wildmenu_items = self.wildmenu_items,
+ wildmenu_pos = self.wildmenu_pos,
+ messages = messages,
+ showmode = self:_chunks_repr(self.showmode, attr_state),
+ showcmd = self:_chunks_repr(self.showcmd, attr_state),
+ ruler = self:_chunks_repr(self.ruler, attr_state),
+ msg_history = msg_history,
+ float_pos = self.float_pos,
+ win_viewport = win_viewport,
}
end
@@ -1255,7 +1340,7 @@ function Screen:_chunks_repr(chunks, attr_state)
attrs = hl
end
local attr_id = self:_get_attr_id(attr_state, attrs, hl)
- repr_chunks[i] = {text, attr_id}
+ repr_chunks[i] = { text, attr_id }
end
return repr_chunks
end
@@ -1276,7 +1361,7 @@ function Screen:redraw_debug(attrs, ignore, timeout)
assert(method == 'redraw')
for _, update in ipairs(args) do
-- mode_info_set is quite verbose, comment out the condition to debug it.
- if update[1] ~= "mode_info_set" then
+ if update[1] ~= 'mode_info_set' then
print(inspect(update))
end
end
@@ -1293,14 +1378,18 @@ end
function Screen:render(headers, attr_state, preview)
headers = headers and (self._options.ext_multigrid or self._options._debug_float)
local rv = {}
- for igrid,grid in vim.spairs(self._grids) do
+ for igrid, grid in vim.spairs(self._grids) do
if headers then
- local suffix = ""
- if igrid > 1 and self.win_position[igrid] == nil
- and self.float_pos[igrid] == nil and self.msg_grid ~= igrid then
- suffix = " (hidden)"
+ local suffix = ''
+ if
+ igrid > 1
+ and self.win_position[igrid] == nil
+ and self.float_pos[igrid] == nil
+ and self.msg_grid ~= igrid
+ then
+ suffix = ' (hidden)'
end
- table.insert(rv, "## grid "..igrid..suffix)
+ table.insert(rv, '## grid ' .. igrid .. suffix)
end
local height = grid.height
if igrid == self.msg_grid then
@@ -1308,8 +1397,8 @@ function Screen:render(headers, attr_state, preview)
end
for i = 1, height do
local cursor = self._cursor.grid == igrid and self._cursor.row == i
- local prefix = (headers or preview) and " " or ""
- table.insert(rv, prefix..self:_row_repr(igrid, i, attr_state, cursor).."|")
+ local prefix = (headers or preview) and ' ' or ''
+ table.insert(rv, prefix .. self:_row_repr(igrid, i, attr_state, cursor) .. '|')
end
end
return rv
@@ -1388,33 +1477,50 @@ local function fmt_ext_state(name, state)
return item
end
end
- if name == "win_viewport" then
- local str = "{\n"
- for k,v in pairs(state) do
- str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = "
- ..v.topline..", botline = "..v.botline..", curline = "..v.curline
- ..", curcol = "..v.curcol..", linecount = "..v.linecount..", sum_scroll_delta = "..v.sum_scroll_delta.."};\n")
+ if name == 'win_viewport' then
+ local str = '{\n'
+ for k, v in pairs(state) do
+ str = (
+ str
+ .. ' ['
+ .. k
+ .. '] = {win = {id = '
+ .. v.win.id
+ .. '}, topline = '
+ .. v.topline
+ .. ', botline = '
+ .. v.botline
+ .. ', curline = '
+ .. v.curline
+ .. ', curcol = '
+ .. v.curcol
+ .. ', linecount = '
+ .. v.linecount
+ .. ', sum_scroll_delta = '
+ .. v.sum_scroll_delta
+ .. '};\n'
+ )
end
- return str .. "}"
- elseif name == "float_pos" then
- local str = "{\n"
- for k,v in pairs(state) do
- str = str.." ["..k.."] = {{id = "..v[1].id.."}"
+ return str .. '}'
+ elseif name == 'float_pos' then
+ local str = '{\n'
+ for k, v in pairs(state) do
+ str = str .. ' [' .. k .. '] = {{id = ' .. v[1].id .. '}'
for i = 2, #v do
- str = str..", "..inspect(v[i])
+ str = str .. ', ' .. inspect(v[i])
end
- str = str .. "};\n"
+ str = str .. '};\n'
end
- return str .. "}"
+ return str .. '}'
else
-- TODO(bfredl): improve formatting of more states
- return inspect(state,{process=remove_all_metatables})
+ return inspect(state, { process = remove_all_metatables })
end
end
function Screen:_print_snapshot(attrs, ignore)
local kwargs, ext_state, attr_state = self:get_snapshot(attrs, ignore)
- local attrstr = ""
+ local attrstr = ''
if attr_state.modified then
local attrstrs = {}
for i, a in pairs(attr_state.ids) do
@@ -1422,20 +1528,20 @@ function Screen:_print_snapshot(attrs, ignore)
if self._options.ext_linegrid then
dict = self:_pprint_hlitem(a)
else
- dict = "{"..self:_pprint_attrs(a).."}"
+ dict = '{' .. self:_pprint_attrs(a) .. '}'
end
- local keyval = (type(i) == "number") and "["..tostring(i).."]" or i
- table.insert(attrstrs, " "..keyval.." = "..dict..";")
+ local keyval = (type(i) == 'number') and '[' .. tostring(i) .. ']' or i
+ table.insert(attrstrs, ' ' .. keyval .. ' = ' .. dict .. ';')
end
- attrstr = (", attr_ids={\n"..table.concat(attrstrs, "\n").."\n}")
+ attrstr = (', attr_ids={\n' .. table.concat(attrstrs, '\n') .. '\n}')
elseif isempty(attrs) then
attrstr = ', attr_ids={}'
end
local result = 'screen:expect{grid=[[\n' .. kwargs.grid .. '\n]]' .. attrstr
for _, k in ipairs(ext_keys) do
- if ext_state[k] ~= nil and not (k == "win_viewport" and not self.options.ext_multigrid) then
- result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
+ if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
+ result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
end
end
result = result .. '}'
@@ -1463,7 +1569,7 @@ function Screen:_insert_hl_id(attr_state, hl_id)
else
info[1] = {}
for k, v in pairs(raw_info[1]) do
- if k ~= "id" then
+ if k ~= 'id' then
info[1][k] = v
end
end
@@ -1473,9 +1579,9 @@ function Screen:_insert_hl_id(attr_state, hl_id)
local entry = self._attr_table[hl_id]
local attrval
if self._rgb_cterm then
- attrval = {entry[1], entry[2], info} -- unpack() doesn't work
+ attrval = { entry[1], entry[2], info } -- unpack() doesn't work
elseif self._options.ext_hlstate then
- attrval = {entry[1], info}
+ attrval = { entry[1], info }
else
attrval = self._options.rgb and entry[1] or entry[2]
end
@@ -1491,17 +1597,17 @@ function Screen:linegrid_check_attrs(attrs)
local iinfo = self._hl_info[i]
local matchinfo = {}
if #iinfo > 1 then
- for k,item in ipairs(iinfo) do
+ for k, item in ipairs(iinfo) do
matchinfo[k] = id_to_index[item.id]
end
else
matchinfo = iinfo
end
- for k,v in pairs(attrs) do
+ for k, v in pairs(attrs) do
local attr, info, attr_rgb, attr_cterm
if self._rgb_cterm then
attr_rgb, attr_cterm, info = unpack(v)
- attr = {attr_rgb, attr_cterm}
+ attr = { attr_rgb, attr_cterm }
info = info or {}
elseif self._options.ext_hlstate then
attr, info = unpack(v)
@@ -1513,12 +1619,12 @@ function Screen:linegrid_check_attrs(attrs)
if #info == #matchinfo then
local match = false
if #info == 1 then
- if self:_equal_info(info[1],matchinfo[1]) then
+ if self:_equal_info(info[1], matchinfo[1]) then
match = true
end
else
match = true
- for j = 1,#info do
+ for j = 1, #info do
if info[j] ~= matchinfo[j] then
match = false
end
@@ -1530,32 +1636,34 @@ function Screen:linegrid_check_attrs(attrs)
end
end
end
- if self:_equal_attr_def(self._rgb_cterm and {{}, {}} or {}, def_attr) and #self._hl_info[i] == 0 then
- id_to_index[i] = ""
+ if
+ self:_equal_attr_def(self._rgb_cterm and { {}, {} } or {}, def_attr)
+ and #self._hl_info[i] == 0
+ then
+ id_to_index[i] = ''
end
end
return id_to_index
end
-
function Screen:_pprint_hlitem(item)
- -- print(inspect(item))
- local multi = self._rgb_cterm or self._options.ext_hlstate
- local cterm = (not self._rgb_cterm and not self._options.rgb)
- local attrdict = "{"..self:_pprint_attrs(multi and item[1] or item, cterm).."}"
- local attrdict2, hlinfo
- local descdict = ""
- if self._rgb_cterm then
- attrdict2 = ", {"..self:_pprint_attrs(item[2], true).."}"
- hlinfo = item[3]
- else
- attrdict2 = ""
- hlinfo = item[2]
- end
- if self._options.ext_hlstate then
- descdict = ", {"..self:_pprint_hlinfo(hlinfo).."}"
- end
- return (multi and "{" or "")..attrdict..attrdict2..descdict..(multi and "}" or "")
+ -- print(inspect(item))
+ local multi = self._rgb_cterm or self._options.ext_hlstate
+ local cterm = (not self._rgb_cterm and not self._options.rgb)
+ local attrdict = '{' .. self:_pprint_attrs(multi and item[1] or item, cterm) .. '}'
+ local attrdict2, hlinfo
+ local descdict = ''
+ if self._rgb_cterm then
+ attrdict2 = ', {' .. self:_pprint_attrs(item[2], true) .. '}'
+ hlinfo = item[3]
+ else
+ attrdict2 = ''
+ hlinfo = item[2]
+ end
+ if self._options.ext_hlstate then
+ descdict = ', {' .. self:_pprint_hlinfo(hlinfo) .. '}'
+ end
+ return (multi and '{' or '') .. attrdict .. attrdict2 .. descdict .. (multi and '}' or '')
end
function Screen:_pprint_hlinfo(states)
@@ -1563,38 +1671,37 @@ function Screen:_pprint_hlinfo(states)
local items = {}
for f, v in pairs(states[1]) do
local desc = tostring(v)
- if type(v) == type("") then
- desc = '"'..desc..'"'
+ if type(v) == type('') then
+ desc = '"' .. desc .. '"'
end
- table.insert(items, f.." = "..desc)
+ table.insert(items, f .. ' = ' .. desc)
end
- return "{"..table.concat(items, ", ").."}"
+ return '{' .. table.concat(items, ', ') .. '}'
else
- return table.concat(states, ", ")
+ return table.concat(states, ', ')
end
end
-
function Screen:_pprint_attrs(attrs, cterm)
- local items = {}
- for f, v in pairs(attrs) do
- local desc = tostring(v)
- if f == "foreground" or f == "background" or f == "special" then
- if Screen.colornames[v] ~= nil then
- desc = "Screen.colors."..Screen.colornames[v]
- elseif cterm then
- desc = tostring(v)
- else
- desc = string.format("tonumber('0x%06x')",v)
- end
+ local items = {}
+ for f, v in pairs(attrs) do
+ local desc = tostring(v)
+ if f == 'foreground' or f == 'background' or f == 'special' then
+ if Screen.colornames[v] ~= nil then
+ desc = 'Screen.colors.' .. Screen.colornames[v]
+ elseif cterm then
+ desc = tostring(v)
+ else
+ desc = string.format("tonumber('0x%06x')", v)
end
- table.insert(items, f.." = "..desc)
end
- return table.concat(items, ", ")
+ table.insert(items, f .. ' = ' .. desc)
+ end
+ return table.concat(items, ', ')
end
---@diagnostic disable-next-line: unused-local, unused-function
-local function backward_find_meaningful(tbl, from) -- luacheck: no unused
+local function backward_find_meaningful(tbl, from) -- luacheck: no unused
for i = from or #tbl, 1, -1 do
if tbl[i] ~= ' ' then
return i + 1
@@ -1610,7 +1717,7 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id)
if self._options.ext_linegrid then
local id = attr_state.id_to_index[hl_id]
- if id == "" then -- sentinel for empty it
+ if id == '' then -- sentinel for empty it
return nil
elseif id ~= nil then
return id
@@ -1621,7 +1728,7 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id)
return id
end
local kind = self._options.rgb and 1 or 2
- return "UNEXPECTED "..self:_pprint_attrs(self._attr_table[hl_id][kind])
+ return 'UNEXPECTED ' .. self:_pprint_attrs(self._attr_table[hl_id][kind])
else
if self:_equal_attrs(attrs, {}) then
-- ignore this attrs
@@ -1629,49 +1736,56 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id)
end
for id, a in pairs(attr_state.ids) do
if self:_equal_attrs(a, attrs) then
- return id
- end
+ return id
+ end
end
if attr_state.mutable then
table.insert(attr_state.ids, attrs)
attr_state.modified = true
return #attr_state.ids
end
- return "UNEXPECTED "..self:_pprint_attrs(attrs)
+ return 'UNEXPECTED ' .. self:_pprint_attrs(attrs)
end
end
function Screen:_equal_attr_def(a, b)
if self._rgb_cterm then
- return self:_equal_attrs(a[1],b[1]) and self:_equal_attrs(a[2],b[2])
+ return self:_equal_attrs(a[1], b[1]) and self:_equal_attrs(a[2], b[2])
elseif self._options.rgb then
- return self:_equal_attrs(a,b[1])
+ return self:_equal_attrs(a, b[1])
else
- return self:_equal_attrs(a,b[2])
+ return self:_equal_attrs(a, b[2])
end
end
function Screen:_equal_attrs(a, b)
- return a.bold == b.bold and a.standout == b.standout and
- a.underline == b.underline and a.undercurl == b.undercurl and
- a.underdouble == b.underdouble and a.underdotted == b.underdotted and
- a.underdashed == b.underdashed and a.italic == b.italic and
- a.reverse == b.reverse and a.foreground == b.foreground and
- a.background == b.background and a.special == b.special and a.blend == b.blend and
- a.strikethrough == b.strikethrough and
- a.fg_indexed == b.fg_indexed and a.bg_indexed == b.bg_indexed
+ return a.bold == b.bold
+ and a.standout == b.standout
+ and a.underline == b.underline
+ and a.undercurl == b.undercurl
+ and a.underdouble == b.underdouble
+ and a.underdotted == b.underdotted
+ and a.underdashed == b.underdashed
+ and a.italic == b.italic
+ and a.reverse == b.reverse
+ and a.foreground == b.foreground
+ and a.background == b.background
+ and a.special == b.special
+ and a.blend == b.blend
+ and a.strikethrough == b.strikethrough
+ and a.fg_indexed == b.fg_indexed
+ and a.bg_indexed == b.bg_indexed
end
function Screen:_equal_info(a, b)
- return a.kind == b.kind and a.hi_name == b.hi_name and
- a.ui_name == b.ui_name
+ return a.kind == b.kind and a.hi_name == b.hi_name and a.ui_name == b.ui_name
end
function Screen:_attr_index(attrs, attr)
if not attrs then
return nil
end
- for i,a in pairs(attrs) do
+ for i, a in pairs(attrs) do
if self:_equal_attrs(a, attr) then
return i
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index b4ab3f54ca..4ee2438f88 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -10,11 +10,15 @@ describe('screen', function()
local screen
local nvim_argv = {
helpers.nvim_prog,
- '-u', 'NONE',
- '-i', 'NONE',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
'-n',
- '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
- '--cmd', 'colorscheme vim',
+ '--cmd',
+ 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
+ '--cmd',
+ 'colorscheme vim',
'--embed',
}
@@ -23,10 +27,10 @@ describe('screen', function()
set_session(screen_nvim)
screen = Screen.new()
screen:attach()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=255},
- [1] = {bold=true, reverse=true},
- } )
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = 255 },
+ [1] = { bold = true, reverse = true },
+ })
end)
it('default initial screen', function()
@@ -45,18 +49,23 @@ local function screen_tests(linegrid)
before_each(function()
clear()
screen = Screen.new()
- screen:attach({rgb=true,ext_linegrid=linegrid})
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=255},
- [1] = {bold=true, reverse=true},
- [2] = {bold=true},
- [3] = {reverse=true},
- [4] = {background = Screen.colors.LightGrey, underline = true},
- [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia},
- [6] = {bold = true, foreground = Screen.colors.Fuchsia},
- [7] = {bold = true, foreground = Screen.colors.SeaGreen},
- [8] = {foreground = Screen.colors.White, background = Screen.colors.Red},
- } )
+ screen:attach({ rgb = true, ext_linegrid = linegrid })
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = 255 },
+ [1] = { bold = true, reverse = true },
+ [2] = { bold = true },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightGrey, underline = true },
+ [5] = {
+ background = Screen.colors.LightGrey,
+ underline = true,
+ bold = true,
+ foreground = Screen.colors.Fuchsia,
+ },
+ [6] = { bold = true, foreground = Screen.colors.Fuchsia },
+ [7] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [8] = { foreground = Screen.colors.White, background = Screen.colors.Red },
+ })
end)
describe('bell/visual bell', function()
@@ -79,7 +88,7 @@ local function screen_tests(linegrid)
describe(':set title', function()
it('is forwarded to the UI', function()
local expected = 'test-title'
- command('set titlestring='..expected)
+ command('set titlestring=' .. expected)
command('set title')
screen:expect(function()
eq(expected, screen.title)
@@ -96,7 +105,7 @@ local function screen_tests(linegrid)
describe(':set icon', function()
it('is forwarded to the UI', function()
local expected = 'test-icon'
- command('set iconstring='..expected)
+ command('set iconstring=' .. expected)
command('set icon')
screen:expect(function()
eq(expected, screen.icon)
@@ -121,12 +130,15 @@ local function screen_tests(linegrid)
]])
feed('<c-l>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*11
{1:[No Name] }|
|
- ]], reset=true}
+ ]],
+ reset = true,
+ }
command('split')
screen:expect([[
@@ -140,7 +152,8 @@ local function screen_tests(linegrid)
]])
feed('<c-l>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*5
{1:[No Name] }|
@@ -148,7 +161,9 @@ local function screen_tests(linegrid)
{0:~ }|*4
{3:[No Name] }|
|
- ]], reset=true}
+ ]],
+ reset = true,
+ }
end)
end)
@@ -254,7 +269,7 @@ local function screen_tests(linegrid)
|
]])
- feed(':echo "'..string.rep('x\\n', 11)..'"<cr>')
+ feed(':echo "' .. string.rep('x\\n', 11) .. '"<cr>')
screen:expect([[
{1: }|
x |*11
@@ -270,7 +285,7 @@ local function screen_tests(linegrid)
|
]])
- feed(':echo "'..string.rep('x\\n', 12)..'"<cr>')
+ feed(':echo "' .. string.rep('x\\n', 12) .. '"<cr>')
screen:expect([[
x |*12
|
@@ -284,7 +299,6 @@ local function screen_tests(linegrid)
{0:~ }|*11
|
]])
-
end)
it('redraws properly with :tab split right after scroll', function()
@@ -676,11 +690,11 @@ local function screen_tests(linegrid)
end)
end
-describe("Screen (char-based)", function()
+describe('Screen (char-based)', function()
screen_tests(false)
end)
-describe("Screen (line-based)", function()
+describe('Screen (line-based)', function()
screen_tests(true)
end)
@@ -691,45 +705,73 @@ describe('Screen default colors', function()
local nvim_argv = {
helpers.nvim_prog,
- '-u', 'NONE',
- '-i', 'NONE',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
'-N',
- '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra,
- '--cmd', 'colorscheme vim',
+ '--cmd',
+ 'set shortmess+=I noswapfile belloff= noshowcmd noruler' .. extra,
+ '--cmd',
+ 'colorscheme vim',
'--embed',
}
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
screen = Screen.new()
- screen:attach(termcolors and {rgb=true,ext_termcolors=true} or {rgb=true})
+ screen:attach(termcolors and { rgb = true, ext_termcolors = true } or { rgb = true })
end
it('are dark per default', function()
startup(false, false)
- screen:expect{condition=function()
- eq({rgb_bg=0, rgb_fg=Screen.colors.White, rgb_sp=Screen.colors.Red,
- cterm_bg=0, cterm_fg=0}, screen.default_colors)
- end}
+ screen:expect {
+ condition = function()
+ eq({
+ rgb_bg = 0,
+ rgb_fg = Screen.colors.White,
+ rgb_sp = Screen.colors.Red,
+ cterm_bg = 0,
+ cterm_fg = 0,
+ }, screen.default_colors)
+ end,
+ }
end)
it('can be set to light', function()
startup(true, false)
- screen:expect{condition=function()
- eq({rgb_bg=Screen.colors.White, rgb_fg=0, rgb_sp=Screen.colors.Red,
- cterm_bg=0, cterm_fg=0}, screen.default_colors)
- end}
+ screen:expect {
+ condition = function()
+ eq({
+ rgb_bg = Screen.colors.White,
+ rgb_fg = 0,
+ rgb_sp = Screen.colors.Red,
+ cterm_bg = 0,
+ cterm_fg = 0,
+ }, screen.default_colors)
+ end,
+ }
end)
it('can be handled by external terminal', function()
startup(false, true)
- screen:expect{condition=function()
- eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors)
- end}
+ screen:expect {
+ condition = function()
+ eq(
+ { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 },
+ screen.default_colors
+ )
+ end,
+ }
startup(true, true)
- screen:expect{condition=function()
- eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors)
- end}
+ screen:expect {
+ condition = function()
+ eq(
+ { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 },
+ screen.default_colors
+ )
+ end,
+ }
end)
end)
@@ -770,13 +812,15 @@ it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", f
clear()
local screen = Screen.new(30, 2)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
})
screen:attach()
command('set showcmd redrawdebug=compositor')
feed('d')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
d |
- ]]}
+ ]],
+ }
end)
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index 1e8af4225a..68596f27ad 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -15,20 +15,20 @@ describe('search highlighting', function()
clear()
screen = Screen.new(40, 7)
screen:attach()
- screen:set_default_attr_ids( {
- [1] = {bold=true, foreground=Screen.colors.Blue},
- [2] = {background = Screen.colors.Yellow}, -- Search
- [3] = {reverse = true},
- [4] = {foreground = Screen.colors.Red}, -- WarningMsg
- [5] = {bold = true, reverse = true}, -- StatusLine
- [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded
+ screen:set_default_attr_ids({
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { background = Screen.colors.Yellow }, -- Search
+ [3] = { reverse = true },
+ [4] = { foreground = Screen.colors.Red }, -- WarningMsg
+ [5] = { bold = true, reverse = true }, -- StatusLine
+ [6] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey }, -- Folded
})
end)
it('is disabled by ":set nohlsearch"', function()
feed_command('set nohlsearch')
- insert("some text\nmore text")
- feed("gg/text<cr>")
+ insert('some text\nmore text')
+ feed('gg/text<cr>')
screen:expect([[
some ^text |
more text |
@@ -38,16 +38,27 @@ describe('search highlighting', function()
end)
it('is disabled in folded text', function()
- insert("some text\nmore text")
+ insert('some text\nmore text')
feed_command('1,2fold')
- feed("gg/text")
- screen:expect{grid=[[
+ feed('gg/text')
+ screen:expect {
+ grid = [[
{6:+-- 2 lines: some text·················}|
{1:~ }|*5
/text^ |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 8, linecount = 2, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 3,
+ curline = 0,
+ curcol = 8,
+ linecount = 2,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
end)
local function test_search_hl()
@@ -59,7 +70,7 @@ describe('search highlighting', function()
]])
-- 'hlsearch' is enabled by default. #2859
- feed("gg/text<cr>")
+ feed('gg/text<cr>')
screen:expect([[
some {2:^text} |
more {2:text}stuff |
@@ -71,7 +82,7 @@ describe('search highlighting', function()
]])
-- overlapping matches not allowed
- feed("3nx")
+ feed('3nx')
screen:expect([[
some {2:text} |
more {2:text}stuff |
@@ -82,7 +93,7 @@ describe('search highlighting', function()
/text |
]])
- feed("ggn*") -- search for entire word
+ feed('ggn*') -- search for entire word
screen:expect([[
some {2:text} |
more textstuff |
@@ -93,7 +104,7 @@ describe('search highlighting', function()
/\<text\> |
]])
- feed_command("nohlsearch")
+ feed_command('nohlsearch')
screen:expect([[
some text |
more textstuff |
@@ -112,7 +123,7 @@ describe('search highlighting', function()
it("works when 'winhighlight' doesn't change Search highlight", function()
command('setlocal winhl=NonText:Underlined')
local attrs = screen:get_default_attr_ids()
- attrs[1] = {foreground = Screen.colors.SlateBlue, underline = true}
+ attrs[1] = { foreground = Screen.colors.SlateBlue, underline = true }
screen:set_default_attr_ids(attrs)
test_search_hl()
end)
@@ -120,7 +131,7 @@ describe('search highlighting', function()
it("works when 'winhighlight' changes Search highlight", function()
command('setlocal winhl=Search:Underlined')
local attrs = screen:get_default_attr_ids()
- attrs[2] = {foreground = Screen.colors.SlateBlue, underline = true}
+ attrs[2] = { foreground = Screen.colors.SlateBlue, underline = true }
screen:set_default_attr_ids(attrs)
test_search_hl()
end)
@@ -128,9 +139,9 @@ describe('search highlighting', function()
describe('CurSearch highlight', function()
before_each(function()
screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Yellow}, -- Search
- [2] = {foreground = Screen.colors.White, background = Screen.colors.Black}, -- CurSearch
- [3] = {foreground = Screen.colors.Red}, -- WarningMsg
+ [1] = { background = Screen.colors.Yellow }, -- Search
+ [2] = { foreground = Screen.colors.White, background = Screen.colors.Black }, -- CurSearch
+ [3] = { foreground = Screen.colors.Red }, -- WarningMsg
})
command('highlight CurSearch guibg=Black guifg=White')
end)
@@ -145,7 +156,8 @@ describe('search highlighting', function()
humans think is impossible.]])
feed('/bee<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
There is no way that a {2:^bee} should be |
able to fly. Its wings are too small |
to get its fat little body off the |
@@ -153,10 +165,12 @@ describe('search highlighting', function()
anyway because {1:bee}s don't care what |
humans think is impossible. |
{3:search hit BOTTOM, continuing at TOP} |
- ]]}
+ ]],
+ }
feed('nn')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
There is no way that a {1:bee} should be |
able to fly. Its wings are too small |
to get its fat little body off the |
@@ -164,10 +178,12 @@ describe('search highlighting', function()
anyway because {2:^bee}s don't care what |
humans think is impossible. |
/bee |
- ]]}
+ ]],
+ }
feed('N')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
There is no way that a {1:bee} should be |
able to fly. Its wings are too small |
to get its fat little body off the |
@@ -175,7 +191,8 @@ describe('search highlighting', function()
anyway because {1:bee}s don't care what |
humans think is impossible. |
?bee |
- ]]}
+ ]],
+ }
end)
it('works for multiline match', function()
@@ -266,9 +283,9 @@ describe('search highlighting', function()
end)
it('highlights after EOL', function()
- insert("\n\n\n\n\n\n")
+ insert('\n\n\n\n\n\n')
- feed("gg/^<cr>")
+ feed('gg/^<cr>')
screen:expect([[
{2: } |
{2:^ } |
@@ -277,7 +294,7 @@ describe('search highlighting', function()
]])
-- Test that highlights are preserved after moving the cursor.
- feed("j")
+ feed('j')
screen:expect([[
{2: } |*2
{2:^ } |
@@ -286,9 +303,9 @@ describe('search highlighting', function()
]])
-- Repeat the test in rightleft mode.
- command("nohlsearch")
- command("set rightleft")
- feed("gg/^<cr>")
+ command('nohlsearch')
+ command('set rightleft')
+ feed('gg/^<cr>')
screen:expect([[
{2: }|
@@ -297,7 +314,7 @@ describe('search highlighting', function()
^/ |
]])
- feed("j")
+ feed('j')
screen:expect([[
{2: }|*2
{2:^ }|
@@ -319,7 +336,7 @@ describe('search highlighting', function()
:file term |
]])
- feed('G') -- Follow :terminal output.
+ feed('G') -- Follow :terminal output.
feed(':vnew<CR>')
insert([[
foo bar baz
@@ -344,7 +361,7 @@ describe('search highlighting', function()
the first line
in a little file]])
command('vsplit')
- feed("gg/li")
+ feed('gg/li')
screen:expect([[
the first {3:li}ne │the first {2:li}ne |
in a {2:li}ttle file │in a {2:li}ttle file |
@@ -353,7 +370,7 @@ describe('search highlighting', function()
]])
-- check that consecutive matches are caught by C-g/C-t
- feed("<C-g>")
+ feed('<C-g>')
screen:expect([[
the first {2:li}ne │the first {2:li}ne |
in a {3:li}ttle file │in a {2:li}ttle file |
@@ -361,7 +378,7 @@ describe('search highlighting', function()
/li^ |
]])
- feed("<C-t>")
+ feed('<C-t>')
screen:expect([[
the first {3:li}ne │the first {2:li}ne |
in a {2:li}ttle file │in a {2:li}ttle file |
@@ -369,7 +386,7 @@ describe('search highlighting', function()
/li^ |
]])
- feed("t")
+ feed('t')
screen:expect([[
the first line │the first line |
in a {3:lit}tle file │in a {2:lit}tle file |
@@ -377,7 +394,7 @@ describe('search highlighting', function()
/lit^ |
]])
- feed("<cr>")
+ feed('<cr>')
screen:expect([[
the first line │the first line |
in a {2:^lit}tle file │in a {2:lit}tle file |
@@ -385,7 +402,7 @@ describe('search highlighting', function()
/lit |
]])
- feed("/fir")
+ feed('/fir')
screen:expect([[
the {3:fir}st line │the {2:fir}st line |
in a little file │in a little file |
@@ -394,7 +411,7 @@ describe('search highlighting', function()
]])
-- incsearch have priority over hlsearch
- feed("<esc>/ttle")
+ feed('<esc>/ttle')
screen:expect([[
the first line │the first line |
in a li{3:ttle} file │in a li{2:ttle} file |
@@ -441,13 +458,13 @@ describe('search highlighting', function()
command([[let @/ = 'i']])
-- moves to next match of previous search pattern, just like /<cr>
feed('/<c-g><cr>')
- eq({0, 1, 6, 0}, funcs.getpos('.'))
+ eq({ 0, 1, 6, 0 }, funcs.getpos('.'))
-- moves to next match of previous search pattern, just like /<cr>
feed('/<cr>')
- eq({0, 1, 12, 0}, funcs.getpos('.'))
+ eq({ 0, 1, 12, 0 }, funcs.getpos('.'))
-- moves to next match of previous search pattern, just like /<cr>
feed('/<c-t><cr>')
- eq({0, 2, 1, 0}, funcs.getpos('.'))
+ eq({ 0, 2, 1, 0 }, funcs.getpos('.'))
-- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern
feed('<esc>/fi<CR>')
@@ -515,7 +532,7 @@ describe('search highlighting', function()
not the match you're looking for
the match is here]])
- feed("gg/mat/e")
+ feed('gg/mat/e')
screen:expect([[
not the {3:mat}ch you're looking for |
the {2:mat}ch is here |
@@ -524,7 +541,7 @@ describe('search highlighting', function()
]])
-- Search with count and /e offset fixed in Vim patch 7.4.532.
- feed("<esc>2/mat/e")
+ feed('<esc>2/mat/e')
screen:expect([[
not the {2:mat}ch you're looking for |
the {3:mat}ch is here |
@@ -532,7 +549,7 @@ describe('search highlighting', function()
/mat/e^ |
]])
- feed("<cr>")
+ feed('<cr>')
screen:expect([[
not the {2:mat}ch you're looking for |
the {2:ma^t}ch is here |
@@ -569,45 +586,58 @@ describe('search highlighting', function()
it('works with matchadd and syntax', function()
screen:set_default_attr_ids {
- [1] = {bold=true, foreground=Screen.colors.Blue};
- [2] = {background = Screen.colors.Yellow};
- [3] = {reverse = true};
- [4] = {foreground = Screen.colors.Red};
- [5] = {bold = true, background = Screen.colors.Green};
- [6] = {italic = true, background = Screen.colors.Magenta};
- [7] = {bold = true, background = Screen.colors.Yellow};
- [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray};
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { background = Screen.colors.Yellow },
+ [3] = { reverse = true },
+ [4] = { foreground = Screen.colors.Red },
+ [5] = { bold = true, background = Screen.colors.Green },
+ [6] = { italic = true, background = Screen.colors.Magenta },
+ [7] = { bold = true, background = Screen.colors.Yellow },
+ [8] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGray },
}
feed_command('set hlsearch')
insert [[
very special text
]]
- feed_command("syntax on")
- feed_command("highlight MyGroup guibg=Green gui=bold")
- feed_command("highlight MyGroup2 guibg=Magenta gui=italic")
+ feed_command('syntax on')
+ feed_command('highlight MyGroup guibg=Green gui=bold')
+ feed_command('highlight MyGroup2 guibg=Magenta gui=italic')
feed_command("call matchadd('MyGroup', 'special')")
feed_command("call matchadd('MyGroup2', 'text', 0)")
-- searchhl and matchadd matches are exclusive, only the highest priority
-- is used (and matches with lower priorities are not combined)
- feed_command("/ial te")
- screen:expect{grid=[[
+ feed_command('/ial te')
+ screen:expect {
+ grid = [[
very {5:spec^ial}{2: te}{6:xt} |
|
{1:~ }|*4
{4:search hit BOTTOM, continuing at TOP} |
- ]], win_viewport={
- [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2, sum_scroll_delta = 0};
- }}
+ ]],
+ win_viewport = {
+ [2] = {
+ win = { id = 1000 },
+ topline = 0,
+ botline = 3,
+ curline = 0,
+ curcol = 11,
+ linecount = 2,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
-- check highlights work also in folds
- feed("zf4j")
- screen:expect{grid=[[
+ feed('zf4j')
+ screen:expect {
+ grid = [[
{8:^+-- 2 lines: very special text·········}|
{1:~ }|*5
{4:search hit BOTTOM, continuing at TOP} |
- ]]}
- command("%foldopen")
+ ]],
+ }
+ command('%foldopen')
screen:expect([[
very {5:spec^ial}{2: te}{6:xt} |
|
@@ -615,7 +645,7 @@ describe('search highlighting', function()
{4:search hit BOTTOM, continuing at TOP} |
]])
- feed_command("call clearmatches()")
+ feed_command('call clearmatches()')
screen:expect([[
very spec{2:^ial te}xt |
|
@@ -625,7 +655,7 @@ describe('search highlighting', function()
-- searchhl has priority over syntax, but in this case
-- nonconflicting attributes are combined
- feed_command("syntax keyword MyGroup special")
+ feed_command('syntax keyword MyGroup special')
screen:expect([[
very {5:spec}{7:^ial}{2: te}xt |
|
@@ -645,4 +675,3 @@ describe('search highlighting', function()
]])
end)
end)
-
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua
index c07db8d3de..53fa4b6d65 100644
--- a/test/functional/ui/sign_spec.lua
+++ b/test/functional/ui/sign_spec.lua
@@ -9,20 +9,20 @@ describe('Signs', function()
clear()
screen = Screen.new()
screen:attach()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=255},
- [1] = {background = Screen.colors.Yellow},
- [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey},
- [3] = {background = Screen.colors.Gray90},
- [4] = {bold = true, reverse = true},
- [5] = {reverse = true},
- [6] = {foreground = Screen.colors.Brown},
- [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [9] = {bold = true, foreground = Screen.colors.Magenta},
- [10] = {foreground = Screen.colors.Blue1},
- [11] = {bold = true, foreground = Screen.colors.SeaGreen4},
- } )
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = 255 },
+ [1] = { background = Screen.colors.Yellow },
+ [2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey },
+ [3] = { background = Screen.colors.Gray90 },
+ [4] = { bold = true, reverse = true },
+ [5] = { reverse = true },
+ [6] = { foreground = Screen.colors.Brown },
+ [7] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
+ [8] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [9] = { bold = true, foreground = Screen.colors.Magenta },
+ [10] = { foreground = Screen.colors.Blue1 },
+ [11] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ })
end)
describe(':sign place', function()
@@ -468,7 +468,7 @@ describe('Signs', function()
end)
it('signcolumn width is updated when removing all signs after deleting lines', function()
- meths.buf_set_lines(0, 0, 1, true, {'a', 'b', 'c', 'd', 'e'})
+ meths.buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
exec('sign define piet text=>>')
exec('sign place 10001 line=1 name=piet')
exec('sign place 10002 line=5 name=piet')
@@ -494,7 +494,7 @@ describe('Signs', function()
end)
it('signcolumn width is updated when removing all signs after inserting lines', function()
- meths.buf_set_lines(0, 0, 1, true, {'a', 'b', 'c', 'd', 'e'})
+ meths.buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
exec('sign define piet text=>>')
exec('sign place 10001 line=1 name=piet')
exec('sign place 10002 line=5 name=piet')
diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua
index cc39790dca..13c3b24cc1 100644
--- a/test/functional/ui/spell_spec.lua
+++ b/test/functional/ui/spell_spec.lua
@@ -17,23 +17,26 @@ describe("'spell'", function()
clear()
screen = Screen.new(80, 8)
screen:attach()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {special = Screen.colors.Red, undercurl = true},
- [2] = {special = Screen.colors.Blue, undercurl = true},
- [3] = {foreground = tonumber('0x6a0dad')},
- [4] = {foreground = Screen.colors.Magenta},
- [5] = {bold = true, foreground = Screen.colors.SeaGreen},
- [6] = {foreground = Screen.colors.Red},
- [7] = {foreground = Screen.colors.Blue},
- [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true},
- [9] = {bold = true},
- [10] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue},
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { special = Screen.colors.Red, undercurl = true },
+ [2] = { special = Screen.colors.Blue, undercurl = true },
+ [3] = { foreground = tonumber('0x6a0dad') },
+ [4] = { foreground = Screen.colors.Magenta },
+ [5] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [6] = { foreground = Screen.colors.Red },
+ [7] = { foreground = Screen.colors.Blue },
+ [8] = { foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true },
+ [9] = { bold = true },
+ [10] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue },
})
end)
it('joins long lines #7937', function()
- if is_os('openbsd') then pending('FIXME #12104', function() end) return end
+ if is_os('openbsd') then
+ pending('FIXME #12104', function() end)
+ return
+ end
exec('set spell')
insert([[
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
@@ -54,7 +57,6 @@ describe("'spell'", function()
{0:~ }|
|
]])
-
end)
-- oldtest: Test_spell_screendump()
@@ -258,7 +260,7 @@ describe("'spell'", function()
{6:search hit BOTTOM, continuing at TOP} |
]])
exec('echo ""')
- local ns = meths.create_namespace("spell")
+ local ns = meths.create_namespace('spell')
-- extmark with spell=true enables spell
local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true })
screen:expect([[
@@ -366,7 +368,7 @@ describe("'spell'", function()
syntax match Constant "^.*$"
call setline(1, "This is some text without any spell errors.")
]])
- local ns = meths.create_namespace("spell")
+ local ns = meths.create_namespace('spell')
curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 })
screen:expect([[
{6:^This is some text without any spell errors.}|
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index f786355b4d..47a68c368e 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -11,7 +11,7 @@ local meths = helpers.meths
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
-local mousemodels = { "extend", "popup", "popup_setpos" }
+local mousemodels = { 'extend', 'popup', 'popup_setpos' }
describe('statuscolumn', function()
local screen
@@ -23,7 +23,9 @@ describe('statuscolumn', function()
end)
it("fails with invalid 'statuscolumn'", function()
- command([[set stc=%{v:relnum?v:relnum:(v:lnum==5?'truncate':v:lnum)}%{!v:relnum&&v:lnum==5?invalid:''}\ ]])
+ command(
+ [[set stc=%{v:relnum?v:relnum:(v:lnum==5?'truncate':v:lnum)}%{!v:relnum&&v:lnum==5?invalid:''}\ ]]
+ )
screen:expect([[
4 aaaaa |
3 aaaaa |
@@ -141,12 +143,14 @@ describe('statuscolumn', function()
end)
it("works with highlighted 'statuscolumn'", function()
- command([[set stc=%#NonText#%{&nu?v:lnum:''}]] ..
- [[%=%{&rnu&&(v:lnum%2)?'\ '.v:relnum:''}]] ..
- [[%#LineNr#%{&rnu&&!(v:lnum%2)?'\ '.v:relnum:''}│]])
+ command(
+ [[set stc=%#NonText#%{&nu?v:lnum:''}]]
+ .. [[%=%{&rnu&&(v:lnum%2)?'\ '.v:relnum:''}]]
+ .. [[%#LineNr#%{&rnu&&!(v:lnum%2)?'\ '.v:relnum:''}│]]
+ )
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
- [1] = {foreground = Screen.colors.Brown},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { foreground = Screen.colors.Brown },
})
screen:expect([[
{0:4 }{1:│}aaaaa |
@@ -204,13 +208,13 @@ describe('statuscolumn', function()
command([[set stc=%C%s%=%{v:virtnum?'':v:lnum}│\ ]])
command("call setline(1,repeat([repeat('aaaaa',10)],16))")
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
- [1] = {foreground = Screen.colors.Brown},
- [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey},
- [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [4] = {bold = true, foreground = Screen.colors.Brown},
- [5] = {foreground = Screen.colors.Red},
- [6] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { foreground = Screen.colors.Brown },
+ [2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey },
+ [3] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
+ [4] = { bold = true, foreground = Screen.colors.Brown },
+ [5] = { foreground = Screen.colors.Red },
+ [6] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey },
})
command('hi! CursorLine guifg=Red guibg=NONE')
screen:expect([[
@@ -434,7 +438,9 @@ describe('statuscolumn', function()
vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_lines = {{{"virt_line", ""}}} })
]])
command('set foldcolumn=0 signcolumn=no')
- command([[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]])
+ command(
+ [[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]]
+ )
screen:expect([[
{1:buffer 0 4}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{1:wrapped 1 4}aaaaaaaa |
@@ -497,8 +503,8 @@ describe('statuscolumn', function()
it('does not corrupt the screen with minwid sign item', function()
screen:try_resize(screen._width, 3)
screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Brown},
- [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Gray},
+ [0] = { foreground = Screen.colors.Brown },
+ [1] = { foreground = Screen.colors.Blue4, background = Screen.colors.Gray },
})
command([[set stc=%6s\ %l]])
exec_lua('vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {sign_text = "𒀀"})')
@@ -527,78 +533,81 @@ describe('statuscolumn', function()
it('clicks work with mousemodel=' .. model, function()
meths.set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {})
meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 1 l 4', eval("g:testvar"))
+ eq('0 1 l 4', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 2 l 4', eval("g:testvar"))
+ eq('0 2 l 4', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 3 l 4', eval("g:testvar"))
+ eq('0 3 l 4', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 4 l 4', eval("g:testvar"))
+ eq('0 4 l 4', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 1 r 7', eval("g:testvar"))
+ eq('0 1 r 7', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 2 r 7', eval("g:testvar"))
+ eq('0 2 r 7', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 3 r 7', eval("g:testvar"))
+ eq('0 3 r 7', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 4 r 7', eval("g:testvar"))
+ eq('0 4 r 7', eval('g:testvar'))
command('rightbelow vsplit')
meths.input_mouse('left', 'press', '', 0, 0, 27)
- eq('0 1 l 4', eval("g:testvar"))
+ eq('0 1 l 4', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 27)
- eq('0 1 r 7', eval("g:testvar"))
+ eq('0 1 r 7', eval('g:testvar'))
command('setlocal rightleft')
meths.input_mouse('left', 'press', '', 0, 0, 52)
- eq('0 1 l 4', eval("g:testvar"))
+ eq('0 1 l 4', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 52)
- eq('0 1 r 7', eval("g:testvar"))
+ eq('0 1 r 7', eval('g:testvar'))
command('wincmd H')
meths.input_mouse('left', 'press', '', 0, 0, 25)
- eq('0 1 l 4', eval("g:testvar"))
+ eq('0 1 l 4', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 3, 25)
- eq('0 1 r 7', eval("g:testvar"))
+ eq('0 1 r 7', eval('g:testvar'))
command('close')
command('set laststatus=2 winbar=%f')
command('let g:testvar = ""')
-- Check that winbar click doesn't register as statuscolumn click
meths.input_mouse('right', 'press', '', 0, 0, 0)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
-- Check that statusline click doesn't register as statuscolumn click
meths.input_mouse('right', 'press', '', 0, 12, 0)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
-- Check that cmdline click doesn't register as statuscolumn click
meths.input_mouse('right', 'press', '', 0, 13, 0)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
end)
it('clicks and highlights work with control characters', function()
meths.set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*4
{1:^I}{0:^A^I^A^I}{1:^A}^aaaaa |
{1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*8
|
- ]], attr_ids={
- [0] = {foreground = Screen.colors.Blue, bold = true}; -- NonText
- [1] = {foreground = Screen.colors.Brown}; -- LineNr
- }}
+ ]],
+ attr_ids = {
+ [0] = { foreground = Screen.colors.Blue, bold = true }, -- NonText
+ [1] = { foreground = Screen.colors.Brown }, -- LineNr
+ },
+ }
meths.input_mouse('right', 'press', '', 0, 4, 3)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 5, 8)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 4)
- eq('0 1 r 10', eval("g:testvar"))
+ eq('0 1 r 10', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 7, 7)
- eq('0 1 l 11', eval("g:testvar"))
+ eq('0 1 l 11', eval('g:testvar'))
end)
it('popupmenu callback does not drag mouse on close', function()
screen:try_resize(screen._width, 2)
screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Brown},
- [1] = {background = Screen.colors.Plum1},
+ [0] = { foreground = Screen.colors.Brown },
+ [1] = { background = Screen.colors.Plum1 },
})
meths.set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {})
exec([[
@@ -665,7 +674,9 @@ describe('statuscolumn', function()
it('works with foldcolumn', function()
-- Fits maximum multibyte foldcolumn #21759
command([[set stc=%C%=%l\ fdc=9 fillchars=foldsep:𒀀]])
- for _ = 0,8 do command('norm zfjzo') end
+ for _ = 0, 8 do
+ command('norm zfjzo')
+ end
-- 'statuscolumn' is not drawn for `virt_lines_leftcol` lines
exec_lua([[
vim.api.nvim_buf_set_extmark(0, ns, 6, 0, {
@@ -689,7 +700,7 @@ describe('statuscolumn', function()
14 aaaaa |
|
]])
- command('set stc=') -- also for the default fold column
+ command('set stc=') -- also for the default fold column
screen:expect_unchanged()
-- 'statuscolumn' is not too wide with custom (bogus) fold column
command([[set stc=%{foldlevel(v:lnum)>0?repeat('-',foldlevel(v:lnum)):''}%=%l\ ]])
@@ -763,7 +774,7 @@ describe('statuscolumn', function()
]])
end)
- it("has correct width with custom sign column when (un)placing signs", function()
+ it('has correct width with custom sign column when (un)placing signs', function()
screen:try_resize(screen._width, 3)
exec_lua([[
vim.cmd.norm('gg')
@@ -820,13 +831,13 @@ describe('statuscolumn', function()
2 ssssaaaaa |
|
]])
- exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id1)")
+ exec_lua('vim.api.nvim_buf_del_extmark(0, ns, id1)')
screen:expect([[
1 ^aaaaa |
2 ssaaaaa |
|
]])
- exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id2)")
+ exec_lua('vim.api.nvim_buf_del_extmark(0, ns, id2)')
screen:expect([[
1 ^aaaaa |
2 aaaaa |
@@ -842,7 +853,7 @@ describe('statuscolumn', function()
]])
end)
- it("is only evaluated twice, once to estimate and once to draw", function()
+ it('is only evaluated twice, once to estimate and once to draw', function()
command([[
let g:stcnr = 0
func! Stc()
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index a88c03f565..873f529097 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -12,7 +12,7 @@ local exec_lua = helpers.exec_lua
local eval = helpers.eval
local sleep = helpers.sleep
-local mousemodels = { "extend", "popup", "popup_setpos" }
+local mousemodels = { 'extend', 'popup', 'popup_setpos' }
for _, model in ipairs(mousemodels) do
describe('statusline clicks with mousemodel=' .. model, function()
@@ -22,8 +22,8 @@ for _, model in ipairs(mousemodels) do
clear()
screen = Screen.new(40, 8)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
- [1] = {bold = true, reverse = true}; -- StatusLine
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { bold = true, reverse = true }, -- StatusLine
})
screen:attach()
command('set laststatus=2 mousemodel=' .. model)
@@ -39,76 +39,84 @@ for _, model in ipairs(mousemodels) do
end)
it('works', function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 6, 16)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 29)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 2 l', eval("g:testvar"))
+ eq('0 2 l', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 3 l', eval("g:testvar"))
+ eq('0 3 l', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 4 l', eval("g:testvar"))
+ eq('0 4 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 28)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 28)
- eq('0 2 r', eval("g:testvar"))
+ eq('0 2 r', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 28)
- eq('0 3 r', eval("g:testvar"))
+ eq('0 3 r', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 28)
- eq('0 4 r', eval("g:testvar"))
+ eq('0 4 r', eval('g:testvar'))
end)
it('works with control characters and highlight', function()
- meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
- screen:expect{grid=[[
+ meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*5
{1:^I}{0:^A^I^A^I}{1:^A }|
|
- ]]}
+ ]],
+ }
meths.input_mouse('right', 'press', '', 0, 6, 3)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 8)
- eq('', eval("g:testvar"))
+ eq('', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 4)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 7)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
end)
it('works for winbar', function()
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 0, 17)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 0, 17)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
end)
it('works for winbar in floating window', function()
- meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5,
- border = "single" })
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
- { scope = 'local' })
+ meths.open_win(
+ 0,
+ true,
+ { width = 30, height = 4, relative = 'editor', row = 1, col = 5, border = 'single' }
+ )
+ meths.set_option_value(
+ 'winbar',
+ 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
+ { scope = 'local' }
+ )
meths.input_mouse('left', 'press', '', 0, 2, 23)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
end)
it('works when there are multiple windows', function()
command('split')
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 0, 17)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 4, 17)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
meths.input_mouse('middle', 'press', '', 0, 3, 17)
- eq('0 1 m', eval("g:testvar"))
+ eq('0 1 m', eval('g:testvar'))
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
end)
it('works with Lua function', function()
@@ -117,79 +125,89 @@ for _, model in ipairs(mousemodels) do
vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
end
]])
- meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {})
+ meths.set_option_value(
+ 'statusline',
+ 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T',
+ {}
+ )
meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
end)
it('ignores unsupported click items', function()
command('tabnew | tabprevious')
- meths.set_option_value('statusline', '%2TNot clicky stuff%T', {})
+ meths.set_option_value('statusline', '%2TNot clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 6, 0)
eq(1, meths.get_current_tabpage().id)
- meths.set_option_value('statusline', '%2XNot clicky stuff%X', {})
+ meths.set_option_value('statusline', '%2XNot clicky stuff%X', {})
meths.input_mouse('left', 'press', '', 0, 6, 0)
eq(2, #meths.list_tabpages())
end)
it("right click works when statusline isn't focused #18994", function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 2 r', eval("g:testvar"))
+ eq('0 2 r', eval('g:testvar'))
end)
- it("works with modifiers #18994", function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ it('works with modifiers #18994', function()
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
-- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
meths.input_mouse('left', 'press', 'S', 0, 6, 17)
- eq('0 1 l(s )', eval("g:testvar"))
+ eq('0 1 l(s )', eval('g:testvar'))
meths.input_mouse('right', 'press', 'S', 0, 6, 17)
- eq('0 1 r(s )', eval("g:testvar"))
+ eq('0 1 r(s )', eval('g:testvar'))
meths.input_mouse('left', 'press', 'A', 0, 6, 17)
- eq('0 1 l( a )', eval("g:testvar"))
+ eq('0 1 l( a )', eval('g:testvar'))
meths.input_mouse('right', 'press', 'A', 0, 6, 17)
- eq('0 1 r( a )', eval("g:testvar"))
+ eq('0 1 r( a )', eval('g:testvar'))
meths.input_mouse('left', 'press', 'AS', 0, 6, 17)
- eq('0 1 l(s a )', eval("g:testvar"))
+ eq('0 1 l(s a )', eval('g:testvar'))
meths.input_mouse('right', 'press', 'AS', 0, 6, 17)
- eq('0 1 r(s a )', eval("g:testvar"))
+ eq('0 1 r(s a )', eval('g:testvar'))
meths.input_mouse('left', 'press', 'T', 0, 6, 17)
- eq('0 1 l( m)', eval("g:testvar"))
+ eq('0 1 l( m)', eval('g:testvar'))
meths.input_mouse('right', 'press', 'T', 0, 6, 17)
- eq('0 1 r( m)', eval("g:testvar"))
+ eq('0 1 r( m)', eval('g:testvar'))
meths.input_mouse('left', 'press', 'TS', 0, 6, 17)
- eq('0 1 l(s m)', eval("g:testvar"))
+ eq('0 1 l(s m)', eval('g:testvar'))
meths.input_mouse('right', 'press', 'TS', 0, 6, 17)
- eq('0 1 r(s m)', eval("g:testvar"))
+ eq('0 1 r(s m)', eval('g:testvar'))
meths.input_mouse('left', 'press', 'C', 0, 6, 17)
- eq('0 1 l( c )', eval("g:testvar"))
+ eq('0 1 l( c )', eval('g:testvar'))
-- <C-RightMouse> is for tag jump
end)
- it("works for global statusline with vertical splits #19186", function()
+ it('works for global statusline with vertical splits #19186', function()
command('set laststatus=3')
- meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value(
+ 'statusline',
+ '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T',
+ {}
+ )
command('vsplit')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ │ |
{0:~ }│{0:~ }|*5
{1:Clicky stuff Clicky stuff}|
|
- ]]}
+ ]],
+ }
-- clickable area on the right
meths.input_mouse('left', 'press', '', 0, 6, 35)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 35)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
-- clickable area on the left
meths.input_mouse('left', 'press', '', 0, 6, 5)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 5)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
end)
it('no memory leak with zero-width click labels', function()
@@ -197,9 +215,9 @@ for _, model in ipairs(mousemodels) do
let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
]])
meths.input_mouse('left', 'press', '', 0, 6, 0)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
meths.input_mouse('right', 'press', '', 0, 6, 39)
- eq('0 1 r', eval("g:testvar"))
+ eq('0 1 r', eval('g:testvar'))
end)
it('no memory leak with truncated click labels', function()
@@ -207,7 +225,7 @@ for _, model in ipairs(mousemodels) do
let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
]])
meths.input_mouse('left', 'press', '', 0, 6, 2)
- eq('0 1 l', eval("g:testvar"))
+ eq('0 1 l', eval('g:testvar'))
end)
end)
end
@@ -220,11 +238,11 @@ describe('global statusline', function()
screen = Screen.new(60, 16)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue};
- [2] = {bold = true, reverse = true};
- [3] = {bold = true};
- [4] = {reverse = true};
- [5] = {bold = true, foreground = Screen.colors.Fuchsia};
+ [1] = { bold = true, foreground = Screen.colors.Blue },
+ [2] = { bold = true, reverse = true },
+ [3] = { bold = true },
+ [4] = { reverse = true },
+ [5] = { bold = true, foreground = Screen.colors.Fuchsia },
})
command('set laststatus=3')
command('set ruler')
@@ -470,8 +488,8 @@ it('statusline is redrawn with :resize from <Cmd> mapping #19629', function()
clear()
local screen = Screen.new(40, 8)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
- [1] = {bold = true, reverse = true}, -- StatusLine
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { bold = true, reverse = true }, -- StatusLine
})
screen:attach()
exec([[
@@ -499,9 +517,9 @@ it('showcmdloc=statusline does not show if statusline is too narrow', function()
clear()
local screen = Screen.new(40, 8)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
- [1] = {bold = true, reverse = true}, -- StatusLine
- [2] = {reverse = true}, -- StatusLineNC
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { bold = true, reverse = true }, -- StatusLine
+ [2] = { reverse = true }, -- StatusLineNC
})
screen:attach()
command('set showcmd')
@@ -630,13 +648,13 @@ it('ruler is redrawn in cmdline with redrawstatus #22804', function()
]])
end)
-it("shows correct ruler in cmdline with no statusline", function()
+it('shows correct ruler in cmdline with no statusline', function()
clear()
local screen = Screen.new(30, 8)
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
- [2] = {bold = true, reverse = true}, -- StatusLine
- [3] = {reverse = true}, -- StatusLineNC
+ [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [2] = { bold = true, reverse = true }, -- StatusLine
+ [3] = { reverse = true }, -- StatusLineNC
}
screen:attach()
-- Use long ruler to check 'ruler' with 'rulerformat' set has correct width.
@@ -688,15 +706,17 @@ it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function
local screen = Screen.new(53, 4)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
+ [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
})
command('hi clear StatusLine')
command('hi clear StatusLineNC')
command('vsplit')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ │ |
{1:~ }│{1:~ }|
[No Name] [No Name] |
|
- ]]}
+ ]],
+ }
end)
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index c3406067bc..087fdf4f14 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -11,26 +11,25 @@ describe('Screen', function()
before_each(function()
clear()
- screen = Screen.new(nil,10)
+ screen = Screen.new(nil, 10)
screen:attach()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray},
- [2] = {bold = true, reverse = true},
- [3] = {reverse = true},
- [4] = {bold = true},
- [5] = {background = Screen.colors.Yellow},
- [6] = {background = Screen.colors.LightGrey},
- } )
+ screen:set_default_attr_ids({
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
+ [2] = { bold = true, reverse = true },
+ [3] = { reverse = true },
+ [4] = { bold = true },
+ [5] = { background = Screen.colors.Yellow },
+ [6] = { background = Screen.colors.LightGrey },
+ })
end)
- describe("match and conceal", function()
-
+ describe('match and conceal', function()
before_each(function()
- command("let &conceallevel=1")
+ command('let &conceallevel=1')
end)
- describe("multiple", function()
+ describe('multiple', function()
before_each(function()
insert([[
&&
@@ -43,7 +42,7 @@ describe('Screen', function()
command("syn match dAmpersand '[&][&]' conceal cchar=∧")
end)
- it("double characters.", function()
+ it('double characters.', function()
screen:expect([[
{1:∧} |*6
^ |
@@ -53,7 +52,7 @@ describe('Screen', function()
end)
it('double characters and move the cursor one line up.', function()
- feed("k")
+ feed('k')
screen:expect([[
{1:∧} |*5
^&& |
@@ -64,7 +63,7 @@ describe('Screen', function()
end)
it('double characters and move the cursor to the beginning of the file.', function()
- feed("gg")
+ feed('gg')
screen:expect([[
^&& |
{1:∧} |*5
@@ -75,7 +74,7 @@ describe('Screen', function()
end)
it('double characters and move the cursor to the second line in the file.', function()
- feed("ggj")
+ feed('ggj')
screen:expect([[
{1:∧} |
^&& |
@@ -86,21 +85,24 @@ describe('Screen', function()
]])
end)
- it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function()
- feed("ggG")
- screen:expect([[
+ it(
+ 'double characters and then move the cursor to the beginning of the file and back to the end of the file.',
+ function()
+ feed('ggG')
+ screen:expect([[
{1:∧} |*6
^ |
{0:~ }|*2
|
]])
- end)
+ end
+ )
end) -- multiple
- it("keyword instances in initially in the document.", function()
- feed("2ilambda<cr><ESC>")
- command("let &conceallevel=1")
- command("syn keyword kLambda lambda conceal cchar=λ")
+ it('keyword instances in initially in the document.', function()
+ feed('2ilambda<cr><ESC>')
+ command('let &conceallevel=1')
+ command('syn keyword kLambda lambda conceal cchar=λ')
screen:expect([[
{1:λ} |*2
^ |
@@ -109,12 +111,11 @@ describe('Screen', function()
]])
end) -- Keyword
- describe("regions in the document", function()
-
+ describe('regions in the document', function()
before_each(function()
- feed("2")
- insert("<r> a region of text </r>\n")
- command("let &conceallevel=1")
+ feed('2')
+ insert('<r> a region of text </r>\n')
+ command('let &conceallevel=1')
end)
it('initially and conceal it.', function()
@@ -139,9 +140,11 @@ describe('Screen', function()
]])
end)
- it('that are nested and conceal the nested region\'s start and end tags.', function()
- command("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
- insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n")
+ it("that are nested and conceal the nested region's start and end tags.", function()
+ command(
+ "syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-"
+ )
+ insert('<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n')
screen:expect([[
{1: } a region of text {1:-} |*2
{1: } A region with {1: } a nested {1: } nested region.{1:-} |
@@ -153,15 +156,15 @@ describe('Screen', function()
end)
end) -- regions in the document
- describe("a region of text", function()
+ describe('a region of text', function()
before_each(function()
- command("syntax conceal on")
- feed("2")
- insert("<r> a region of text </r>\n")
+ command('syntax conceal on')
+ feed('2')
+ insert('<r> a region of text </r>\n')
command("syn region rText start='<r>' end='</r>' cchar=-")
end)
- it("and turn on implicit concealing", function()
+ it('and turn on implicit concealing', function()
screen:expect([[
{1:-} |*2
^ |
@@ -170,10 +173,10 @@ describe('Screen', function()
]])
end)
- it("and then turn on, then off, and then back on implicit concealing.", function()
- command("syntax conceal off")
- feed("2")
- insert("<i> italian text </i>\n")
+ it('and then turn on, then off, and then back on implicit concealing.', function()
+ command('syntax conceal off')
+ feed('2')
+ insert('<i> italian text </i>\n')
command("syn region iText start='<i>' end='</i>' cchar=*")
screen:expect([[
{1:-} |*2
@@ -182,7 +185,7 @@ describe('Screen', function()
{0:~ }|*4
|
]])
- command("syntax conceal on")
+ command('syntax conceal on')
command("syn region iText start='<i>' end='</i>' cchar=*")
screen:expect([[
{1:-} |*2
@@ -194,18 +197,18 @@ describe('Screen', function()
end)
end) -- a region of text (implicit concealing)
- it("cursor position is correct when entering Insert mode with cocu=ni #13916", function()
+ 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=&")
+ feed('$')
+ command('set concealcursor=ni')
+ command('syn match Foo /foobar/ conceal cchar=&')
screen:expect([[
{1:&&&}^ |
{0:~ }|*8
|
]])
- feed("i")
+ feed('i')
-- cursor should stay in place, not jump to column 16
screen:expect([[
{1:&&&}^ |
@@ -215,18 +218,18 @@ describe('Screen', function()
end)
end) -- match and conceal
- describe("let the conceal level be", function()
+ describe('let the conceal level be', function()
before_each(function()
- insert("// No Conceal\n")
+ insert('// No Conceal\n')
insert('"Conceal without a cchar"\n')
- insert("+ With cchar\n\n")
+ insert('+ With cchar\n\n')
command("syn match noConceal '^//.*$'")
- command("syn match concealNoCchar '\".\\{-}\"$' conceal")
+ command('syn match concealNoCchar \'".\\{-}"$\' conceal')
command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C")
end)
- it("0. No concealing.", function()
- command("let &conceallevel=0")
+ it('0. No concealing.', function()
+ command('let &conceallevel=0')
screen:expect([[
// No Conceal |
"Conceal without a cchar" |
@@ -238,8 +241,8 @@ describe('Screen', function()
]])
end)
- it("1. Conceal using cchar or reference listchars.", function()
- command("let &conceallevel=1")
+ it('1. Conceal using cchar or reference listchars.', function()
+ command('let &conceallevel=1')
screen:expect([[
// No Conceal |
{1: } |
@@ -251,8 +254,8 @@ describe('Screen', function()
]])
end)
- it("2. Hidden unless cchar is set.", function()
- command("let &conceallevel=2")
+ it('2. Hidden unless cchar is set.', function()
+ command('let &conceallevel=2')
screen:expect([[
// No Conceal |
|
@@ -264,8 +267,8 @@ describe('Screen', function()
]])
end)
- it("3. Hide all concealed text.", function()
- command("let &conceallevel=3")
+ it('3. Hide all concealed text.', function()
+ command('let &conceallevel=3')
screen:expect([[
// No Conceal |
|*3
@@ -276,11 +279,10 @@ describe('Screen', function()
end)
end) -- conceallevel
-
- describe("cursor movement", function()
+ describe('cursor movement', function()
before_each(function()
- command("syn keyword concealy barf conceal cchar=b")
- command("set cole=2")
+ command('syn keyword concealy barf conceal cchar=b')
+ command('set cole=2')
feed('5Ofoo barf bar barf eggs<esc>')
screen:expect([[
foo {1:b} bar {1:b} eggs |*4
@@ -289,12 +291,11 @@ describe('Screen', function()
{0:~ }|*3
|
]])
-
end)
it('between windows', function()
feed('k')
- command("split")
+ command('split')
screen:expect([[
foo {1:b} bar {1:b} eggs |
foo barf bar barf egg^s |
@@ -386,7 +387,6 @@ describe('Screen', function()
{0:~ }|*3
|
]])
-
end)
it('between modes cocu=n', function()
@@ -418,7 +418,6 @@ describe('Screen', function()
|
]])
-
feed('v')
screen:expect([[
^foo barf bar barf eggs |
@@ -648,27 +647,33 @@ describe('Screen', function()
feed('10Ofoo barf bar barf eggs<esc>')
feed(':3<cr>o a<Esc>ggV')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
foo {1:b} bar {1:b} eggs |*2
a |
foo {1:b} bar {1:b} eggs |*5
{4:-- VISUAL LINE --} |
- ]]}
+ ]],
+ }
feed(string.rep('j', 15))
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{6:foo }{1:b}{6: bar }{1:b}{6: eggs} |*8
^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
{4:-- VISUAL LINE --} |
- ]]}
+ ]],
+ }
feed(string.rep('k', 15))
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
foo {1:b} bar {1:b} eggs |*2
a |
foo {1:b} bar {1:b} eggs |*5
{4:-- VISUAL LINE --} |
- ]]}
+ ]],
+ }
end)
end)
@@ -681,33 +686,37 @@ describe('Screen', function()
bbb
ccc
]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
aaa |
bbb |
ccc |
^ |
{0:~ }|*5
|
- ]]}
+ ]],
+ }
-- XXX: hack to get notifications, and check only a single line is
-- updated. Could use next_msg() also.
local orig_handle_grid_line = screen._handle_grid_line
local grid_lines = {}
function screen._handle_grid_line(self, grid, row, col, items)
- table.insert(grid_lines, {row, col, items})
+ table.insert(grid_lines, { row, col, items })
orig_handle_grid_line(self, grid, row, col, items)
end
feed('k')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
aaa |
bbb |
^ccc |
|
{0:~ }|*5
|
- ]]}
- eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}, {3, 0, {{' ', 0, 53}}}}, grid_lines)
+ ]],
+ }
+ eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } }, { 3, 0, { { ' ', 0, 53 } } } }, grid_lines)
end)
it('K_EVENT should not cause extra redraws with concealcursor #13196', function()
@@ -720,35 +729,39 @@ describe('Screen', function()
bbb
ccc
]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
aaa |
bbb |
ccc |
^ |
{0:~ }|*5
|
- ]]}
+ ]],
+ }
-- XXX: hack to get notifications, and check only a single line is
-- updated. Could use next_msg() also.
local orig_handle_grid_line = screen._handle_grid_line
local grid_lines = {}
function screen._handle_grid_line(self, grid, row, col, items)
- table.insert(grid_lines, {row, col, items})
+ table.insert(grid_lines, { row, col, items })
orig_handle_grid_line(self, grid, row, col, items)
end
feed('k')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
aaa |
bbb |
^ccc |
|
{0:~ }|*5
|
- ]]}
- eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}}, grid_lines)
+ ]],
+ }
+ eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } } }, grid_lines)
grid_lines = {}
- poke_eventloop() -- causes K_EVENT key
+ poke_eventloop() -- causes K_EVENT key
screen:expect_unchanged()
eq({}, grid_lines) -- no redraw was done
end)
@@ -767,7 +780,8 @@ describe('Screen', function()
command('set nomodified')
command('so')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^3split |
let m matchadd('Conceal', '') |
setl conceallevel2 concealcursornc |
@@ -778,16 +792,18 @@ describe('Screen', function()
normal gg |
{3:Xcolesearch }|
|
- ]]}
+ ]],
+ }
-- Jump to something that is beyond the bottom of the window,
-- so there's a scroll down.
- feed("/expr<CR>")
+ feed('/expr<CR>')
-- Are the concealed parts of the current line really hidden?
-- Is the window's cursor column properly updated for hidden
-- parts of the current line?
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
setl conceallevel2 concealcursornc |
normal gg |
"{5:^expr} |
@@ -798,7 +814,8 @@ describe('Screen', function()
normal gg |
{3:Xcolesearch }|
/expr |
- ]]}
+ ]],
+ }
end)
-- oldtest: Test_cursor_column_in_concealed_line_after_leftcol_change()
@@ -816,12 +833,14 @@ describe('Screen', function()
-- Are the concealed parts of the current line really hidden?
-- Is the window's cursor column properly updated for conceal?
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^c |
|
{0:~ }|*7
|
- ]]}
+ ]],
+ }
end)
end)
end)
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
index 8f40e1db61..f270d298cb 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -12,7 +12,7 @@ describe('ui/ext_tabline', function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach({rgb=true, ext_tabline=true})
+ screen:attach({ rgb = true, ext_tabline = true })
function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
event_curtab = curtab
event_tabs = tabs
@@ -22,65 +22,77 @@ describe('ui/ext_tabline', function()
end)
it('publishes UI events', function()
- command("tabedit another-tab")
+ command('tabedit another-tab')
local expected_tabs = {
- {tab = { id = 1 }, name = '[No Name]'},
- {tab = { id = 2 }, name = 'another-tab'},
+ { tab = { id = 1 }, name = '[No Name]' },
+ { tab = { id = 2 }, name = 'another-tab' },
}
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
~ |*3
|
- ]], condition=function()
- eq({ id = 2 }, event_curtab)
- eq(expected_tabs, event_tabs)
- end}
+ ]],
+ condition = function()
+ eq({ id = 2 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end,
+ }
- command("tabNext")
- screen:expect{grid=[[
+ command('tabNext')
+ screen:expect {
+ grid = [[
^ |
~ |*3
|
- ]], condition=function()
- eq({ id = 1 }, event_curtab)
- eq(expected_tabs, event_tabs)
- end}
+ ]],
+ condition = function()
+ eq({ id = 1 }, event_curtab)
+ eq(expected_tabs, event_tabs)
+ end,
+ }
end)
it('buffer UI events', function()
- local expected_buffers_initial= {
- {buffer = { id = 1 }, name = '[No Name]'},
+ local expected_buffers_initial = {
+ { buffer = { id = 1 }, name = '[No Name]' },
}
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
~ |*3
|
- ]], condition=function()
- eq({ id = 1}, event_curbuf)
- eq(expected_buffers_initial, event_buffers)
- end}
+ ]],
+ condition = function()
+ eq({ id = 1 }, event_curbuf)
+ eq(expected_buffers_initial, event_buffers)
+ end,
+ }
- command("badd another-buffer")
- command("bnext")
+ command('badd another-buffer')
+ command('bnext')
local expected_buffers = {
- {buffer = { id = 1 }, name = '[No Name]'},
- {buffer = { id = 2 }, name = 'another-buffer'},
+ { buffer = { id = 1 }, name = '[No Name]' },
+ { buffer = { id = 2 }, name = 'another-buffer' },
}
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
~ |*3
|
- ]], condition=function()
- eq({ id = 2 }, event_curbuf)
- eq(expected_buffers, event_buffers)
- end}
+ ]],
+ condition = function()
+ eq({ id = 2 }, event_curbuf)
+ eq(expected_buffers, event_buffers)
+ end,
+ }
end)
end)
-describe("tabline", function()
+describe('tabline', function()
local screen
before_each(function()
@@ -88,27 +100,31 @@ describe("tabline", function()
screen = Screen.new(42, 5)
screen:attach()
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
- [1] = {reverse = true}; -- TabLineFill
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { reverse = true }, -- TabLineFill
})
end)
it('redraws when tabline option is set', function()
command('set tabline=asdf')
command('set showtabline=2')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:asdf }|
^ |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
command('set tabline=jkl')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:jkl }|
^ |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
end)
it('click definitions do not leak memory #21765', function()
@@ -123,39 +139,49 @@ describe("tabline", function()
insert('tab2')
command('tabprev')
meths.set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {})
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^1 |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
assert_alive()
meths.input_mouse('left', 'press', '', 0, 0, 1)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^2 |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
meths.input_mouse('left', 'press', '', 0, 0, 0)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^1 |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
meths.input_mouse('left', 'press', '', 0, 0, 39)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^2 |
{0:~ }|*2
|
- ]]}
+ ]],
+ }
meths.input_mouse('left', 'press', '', 0, 0, 40)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tab^1 |
{0:~ }|*3
|
- ]]}
+ ]],
+ }
end)
end)
diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua
index 66c0ff5c9c..6f86b61431 100644
--- a/test/functional/ui/title_spec.lua
+++ b/test/functional/ui/title_spec.lua
@@ -43,13 +43,13 @@ describe('title', function()
local buf2
before_each(function()
- command('edit '..file1)
+ command('edit ' .. file1)
buf2 = funcs.bufadd(file2)
command('set title')
end)
it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function()
- command([[inoremap <F2> <C-R>=setbufvar(]]..buf2..[[, '&autoindent', 1) ?? ''<CR>]])
+ command([[inoremap <F2> <C-R>=setbufvar(]] .. buf2 .. [[, '&autoindent', 1) ?? ''<CR>]])
feed('i<F2><Esc>')
command('redraw!')
screen:expect(function()
@@ -66,11 +66,14 @@ describe('title', function()
end)
it('a Lua callback calling nvim_set_option_value in a hidden buffer', function()
- exec_lua(string.format([[
+ exec_lua(string.format(
+ [[
vim.schedule(function()
vim.api.nvim_set_option_value('autoindent', true, { buf = %d })
end)
- ]], buf2))
+ ]],
+ buf2
+ ))
command('redraw!')
screen:expect(function()
eq(expected, screen.title)
@@ -78,11 +81,14 @@ describe('title', function()
end)
it('a Lua callback calling nvim_buf_call in a hidden buffer', function()
- exec_lua(string.format([[
+ exec_lua(string.format(
+ [[
vim.schedule(function()
vim.api.nvim_buf_call(%d, function() end)
end)
- ]], buf2))
+ ]],
+ buf2
+ ))
command('redraw!')
screen:expect(function()
eq(expected, screen.title)
@@ -102,11 +108,15 @@ describe('title', function()
it('setting the buffer of another window using Lua callback', function()
local oldwin = curwin().id
command('split')
- exec_lua(string.format([[
+ exec_lua(string.format(
+ [[
vim.schedule(function()
vim.api.nvim_win_set_buf(%d, %d)
end)
- ]], oldwin, buf2))
+ ]],
+ oldwin,
+ buf2
+ ))
command('redraw!')
screen:expect(function()
eq(expected, screen.title)
@@ -115,7 +125,11 @@ describe('title', function()
it('creating a floating window using RPC', function()
meths.open_win(buf2, false, {
- relative = 'editor', width = 5, height = 5, row = 0, col = 0,
+ relative = 'editor',
+ width = 5,
+ height = 5,
+ row = 0,
+ col = 0,
})
command('redraw!')
screen:expect(function()
@@ -124,11 +138,14 @@ describe('title', function()
end)
it('creating a floating window using Lua callback', function()
- exec_lua(string.format([[
+ exec_lua(string.format(
+ [[
vim.api.nvim_open_win(%d, false, {
relative = 'editor', width = 5, height = 5, row = 0, col = 0,
})
- ]], buf2))
+ ]],
+ buf2
+ ))
command('redraw!')
screen:expect(function()
eq(expected, screen.title)
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index 79903fd42f..749ddf72f8 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -20,71 +20,85 @@ describe("'wildmenu'", function()
-- oldtest: Test_wildmenu_screendump()
it('works', function()
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
- [1] = {foreground = Screen.colors.Black, background = Screen.colors.Yellow}; -- WildMenu
- [2] = {bold = true, reverse = true}; -- StatusLine
+ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
+ [1] = { foreground = Screen.colors.Black, background = Screen.colors.Yellow }, -- WildMenu
+ [2] = { bold = true, reverse = true }, -- StatusLine
})
-- Test simple wildmenu
feed(':sign <Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
{1:define}{2: jump list > }|
:sign define^ |
- ]]}
+ ]],
+ }
feed('<Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
{2:define }{1:jump}{2: list > }|
:sign jump^ |
- ]]}
+ ]],
+ }
feed('<Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
{2:define jump }{1:list}{2: > }|
:sign list^ |
- ]]}
+ ]],
+ }
-- Looped back to the original value
feed('<Tab><Tab><Tab><Tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
{2:define jump list > }|
:sign ^ |
- ]]}
+ ]],
+ }
-- Test that the wild menu is cleared properly
feed('<Space>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*3
:sign ^ |
- ]]}
+ ]],
+ }
-- Test that a different wildchar still works
feed('<Esc>')
command('set wildchar=<Esc>')
feed(':sign <Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{0:~ }|*2
{1:define}{2: jump list > }|
:sign define^ |
- ]]}
+ ]],
+ }
-- Double-<Esc> is a hard-coded method to escape while wildchar=<Esc>. Make
-- sure clean up is properly done in edge case like this.
feed('<Esc>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
{0:~ }|*3
|
- ]]}
+ ]],
+ }
end)
it('C-E to cancel wildmenu completion restore original input', function()
@@ -174,41 +188,45 @@ describe("'wildmenu'", function()
command('set wildmenu wildmode=full')
command('set scrollback=4')
feed((':terminal "%s" REP 5000 !terminal_output!<cr>'):format(testprg('shell-test')))
- feed('G') -- Follow :terminal output.
- feed([[:sign <Tab>]]) -- Invoke wildmenu.
+ feed('G') -- Follow :terminal output.
+ feed([[:sign <Tab>]]) -- Invoke wildmenu.
-- NB: in earlier versions terminal output was redrawn during cmdline mode.
-- For now just assert that the screen remains unchanged.
- screen:expect{any='define jump list > |\n:sign define^ |'}
+ screen:expect { any = 'define jump list > |\n:sign define^ |' }
screen:expect_unchanged()
-- cmdline CTRL-D display should also be preserved.
feed([[<C-U>]])
- feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D.
- screen:expect{grid=[[
+ feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D.
+ screen:expect {
+ grid = [[
:sign |
define place |
jump undefine |
list unplace |
:sign ^ |
- ]]}
+ ]],
+ }
screen:expect_unchanged()
-- Exiting cmdline should show the buffer.
feed([[<C-\><C-N>]])
- screen:expect{any=[[!terminal_output!]]}
+ screen:expect { any = [[!terminal_output!]] }
end)
it('ignores :redrawstatus called from a timer #7108', function()
command('set wildmenu wildmode=full')
command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]])
feed([[<C-\><C-N>]])
- feed([[:sign <Tab>]]) -- Invoke wildmenu.
- screen:expect{grid=[[
+ feed([[:sign <Tab>]]) -- Invoke wildmenu.
+ screen:expect {
+ grid = [[
|
~ |*2
define jump list > |
:sign define^ |
- ]]}
+ ]],
+ }
screen:expect_unchanged()
end)
@@ -218,7 +236,7 @@ describe("'wildmenu'", function()
screen.timeout = 1000
if not is_os('win') then
- command('set shell=sh') -- Need a predictable "$" prompt.
+ command('set shell=sh') -- Need a predictable "$" prompt.
command('let $PS1 = "$"')
end
command('set laststatus=0')
@@ -235,10 +253,10 @@ describe("'wildmenu'", function()
end)
feed([[<C-\><C-N>]])
- feed([[:<Tab>]]) -- Invoke wildmenu.
+ feed([[:<Tab>]]) -- Invoke wildmenu.
-- Check only the last 2 lines, because the shell output is
-- system-dependent.
- screen:expect{any='! # & < = > @ > |\n:!^'}
+ screen:expect { any = '! # & < = > @ > |\n:!^' }
screen:expect_unchanged()
end)
@@ -389,9 +407,9 @@ describe("'wildmenu'", function()
it('works with c_CTRL_Z standard mapping', function()
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue1};
- [2] = {foreground = Screen.colors.Grey0, background = Screen.colors.Yellow};
- [3] = {bold = true, reverse = true};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow },
+ [3] = { bold = true, reverse = true },
}
-- Wildcharm? where we are going we aint't no need no wildcharm.
@@ -404,12 +422,14 @@ describe("'wildmenu'", function()
command 'cnoremap <f2> <c-z>'
feed(':syntax <f2>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{2:case}{3: clear cluster > }|
:syntax case^ |
- ]]}
+ ]],
+ }
feed '<esc>'
command 'set wildmode=longest:full,full'
@@ -417,26 +437,32 @@ describe("'wildmenu'", function()
command [[cnoremap <expr> <tab> luaeval("not rawset(_G, 'coin', not coin).coin") ? "<c-z>" : "c"]]
feed ':syntax <tab>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
:syntax c^ |
- ]]}
+ ]],
+ }
feed '<tab>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*2
{3:case clear cluster > }|
:syntax c^ |
- ]]}
+ ]],
+ }
feed '<tab>'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
{1:~ }|*3
:syntax cc^ |
- ]]}
+ ]],
+ }
end)
end)
@@ -446,9 +472,9 @@ describe('command line completion', function()
clear()
screen = Screen.new(40, 5)
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey0, background = Screen.colors.Yellow},
- [3] = {bold = true, reverse = true},
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow },
+ [3] = { bold = true, reverse = true },
})
screen:attach()
end)
@@ -458,7 +484,7 @@ describe('command line completion', function()
it('lists directories with empty PATH', function()
local tmp = funcs.tempname()
- command('e '.. tmp)
+ command('e ' .. tmp)
command('cd %:h')
command("call mkdir('Xtest-functional-viml-compl-dir')")
command('let $PATH=""')
@@ -483,10 +509,10 @@ describe('command line completion', function()
end)
it('completes (multibyte) env var names #9655', function()
- clear({env={
- ['XTEST_1AaあB']='foo',
- ['XTEST_2']='bar',
- }})
+ clear({ env = {
+ ['XTEST_1AaあB'] = 'foo',
+ ['XTEST_2'] = 'bar',
+ } })
screen:attach()
command('set wildmenu wildmode=full')
feed(':!echo $XTEST_<tab>')
@@ -551,54 +577,72 @@ describe('ui/ext_wildmenu', function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach({rgb=true, ext_wildmenu=true})
+ screen:attach({ rgb = true, ext_wildmenu = true })
end)
it('works with :sign <tab>', function()
local expected = {
- 'define',
- 'jump',
- 'list',
- 'place',
- 'undefine',
- 'unplace',
+ 'define',
+ 'jump',
+ 'list',
+ 'place',
+ 'undefine',
+ 'unplace',
}
command('set wildmode=full')
command('set wildmenu')
feed(':sign <tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
~ |*3
:sign define^ |
- ]], wildmenu_items=expected, wildmenu_pos=0}
+ ]],
+ wildmenu_items = expected,
+ wildmenu_pos = 0,
+ }
feed('<tab>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
~ |*3
:sign jump^ |
- ]], wildmenu_items=expected, wildmenu_pos=1}
+ ]],
+ wildmenu_items = expected,
+ wildmenu_pos = 1,
+ }
feed('<left><left>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
~ |*3
:sign ^ |
- ]], wildmenu_items=expected, wildmenu_pos=-1}
+ ]],
+ wildmenu_items = expected,
+ wildmenu_pos = -1,
+ }
feed('<right>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
~ |*3
:sign define^ |
- ]], wildmenu_items=expected, wildmenu_pos=0}
+ ]],
+ wildmenu_items = expected,
+ wildmenu_pos = 0,
+ }
feed('a')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
~ |*3
:sign definea^ |
- ]]}
+ ]],
+ }
end)
end)
diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua
index 65fd5d31f5..502c61a31b 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -19,17 +19,26 @@ describe('winbar', function()
screen = Screen.new(60, 13)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true},
- [2] = {reverse = true},
- [3] = {bold = true, foreground = Screen.colors.Blue},
- [4] = {bold = true, reverse = true},
- [5] = {bold = true, foreground = Screen.colors.Red},
- [6] = {foreground = Screen.colors.Blue},
- [7] = {background = Screen.colors.LightGrey},
- [8] = {background = Screen.colors.LightMagenta},
- [9] = {bold = true, foreground = Screen.colors.Blue, background = Screen.colors.LightMagenta},
- [10] = {background = Screen.colors.LightGrey, underline = true},
- [11] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
+ [1] = { bold = true },
+ [2] = { reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.Blue },
+ [4] = { bold = true, reverse = true },
+ [5] = { bold = true, foreground = Screen.colors.Red },
+ [6] = { foreground = Screen.colors.Blue },
+ [7] = { background = Screen.colors.LightGrey },
+ [8] = { background = Screen.colors.LightMagenta },
+ [9] = {
+ bold = true,
+ foreground = Screen.colors.Blue,
+ background = Screen.colors.LightMagenta,
+ },
+ [10] = { background = Screen.colors.LightGrey, underline = true },
+ [11] = {
+ background = Screen.colors.LightGrey,
+ underline = true,
+ bold = true,
+ foreground = Screen.colors.Magenta,
+ },
})
meths.set_option_value('winbar', 'Set Up The Bars', {})
end)
@@ -48,7 +57,7 @@ describe('winbar', function()
eq(1, win_info.winbar)
end)
- it('works with custom \'fillchars\' value', function()
+ it("works with custom 'fillchars' value", function()
command('set fillchars=wbr:+')
screen:expect([[
{1:Set Up The Bars+++++++++++++++++++++++++++++++++++++++++++++}|
@@ -124,7 +133,7 @@ describe('winbar', function()
]])
end)
- it('works when switching value of \'winbar\'', function()
+ it("works when switching value of 'winbar'", function()
command('belowright vsplit | split | split | set winbar=')
screen:expect([[
│^ |
@@ -177,29 +186,35 @@ describe('winbar', function()
just some
random text]]
meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 2,11 }|
just some |
random tex^t |
{3:~ }|*9
|
- ]]}
+ ]],
+ }
feed 'b'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 2,8 }|
just some |
random ^text |
{3:~ }|*9
|
- ]]}
+ ]],
+ }
feed 'k'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 1,8 }|
just so^me |
random text |
{3:~ }|*9
|
- ]]}
+ ]],
+ }
end)
it('works with laststatus=3', function()
@@ -264,7 +279,7 @@ describe('winbar', function()
{3:~ }|*3
|
]])
- eq({5, 1}, meths.win_get_cursor(0))
+ eq({ 5, 1 }, meths.win_get_cursor(0))
meths.input_mouse('left', 'drag', '', 0, 6, 2)
screen:expect([[
@@ -280,7 +295,7 @@ describe('winbar', function()
{3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({6, 2}, meths.win_get_cursor(0))
+ eq({ 6, 2 }, meths.win_get_cursor(0))
meths.input_mouse('left', 'drag', '', 0, 1, 2)
screen:expect([[
@@ -296,11 +311,11 @@ describe('winbar', function()
{3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({1, 2}, meths.win_get_cursor(0))
+ eq({ 1, 2 }, meths.win_get_cursor(0))
meths.input_mouse('left', 'drag', '', 0, 0, 2)
screen:expect_unchanged()
- eq({1, 2}, meths.win_get_cursor(0))
+ eq({ 1, 2 }, meths.win_get_cursor(0))
end)
it('dragging statusline with mouse works correctly', function()
@@ -398,19 +413,22 @@ describe('winbar', function()
end)
it('requires window-local value for floating windows', function()
- local win = meths.open_win(0, false, { relative = 'editor', row = 2, col = 10, height = 7,
- width = 30 })
+ local win =
+ meths.open_win(0, false, { relative = 'editor', row = 2, col = 10, height = 7, width = 30 })
meths.set_option_value('winbar', 'bar', {})
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:bar }|
^ |
{3:~ }{8: }{3: }|
{3:~ }{9:~ }{3: }|*6
{3:~ }|*3
|
- ]]}
+ ]],
+ }
meths.set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id })
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:bar }|
^ |
{3:~ }{1:floaty bar }{3: }|
@@ -418,7 +436,8 @@ describe('winbar', function()
{3:~ }{9:~ }{3: }|*5
{3:~ }|*3
|
- ]]}
+ ]],
+ }
end)
it('works correctly when moving a split', function()
@@ -505,10 +524,10 @@ describe('local winbar with tabs', function()
screen = Screen.new(60, 10)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true},
- [2] = {reverse = true},
- [3] = {bold = true, foreground = Screen.colors.Blue},
- [4] = {underline = true, background = Screen.colors.LightGray}
+ [1] = { bold = true },
+ [2] = { reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.Blue },
+ [4] = { underline = true, background = Screen.colors.LightGray },
})
meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
end)
@@ -522,13 +541,15 @@ describe('local winbar with tabs', function()
|
]])
command('tabnext')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: [No Name] }{4: [No Name] }{2: }{4:X}|
{1:foo }|
^ |
{3:~ }|*6
|
- ]]}
+ ]],
+ }
end)
it('can edit new empty buffer #19458', function()
@@ -536,26 +557,31 @@ describe('local winbar with tabs', function()
some
goofy
text]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:foo }|
some |
goofy |
tex^t |
{3:~ }|*5
|
- ]]}
+ ]],
+ }
-- this used to throw an E315 ml_get error
command 'tabedit'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{4: + [No Name] }{1: [No Name] }{2: }{4:X}|
^ |
{3:~ }|*7
|
- ]]}
+ ]],
+ }
command 'tabprev'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: + [No Name] }{4: [No Name] }{2: }{4:X}|
{1:foo }|
some |
@@ -563,22 +589,28 @@ describe('local winbar with tabs', function()
tex^t |
{3:~ }|*4
|
- ]]}
+ ]],
+ }
end)
end)
it('winbar works properly when redrawing is postponed #23534', function()
- clear({args = {
- '-c', 'set laststatus=2 lazyredraw',
- '-c', 'setlocal statusline=(statusline) winbar=(winbar)',
- '-c', 'call nvim_input(":<Esc>")',
- }})
+ clear({
+ args = {
+ '-c',
+ 'set laststatus=2 lazyredraw',
+ '-c',
+ 'setlocal statusline=(statusline) winbar=(winbar)',
+ '-c',
+ 'call nvim_input(":<Esc>")',
+ },
+ })
local screen = Screen.new(60, 6)
screen:attach()
screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Blue, bold = true},
- [1] = {bold = true},
- [2] = {bold = true, reverse = true},
+ [0] = { foreground = Screen.colors.Blue, bold = true },
+ [1] = { bold = true },
+ [2] = { bold = true, reverse = true },
})
screen:expect([[
{1:(winbar) }|