aboutsummaryrefslogtreecommitdiff
path: root/test/functional/editor
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/editor')
-rw-r--r--test/functional/editor/completion_spec.lua718
-rw-r--r--test/functional/editor/defaults_spec.lua100
-rw-r--r--test/functional/editor/jump_spec.lua46
-rw-r--r--test/functional/editor/macro_spec.lua17
-rw-r--r--test/functional/editor/meta_key_spec.lua15
-rw-r--r--test/functional/editor/mode_cmdline_spec.lua12
-rw-r--r--test/functional/editor/mode_insert_spec.lua113
-rw-r--r--test/functional/editor/tabpage_spec.lua23
8 files changed, 698 insertions, 346 deletions
diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua
index 62bb7e19f3..d543de4acd 100644
--- a/test/functional/editor/completion_spec.lua
+++ b/test/functional/editor/completion_spec.lua
@@ -4,7 +4,7 @@ local Screen = require('test.functional.ui.screen')
local assert_alive = n.assert_alive
local clear, feed = n.clear, n.feed
-local eval, eq, neq = n.eval, t.eq, t.neq
+local eval, eq, neq, ok = n.eval, t.eq, t.neq, t.ok
local feed_command, source, expect = n.feed_command, n.source, n.expect
local fn = n.fn
local command = n.command
@@ -18,19 +18,10 @@ describe('completion', function()
clear()
screen = Screen.new(60, 8)
screen:attach()
- screen:set_default_attr_ids({
- [0] = { bold = true, foreground = Screen.colors.Blue },
- [1] = { background = Screen.colors.LightMagenta },
- [2] = { background = Screen.colors.Grey },
- [3] = { bold = true },
- [4] = { bold = true, foreground = Screen.colors.SeaGreen },
- [5] = { foreground = Screen.colors.Red },
- [6] = { background = Screen.colors.Black },
- [7] = { foreground = Screen.colors.White, background = Screen.colors.Red },
- [8] = { reverse = true },
- [9] = { bold = true, reverse = true },
- [10] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow },
- })
+ screen:add_extra_attr_ids {
+ [100] = { foreground = Screen.colors.Gray0, background = Screen.colors.Yellow },
+ [101] = { background = Screen.colors.Gray0 },
+ }
end)
describe('v:completed_item', function()
@@ -42,15 +33,15 @@ describe('completion', function()
screen:expect([[
foo |
foo^ |
- {0:~ }|*5
- {3:-- Keyword Local completion (^N^P) The only match} |
+ {1:~ }|*5
+ {5:-- Keyword Local completion (^N^P) The only match} |
]])
feed('<C-e>')
screen:expect([[
foo |
^ |
- {0:~ }|*5
- {3:-- INSERT --} |
+ {1:~ }|*5
+ {5:-- INSERT --} |
]])
feed('<ESC>')
eq({}, eval('v:completed_item'))
@@ -104,10 +95,10 @@ describe('completion', function()
eq('foo', eval('getline(1)'))
screen:expect([[
foo^ |
- {2:bar foobaz baz }{0: }|
- {1:abbr kind menu }{0: }|
- {0:~ }|*4
- {3:-- Omni completion (^O^N^P) }{4:match 1 of 2} |
+ {12:bar foobaz baz }{1: }|
+ {4:abbr kind menu }{1: }|
+ {1:~ }|*4
+ {5:-- Omni completion (^O^N^P) }{6:match 1 of 2} |
]])
eq({
word = 'foo',
@@ -136,24 +127,24 @@ describe('completion', function()
screen:expect([[
foo |
^ |
- {0:~ }|*5
- {3:-- INSERT --} |
+ {1:~ }|*5
+ {5:-- INSERT --} |
]])
feed('<C-x>')
-- the ^X prompt, only test this once
screen:expect([[
foo |
^ |
- {0:~ }|*5
- {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
+ {1:~ }|*5
+ {5:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
]])
feed('<C-n>')
screen:expect([[
foo |
foo^ |
- {2:foo }{0: }|
- {0:~ }|*4
- {3:-- Keyword Local completion (^N^P) The only match} |
+ {12:foo }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword Local completion (^N^P) The only match} |
]])
feed('bar<ESC>')
eq('foobar', eval('getline(2)'))
@@ -162,9 +153,9 @@ describe('completion', function()
foo |
foobar |
foo^ |
- {2:foo }{0: }|
- {0:~ }|*3
- {3:-- INSERT --} |
+ {12:foo }{1: }|
+ {1:~ }|*3
+ {5:-- INSERT --} |
]])
eq('foo', eval('getline(3)'))
end)
@@ -174,16 +165,16 @@ describe('completion', function()
screen:expect([[
foo |
^ |
- {2:foo }{0: }|
- {0:~ }|*4
- {3:-- Keyword Local completion (^N^P) The only match} |
+ {12:foo }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword Local completion (^N^P) The only match} |
]])
feed('<C-y>')
screen:expect([[
foo |
foo^ |
- {0:~ }|*5
- {3:-- INSERT --} |
+ {1:~ }|*5
+ {5:-- INSERT --} |
]])
feed('<ESC>')
eq('foo', eval('getline(2)'))
@@ -191,9 +182,9 @@ describe('completion', function()
screen:expect([[
foo |*2
^ |
- {2:foo }{0: }|
- {0:~ }|*3
- {3:-- INSERT --} |
+ {12:foo }{1: }|
+ {1:~ }|*3
+ {5:-- INSERT --} |
]])
feed('<C-y><ESC>')
eq('foo', eval('getline(3)'))
@@ -204,16 +195,16 @@ describe('completion', function()
screen:expect([[
foo |
^ |
- {1:foo }{0: }|
- {0:~ }|*4
- {3:-- Keyword Local completion (^N^P) }{5:Back at original} |
+ {4:foo }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword Local completion (^N^P) }{19:Back at original} |
]])
feed('b')
screen:expect([[
foo |
b^ |
- {0:~ }|*5
- {3:-- Keyword Local completion (^N^P) }{5:Back at original} |
+ {1:~ }|*5
+ {5:-- Keyword Local completion (^N^P) }{19:Back at original} |
]])
feed('ar<ESC>')
eq('bar', eval('getline(2)'))
@@ -222,9 +213,9 @@ describe('completion', function()
foo |
bar |
^ |
- {1:foo }{0: }|
- {0:~ }|*3
- {3:-- INSERT --} |
+ {4:foo }{1: }|
+ {1:~ }|*3
+ {5:-- INSERT --} |
]])
feed('bar<ESC>')
eq('bar', eval('getline(3)'))
@@ -235,15 +226,15 @@ describe('completion', function()
screen:expect([[
foo |
^ |
- {1:foo }{0: }|
- {0:~ }|*4
- {3:-- Keyword Local completion (^N^P) }{5:Back at original} |
+ {4:foo }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword Local completion (^N^P) }{19:Back at original} |
]])
feed('<ESC>')
screen:expect([[
foo |
^ |
- {0:~ }|*5
+ {1:~ }|*5
|
]])
eq('', eval('getline(2)'))
@@ -252,16 +243,16 @@ describe('completion', function()
foo |
|
^ |
- {1:foo }{0: }|
- {0:~ }|*3
- {3:-- INSERT --} |
+ {4:foo }{1: }|
+ {1:~ }|*3
+ {5:-- INSERT --} |
]])
feed('<ESC>')
screen:expect([[
foo |
|
^ |
- {0:~ }|*4
+ {1:~ }|*4
|
]])
eq('', eval('getline(3)'))
@@ -336,7 +327,7 @@ describe('completion', function()
end
end)
- describe('refresh:always', function()
+ describe('with refresh:always and noselect', function()
before_each(function()
source([[
function! TestCompletion(findstart, base) abort
@@ -367,44 +358,44 @@ describe('completion', function()
feed('i<C-x><C-u>')
screen:expect([[
^ |
- {1:January }{6: }{0: }|
- {1:February }{6: }{0: }|
- {1:March }{6: }{0: }|
- {1:April }{2: }{0: }|
- {1:May }{2: }{0: }|
- {1:June }{2: }{0: }|
- {3:-- User defined completion (^U^N^P) }{5:Back at original} |
+ {4:January }{101: }{1: }|
+ {4:February }{101: }{1: }|
+ {4:March }{101: }{1: }|
+ {4:April }{12: }{1: }|
+ {4:May }{12: }{1: }|
+ {4:June }{12: }{1: }|
+ {5:-- User defined completion (^U^N^P) }{19:Back at original} |
]])
feed('u')
screen:expect([[
u^ |
- {1:January }{0: }|
- {1:February }{0: }|
- {1:June }{0: }|
- {1:July }{0: }|
- {1:August }{0: }|
- {0:~ }|
- {3:-- User defined completion (^U^N^P) }{5:Back at original} |
+ {4:January }{1: }|
+ {4:February }{1: }|
+ {4:June }{1: }|
+ {4:July }{1: }|
+ {4:August }{1: }|
+ {1:~ }|
+ {5:-- User defined completion (^U^N^P) }{19:Back at original} |
]])
feed('g')
screen:expect([[
ug^ |
- {1:August }{0: }|
- {0:~ }|*5
- {3:-- User defined completion (^U^N^P) }{5:Back at original} |
+ {4:August }{1: }|
+ {1:~ }|*5
+ {5:-- User defined completion (^U^N^P) }{19:Back at original} |
]])
feed('<Down>')
screen:expect([[
ug^ |
- {2:August }{0: }|
- {0:~ }|*5
- {3:-- User defined completion (^U^N^P) The only match} |
+ {12:August }{1: }|
+ {1:~ }|*5
+ {5:-- User defined completion (^U^N^P) The only match} |
]])
feed('<C-y>')
screen:expect([[
August^ |
- {0:~ }|*6
- {3:-- INSERT --} |
+ {1:~ }|*6
+ {5:-- INSERT --} |
]])
expect('August')
end)
@@ -414,45 +405,45 @@ describe('completion', function()
screen:expect([[
|
Ja^ |
- {1:January }{0: }|
- {0:~ }|*4
- {3:-- User defined completion (^U^N^P) }{5:Back at original} |
+ {4:January }{1: }|
+ {1:~ }|*4
+ {5:-- User defined completion (^U^N^P) }{19:Back at original} |
]])
feed('<BS>')
screen:expect([[
|
J^ |
- {1:January }{0: }|
- {1:June }{0: }|
- {1:July }{0: }|
- {0:~ }|*2
- {3:-- User defined completion (^U^N^P) }{5:Back at original} |
+ {4:January }{1: }|
+ {4:June }{1: }|
+ {4:July }{1: }|
+ {1:~ }|*2
+ {5:-- User defined completion (^U^N^P) }{19:Back at original} |
]])
feed('<C-n>')
screen:expect([[
|
January^ |
- {2:January }{0: }|
- {1:June }{0: }|
- {1:July }{0: }|
- {0:~ }|*2
- {3:-- User defined completion (^U^N^P) }{4:match 1 of 3} |
+ {12:January }{1: }|
+ {4:June }{1: }|
+ {4:July }{1: }|
+ {1:~ }|*2
+ {5:-- User defined completion (^U^N^P) }{6:match 1 of 3} |
]])
feed('<C-n>')
screen:expect([[
|
June^ |
- {1:January }{0: }|
- {2:June }{0: }|
- {1:July }{0: }|
- {0:~ }|*2
- {3:-- User defined completion (^U^N^P) }{4:match 2 of 3} |
+ {4:January }{1: }|
+ {12:June }{1: }|
+ {4:July }{1: }|
+ {1:~ }|*2
+ {5:-- User defined completion (^U^N^P) }{6:match 2 of 3} |
]])
feed('<Esc>')
screen:expect([[
|
Jun^e |
- {0:~ }|*5
+ {1:~ }|*5
|
]])
feed('.')
@@ -460,7 +451,7 @@ describe('completion', function()
|
June |
Jun^e |
- {0:~ }|*4
+ {1:~ }|*4
|
]])
expect([[
@@ -468,6 +459,67 @@ describe('completion', function()
June
June]])
end)
+
+ it('Enter does not select original text', function()
+ feed('iJ<C-x><C-u>')
+ poke_eventloop()
+ feed('u')
+ poke_eventloop()
+ feed('<CR>')
+ expect([[
+ Ju
+ ]])
+ feed('J<C-x><C-u>')
+ poke_eventloop()
+ feed('<CR>')
+ expect([[
+ Ju
+ J
+ ]])
+ end)
+ end)
+
+ describe('with noselect but not refresh:always', function()
+ before_each(function()
+ source([[
+ function! TestCompletion(findstart, base) abort
+ if a:findstart
+ let line = getline('.')
+ let start = col('.') - 1
+ while start > 0 && line[start - 1] =~ '\a'
+ let start -= 1
+ endwhile
+ return start
+ else
+ let ret = []
+ for m in split("January February March April May June July August September October November December")
+ if m =~ a:base " match by regex
+ call add(ret, m)
+ endif
+ endfor
+ return {'words':ret}
+ endif
+ endfunction
+
+ set completeopt=menuone,noselect
+ set completefunc=TestCompletion
+ ]])
+ end)
+
+ it('Enter selects original text after adding leader', function()
+ feed('iJ<C-x><C-u>')
+ poke_eventloop()
+ feed('u')
+ poke_eventloop()
+ feed('<CR>')
+ expect('Ju')
+ feed('<Esc>')
+ poke_eventloop()
+ -- The behavior should be the same when completion has been interrupted,
+ -- which can happen interactively if the completion function is slow.
+ feed('SJ<C-x><C-u>u<CR>')
+ expect('Ju')
+ end)
end)
describe('with a lot of items', function()
@@ -485,46 +537,46 @@ describe('completion', function()
feed('i<C-r>=TestComplete()<CR>')
screen:expect([[
^ |
- {1:0 }{6: }{0: }|
- {1:1 }{2: }{0: }|
- {1:2 }{2: }{0: }|
- {1:3 }{2: }{0: }|
- {1:4 }{2: }{0: }|
- {1:5 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:0 }{101: }{1: }|
+ {4:1 }{12: }{1: }|
+ {4:2 }{12: }{1: }|
+ {4:3 }{12: }{1: }|
+ {4:4 }{12: }{1: }|
+ {4:5 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('7')
screen:expect([[
7^ |
- {1:7 }{6: }{0: }|
- {1:70 }{6: }{0: }|
- {1:71 }{6: }{0: }|
- {1:72 }{2: }{0: }|
- {1:73 }{2: }{0: }|
- {1:74 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:7 }{101: }{1: }|
+ {4:70 }{101: }{1: }|
+ {4:71 }{101: }{1: }|
+ {4:72 }{12: }{1: }|
+ {4:73 }{12: }{1: }|
+ {4:74 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<c-n>')
screen:expect([[
7^ |
- {2:7 }{6: }{0: }|
- {1:70 }{6: }{0: }|
- {1:71 }{6: }{0: }|
- {1:72 }{2: }{0: }|
- {1:73 }{2: }{0: }|
- {1:74 }{2: }{0: }|
- {3:-- INSERT --} |
+ {12:7 }{101: }{1: }|
+ {4:70 }{101: }{1: }|
+ {4:71 }{101: }{1: }|
+ {4:72 }{12: }{1: }|
+ {4:73 }{12: }{1: }|
+ {4:74 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<c-n>')
screen:expect([[
70^ |
- {1:7 }{6: }{0: }|
- {2:70 }{6: }{0: }|
- {1:71 }{6: }{0: }|
- {1:72 }{2: }{0: }|
- {1:73 }{2: }{0: }|
- {1:74 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:7 }{101: }{1: }|
+ {12:70 }{101: }{1: }|
+ {4:71 }{101: }{1: }|
+ {4:72 }{12: }{1: }|
+ {4:73 }{12: }{1: }|
+ {4:74 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
end)
@@ -532,107 +584,107 @@ describe('completion', function()
feed('i<C-r>=TestComplete()<CR>')
screen:expect([[
^ |
- {1:0 }{6: }{0: }|
- {1:1 }{2: }{0: }|
- {1:2 }{2: }{0: }|
- {1:3 }{2: }{0: }|
- {1:4 }{2: }{0: }|
- {1:5 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:0 }{101: }{1: }|
+ {4:1 }{12: }{1: }|
+ {4:2 }{12: }{1: }|
+ {4:3 }{12: }{1: }|
+ {4:4 }{12: }{1: }|
+ {4:5 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageDown>')
screen:expect([[
^ |
- {1:0 }{6: }{0: }|
- {1:1 }{2: }{0: }|
- {1:2 }{2: }{0: }|
- {2:3 }{0: }|
- {1:4 }{2: }{0: }|
- {1:5 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:0 }{101: }{1: }|
+ {4:1 }{12: }{1: }|
+ {4:2 }{12: }{1: }|
+ {12:3 }{1: }|
+ {4:4 }{12: }{1: }|
+ {4:5 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageDown>')
screen:expect([[
^ |
- {1:5 }{6: }{0: }|
- {1:6 }{2: }{0: }|
- {2:7 }{0: }|
- {1:8 }{2: }{0: }|
- {1:9 }{2: }{0: }|
- {1:10 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:5 }{101: }{1: }|
+ {4:6 }{12: }{1: }|
+ {12:7 }{1: }|
+ {4:8 }{12: }{1: }|
+ {4:9 }{12: }{1: }|
+ {4:10 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<Down>')
screen:expect([[
^ |
- {1:5 }{6: }{0: }|
- {1:6 }{2: }{0: }|
- {1:7 }{2: }{0: }|
- {2:8 }{0: }|
- {1:9 }{2: }{0: }|
- {1:10 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:5 }{101: }{1: }|
+ {4:6 }{12: }{1: }|
+ {4:7 }{12: }{1: }|
+ {12:8 }{1: }|
+ {4:9 }{12: }{1: }|
+ {4:10 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageUp>')
screen:expect([[
^ |
- {1:2 }{6: }{0: }|
- {1:3 }{2: }{0: }|
- {2:4 }{0: }|
- {1:5 }{2: }{0: }|
- {1:6 }{2: }{0: }|
- {1:7 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:2 }{101: }{1: }|
+ {4:3 }{12: }{1: }|
+ {12:4 }{1: }|
+ {4:5 }{12: }{1: }|
+ {4:6 }{12: }{1: }|
+ {4:7 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageUp>') -- stop on first item
screen:expect([[
^ |
- {2:0 }{6: }{0: }|
- {1:1 }{2: }{0: }|
- {1:2 }{2: }{0: }|
- {1:3 }{2: }{0: }|
- {1:4 }{2: }{0: }|
- {1:5 }{2: }{0: }|
- {3:-- INSERT --} |
+ {12:0 }{101: }{1: }|
+ {4:1 }{12: }{1: }|
+ {4:2 }{12: }{1: }|
+ {4:3 }{12: }{1: }|
+ {4:4 }{12: }{1: }|
+ {4:5 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageUp>') -- when on first item, unselect
screen:expect([[
^ |
- {1:0 }{6: }{0: }|
- {1:1 }{2: }{0: }|
- {1:2 }{2: }{0: }|
- {1:3 }{2: }{0: }|
- {1:4 }{2: }{0: }|
- {1:5 }{2: }{0: }|
- {3:-- INSERT --} |
+ {4:0 }{101: }{1: }|
+ {4:1 }{12: }{1: }|
+ {4:2 }{12: }{1: }|
+ {4:3 }{12: }{1: }|
+ {4:4 }{12: }{1: }|
+ {4:5 }{12: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageUp>') -- when unselected, select last item
screen:expect([[
^ |
- {1:95 }{2: }{0: }|
- {1:96 }{2: }{0: }|
- {1:97 }{2: }{0: }|
- {1:98 }{2: }{0: }|
- {1:99 }{2: }{0: }|
- {2:100 }{6: }{0: }|
- {3:-- INSERT --} |
+ {4:95 }{12: }{1: }|
+ {4:96 }{12: }{1: }|
+ {4:97 }{12: }{1: }|
+ {4:98 }{12: }{1: }|
+ {4:99 }{12: }{1: }|
+ {12:100 }{101: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<PageUp>')
screen:expect([[
^ |
- {1:94 }{2: }{0: }|
- {1:95 }{2: }{0: }|
- {2:96 }{0: }|
- {1:97 }{2: }{0: }|
- {1:98 }{2: }{0: }|
- {1:99 }{6: }{0: }|
- {3:-- INSERT --} |
+ {4:94 }{12: }{1: }|
+ {4:95 }{12: }{1: }|
+ {12:96 }{1: }|
+ {4:97 }{12: }{1: }|
+ {4:98 }{12: }{1: }|
+ {4:99 }{101: }{1: }|
+ {5:-- INSERT --} |
]])
feed('<cr>')
screen:expect([[
96^ |
- {0:~ }|*6
- {3:-- INSERT --} |
+ {1:~ }|*6
+ {5:-- INSERT --} |
]])
end)
end)
@@ -668,9 +720,9 @@ describe('completion', function()
screen:expect([[
inc uninc indent unindent |
ind^ |
- {2:indent }{0: }|
- {0:~ }|*4
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
+ {12:indent }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} |
]])
-- Indents when the item is selected
@@ -678,8 +730,8 @@ describe('completion', function()
screen:expect([[
inc uninc indent unindent |
indent^ |
- {0:~ }|*5
- {3:-- INSERT --} |
+ {1:~ }|*5
+ {5:-- INSERT --} |
]])
-- Indents when completion is exited using ESC.
feed('<CR>in<C-N><BS>d<Esc>')
@@ -687,7 +739,7 @@ describe('completion', function()
inc uninc indent unindent |
indent |
in^d |
- {0:~ }|*4
+ {1:~ }|*4
|
]])
-- Works for unindenting too.
@@ -699,9 +751,9 @@ describe('completion', function()
indent |
ind |
unind^ |
- {0:~ }{2: unindent }{0: }|
- {0:~ }|*2
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
+ {1:~ }{12: unindent }{1: }|
+ {1:~ }|*2
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} |
]])
-- Works when going back and forth.
feed('<BS>c')
@@ -710,9 +762,9 @@ describe('completion', function()
indent |
ind |
uninc^ |
- {0:~ }{2: uninc }{0: }|
- {0:~ }|*2
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
+ {1:~ }{12: uninc }{1: }|
+ {1:~ }|*2
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} |
]])
feed('<BS>d')
screen:expect([[
@@ -720,9 +772,9 @@ describe('completion', function()
indent |
ind |
unind^ |
- {0:~ }{2: unindent }{0: }|
- {0:~ }|*2
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} |
+ {1:~ }{12: unindent }{1: }|
+ {1:~ }|*2
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} |
]])
feed('<C-N><C-N><C-Y><Esc>')
screen:expect([[
@@ -730,7 +782,7 @@ describe('completion', function()
indent |
ind |
uninden^t |
- {0:~ }|*3
+ {1:~ }|*3
|
]])
end)
@@ -741,15 +793,15 @@ describe('completion', function()
screen:expect([[
^foo |
bar |
- {0:~ }|*5
+ {1:~ }|*5
|
]])
feed('A<C-x><C-l>')
screen:expect([[
foo^ |
bar |
- {0:~ }|*5
- {3:-- Whole line completion (^L^N^P) }{7:Pattern not found} |
+ {1:~ }|*5
+ {5:-- Whole line completion (^L^N^P) }{9:Pattern not found} |
]])
eq(-1, eval('foldclosed(1)'))
end)
@@ -761,10 +813,10 @@ describe('completion', function()
screen:expect([[
foobar fooegg |
fooegg^ |
- {1:foobar }{0: }|
- {2:fooegg }{0: }|
- {0:~ }|*3
- {3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
+ {4:foobar }{1: }|
+ {12:fooegg }{1: }|
+ {1:~ }|*3
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 2} |
]])
assert_alive()
@@ -773,10 +825,10 @@ describe('completion', function()
grid = [[
foobar fooegg |
fooegg^ |
- {1:foobar }{0: }|
- {2:fooegg }{0: }|
- {0:~ }|*3
- {3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
+ {4:foobar }{1: }|
+ {12:fooegg }{1: }|
+ {1:~ }|*3
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 2} |
]],
unchanged = true,
}
@@ -786,10 +838,10 @@ describe('completion', function()
screen:expect([[
foobar fooegg |
foobar^ |
- {2:foobar }{0: }|
- {1:fooegg }{0: }|
- {0:~ }|*3
- {3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
+ {12:foobar }{1: }|
+ {4:fooegg }{1: }|
+ {1:~ }|*3
+ {5:-- Keyword completion (^N^P) }{6:match 2 of 2} |
]])
end)
@@ -800,7 +852,7 @@ describe('completion', function()
screen:expect {
grid = [[
|
- {0:~ }|*6
+ {1:~ }|*6
:lua CURRENT_TESTING_VAR^ |
]],
}
@@ -813,19 +865,73 @@ describe('completion', function()
screen:expect {
grid = [[
|
- {0:~ }|*5
- {10:CURRENT_TESTING_BAR}{9: CURRENT_TESTING_FOO }|
+ {1:~ }|*5
+ {100:CURRENT_TESTING_BAR}{3: CURRENT_TESTING_FOO }|
:lua CURRENT_TESTING_BAR^ |
]],
unchanged = true,
}
end)
+ it('prefix is not included in completion for cmdline mode', function()
+ feed(':lua math.a<Tab>')
+ screen:expect([[
+ |
+ {1:~ }|*5
+ {100:abs}{3: acos asin atan atan2 }|
+ :lua math.abs^ |
+ ]])
+ feed('<Tab>')
+ screen:expect([[
+ |
+ {1:~ }|*5
+ {3:abs }{100:acos}{3: asin atan atan2 }|
+ :lua math.acos^ |
+ ]])
+ end)
+
+ it('prefix is not included in completion for i_CTRL-X_CTRL-V #19623', function()
+ feed('ilua math.a<C-X><C-V>')
+ screen:expect([[
+ lua math.abs^ |
+ {1:~ }{12: abs }{1: }|
+ {1:~ }{4: acos }{1: }|
+ {1:~ }{4: asin }{1: }|
+ {1:~ }{4: atan }{1: }|
+ {1:~ }{4: atan2 }{1: }|
+ {1:~ }|
+ {5:-- Command-line completion (^V^N^P) }{6:match 1 of 5} |
+ ]])
+ feed('<C-V>')
+ screen:expect([[
+ lua math.acos^ |
+ {1:~ }{4: abs }{1: }|
+ {1:~ }{12: acos }{1: }|
+ {1:~ }{4: asin }{1: }|
+ {1:~ }{4: atan }{1: }|
+ {1:~ }{4: atan2 }{1: }|
+ {1:~ }|
+ {5:-- Command-line completion (^V^N^P) }{6:match 2 of 5} |
+ ]])
+ end)
+
+ it('works when cursor is in the middle of cmdline #29586', function()
+ feed(':lua math.a(); 1<Left><Left><Left><Left><Left><Tab>')
+ screen:expect([[
+ |
+ {1:~ }|*5
+ {100:abs}{3: acos asin atan atan2 }|
+ :lua math.abs^(); 1 |
+ ]])
+ end)
+
it('provides completion from `getcompletion()`', function()
eq({ 'vim' }, fn.getcompletion('vi', 'lua'))
eq({ 'api' }, fn.getcompletion('vim.ap', 'lua'))
eq({ 'tbl_filter' }, fn.getcompletion('vim.tbl_fil', 'lua'))
eq({ 'vim' }, fn.getcompletion('print(vi', 'lua'))
+ eq({ 'abs', 'acos', 'asin', 'atan', 'atan2' }, fn.getcompletion('math.a', 'lua'))
+ eq({ 'abs', 'acos', 'asin', 'atan', 'atan2' }, fn.getcompletion('lua math.a', 'cmdline'))
-- fuzzy completion is not supported, so the result should be the same
command('set wildoptions+=fuzzy')
eq({ 'vim' }, fn.getcompletion('vi', 'lua'))
@@ -841,36 +947,42 @@ describe('completion', function()
eq('SpecialKey', fn.getcompletion('set winhighlight=NonText:', 'cmdline')[1])
end)
+ it('cmdline completion for -complete does not contain spaces', function()
+ for _, str in ipairs(fn.getcompletion('command -complete=', 'cmdline')) do
+ ok(not str:find(' '), 'string without spaces', str)
+ end
+ end)
+
describe('from the commandline window', function()
it('is cleared after CTRL-C', function()
feed('q:')
feed('ifoo faa fee f')
screen:expect([[
|
- {8:[No Name] }|
- {0::}foo faa fee f^ |
- {0:~ }|*3
- {9:[Command Line] }|
- {3:-- INSERT --} |
+ {2:[No Name] }|
+ {1::}foo faa fee f^ |
+ {1:~ }|*3
+ {3:[Command Line] }|
+ {5:-- INSERT --} |
]])
feed('<c-x><c-n>')
screen:expect([[
|
- {8:[No Name] }|
- {0::}foo faa fee foo^ |
- {0:~ }{2: foo }{0: }|
- {0:~ }{1: faa }{0: }|
- {0:~ }{1: fee }{0: }|
- {9:[Command Line] }|
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 3} |
+ {2:[No Name] }|
+ {1::}foo faa fee foo^ |
+ {1:~ }{12: foo }{1: }|
+ {1:~ }{4: faa }{1: }|
+ {1:~ }{4: fee }{1: }|
+ {3:[Command Line] }|
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 3} |
]])
feed('<c-c>')
screen:expect([[
|
- {8:[No Name] }|
- {0::}foo faa fee foo |
- {0:~ }|*3
- {9:[Command Line] }|
+ {2:[No Name] }|
+ {1::}foo faa fee foo |
+ {1:~ }|*3
+ {3:[Command Line] }|
:foo faa fee foo^ |
]])
end)
@@ -903,9 +1015,9 @@ describe('completion', function()
feed('i<C-r>=TestComplete()<CR>')
screen:expect([[
^ |
- {1:1 3 2 }{0: }|
- {0:~ }|*5
- {3:-- INSERT --} |
+ {4:1 3 2 }{1: }|
+ {1:~ }|*5
+ {5:-- INSERT --} |
]])
end)
end)
@@ -918,12 +1030,12 @@ describe('completion', function()
grid = [[
*backers.txt* Nvim |
Xnull^ |
- {2:Xnull }{6: } |
- {1:Xoxomoon }{6: } |
- {1:Xu }{6: } NVIM REFERENCE MANUAL |
- {1:Xpayn }{2: } |
- {1:Xinity }{2: } |
- {3:-- Keyword Local completion (^N^P) }{4:match 1 of 7} |
+ {12:Xnull }{101: } |
+ {4:Xoxomoon }{101: } |
+ {4:Xu }{101: } NVIM REFERENCE MANUAL |
+ {4:Xpayn }{12: } |
+ {4:Xinity }{12: } |
+ {5:-- Keyword Local completion (^N^P) }{6:match 1 of 7} |
]],
}
end)
@@ -950,8 +1062,8 @@ describe('completion', function()
bar |
foobar |
f^ |
- {0:~ }|*3
- {3:-- Keyword completion (^N^P) }{5:Back at original} |
+ {1:~ }|*3
+ {5:-- Keyword completion (^N^P) }{19:Back at original} |
]],
popupmenu = {
anchor = { 1, 3, 0 },
@@ -970,8 +1082,8 @@ describe('completion', function()
bar |
foobar |
foob^ |
- {0:~ }|*3
- {3:-- Keyword completion (^N^P) }{5:Back at original} |
+ {1:~ }|*3
+ {5:-- Keyword completion (^N^P) }{19:Back at original} |
]],
popupmenu = {
anchor = { 1, 3, 0 },
@@ -992,10 +1104,10 @@ describe('completion', function()
bar |
foobar |
f^ |
- {1:foo }{0: }|
- {1:foobar }{0: }|
- {0:~ }|
- {3:-- Keyword completion (^N^P) }{5:Back at original} |
+ {4:foo }{1: }|
+ {4:foobar }{1: }|
+ {1:~ }|
+ {5:-- Keyword completion (^N^P) }{19:Back at original} |
]])
eq(
{ completed_item = {}, width = 15, height = 2, size = 2, col = 0, row = 4, scrollbar = false },
@@ -1007,10 +1119,10 @@ describe('completion', function()
bar |
foobar |
foo^ |
- {2:foo }{0: }|
- {1:foobar }{0: }|
- {0:~ }|
- {3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
+ {12:foo }{1: }|
+ {4:foobar }{1: }|
+ {1:~ }|
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 2} |
]])
eq('foo', eval('g:word'))
feed('<C-N>')
@@ -1019,10 +1131,10 @@ describe('completion', function()
bar |
foobar |
foobar^ |
- {1:foo }{0: }|
- {2:foobar }{0: }|
- {0:~ }|
- {3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
+ {4:foo }{1: }|
+ {12:foobar }{1: }|
+ {1:~ }|
+ {5:-- Keyword completion (^N^P) }{6:match 2 of 2} |
]])
eq('foobar', eval('g:word'))
feed('<up>')
@@ -1031,10 +1143,10 @@ describe('completion', function()
bar |
foobar |
foobar^ |
- {2:foo }{0: }|
- {1:foobar }{0: }|
- {0:~ }|
- {3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
+ {12:foo }{1: }|
+ {4:foobar }{1: }|
+ {1:~ }|
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 2} |
]])
eq('foo', eval('g:word'))
feed('<down>')
@@ -1043,10 +1155,10 @@ describe('completion', function()
bar |
foobar |
foobar^ |
- {1:foo }{0: }|
- {2:foobar }{0: }|
- {0:~ }|
- {3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
+ {4:foo }{1: }|
+ {12:foobar }{1: }|
+ {1:~ }|
+ {5:-- Keyword completion (^N^P) }{6:match 2 of 2} |
]])
eq('foobar', eval('g:word'))
feed('<esc>')
@@ -1061,11 +1173,11 @@ describe('completion', function()
hullo |
heeee |
hello^ |
- {2:hello }{0: }|
- {1:hullo }{0: }|
- {1:heeee }{0: }|
- {0:~ }|*6
- {3:-- }{4:match 1 of 3} |
+ {12:hello }{1: }|
+ {4:hullo }{1: }|
+ {4:heeee }{1: }|
+ {1:~ }|*6
+ {5:-- }{6:match 1 of 3} |
]])
command([[call timer_start(100, { -> execute('stopinsert') })]])
vim.uv.sleep(200)
@@ -1075,7 +1187,7 @@ describe('completion', function()
hullo |
heee^e |
hello |
- {0:~ }|*9
+ {1:~ }|*9
|
]])
end)
@@ -1090,9 +1202,9 @@ describe('completion', function()
screen:expect([[
ii |
ii^ |
- {2:ii }{0: }|
- {0:~ }|*4
- {3:-- Keyword completion (^N^P) The only match} |
+ {12:ii }{1: }|
+ {1:~ }|*4
+ {5:-- Keyword completion (^N^P) The only match} |
]])
assert_alive()
end)
@@ -1129,22 +1241,22 @@ describe('completion', function()
screen:expect {
grid = [[
foo^ |
- {2:foo }{0: }|
- {1:bar }{0: }|
- {1:foa }{0: }|
- {1:.hidden }{0: }|
- {0:~ }|*3
- {3:-- }{4:match 1 of 4} |
+ {12:foo }{1: }|
+ {4:bar }{1: }|
+ {4:foa }{1: }|
+ {4:.hidden }{1: }|
+ {1:~ }|*3
+ {5:-- }{6:match 1 of 4} |
]],
}
feed('<Esc>ccf<C-n>')
screen:expect {
grid = [[
foo^ |
- {2:foo }{0: }|
- {1:foa }{0: }|
- {0:~ }|*5
- {3:-- }{4:match 1 of 2} |
+ {12:foo }{1: }|
+ {4:foa }{1: }|
+ {1:~ }|*5
+ {5:-- }{6:match 1 of 2} |
]],
}
end)
@@ -1168,10 +1280,10 @@ describe('completion', function()
eq(eval('mark'), eval("nvim_buf_get_extmark_by_id(0, ns_id, mark_id, { 'details':1 })"))
feed('<Esc>0Yppia<Esc>ggI<C-N>')
screen:expect([[
- aaaa{7:^aa}aa |
- {2:aaaa } |
- {1:aaaaa } |
- {3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
+ aaaa{9:^aa}aa |
+ {12:aaaa } |
+ {4:aaaaa } |
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 2} |
]])
feed('<C-N><C-N><Esc>')
eq(eval('mark'), eval("nvim_buf_get_extmark_by_id(0, ns_id, mark_id, { 'details':1 })"))
@@ -1180,16 +1292,16 @@ describe('completion', function()
feed('<C-N>')
screen:expect([[
aaaaa^ |
- {1:aaaa } |
- {2:aaaaa } |
- {3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
+ {4:aaaa } |
+ {12:aaaaa } |
+ {5:-- Keyword completion (^N^P) }{6:match 2 of 2} |
]])
feed('<C-E>')
screen:expect([[
- {7:aa}aa^ |
+ {9:aa}aa^ |
aaaa |
aaaaa |
- {3:-- INSERT --} |
+ {5:-- INSERT --} |
]])
end)
end)
diff --git a/test/functional/editor/defaults_spec.lua b/test/functional/editor/defaults_spec.lua
new file mode 100644
index 0000000000..47fd177f7b
--- /dev/null
+++ b/test/functional/editor/defaults_spec.lua
@@ -0,0 +1,100 @@
+--
+-- Tests for default autocmds, mappings, commands, and menus.
+--
+-- See options/defaults_spec.lua for default options and environment decisions.
+--
+
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+local Screen = require('test.functional.ui.screen')
+
+describe('default', function()
+ describe('autocommands', function()
+ it('nvim_terminal.TermClose closes terminal with default shell on success', function()
+ n.clear()
+ n.api.nvim_set_option_value('shell', n.testprg('shell-test'), {})
+ n.command('set shellcmdflag=EXIT shellredir= shellpipe= shellquote= shellxquote=')
+
+ -- Should not block other events
+ n.command('let g:n=0')
+ n.command('au BufEnter * let g:n = g:n + 1')
+
+ n.command('terminal')
+ t.eq(1, n.eval('get(g:, "n", 0)'))
+
+ t.retry(nil, 1000, function()
+ t.neq('terminal', n.api.nvim_get_option_value('buftype', { buf = 0 }))
+ t.eq(2, n.eval('get(g:, "n", 0)'))
+ end)
+ end)
+ end)
+
+ describe('popupmenu', function()
+ it('can be disabled by user', function()
+ n.clear {
+ args = { '+autocmd! nvim_popupmenu', '+aunmenu PopUp' },
+ }
+ local screen = Screen.new(40, 8)
+ screen:attach()
+ n.insert([[
+ 1 line 1
+ 2 https://example.com
+ 3 line 3
+ 4 line 4]])
+
+ n.api.nvim_input_mouse('right', 'press', '', 0, 1, 4)
+ screen:expect({
+ grid = [[
+ 1 line 1 |
+ 2 ht^tps://example.com |
+ 3 line 3 |
+ 4 line 4 |
+ {1:~ }|*3
+ |
+ ]],
+ })
+ end)
+
+ it('right-click on URL shows "Open in web browser"', function()
+ n.clear()
+ local screen = Screen.new(40, 8)
+ screen:attach()
+ n.insert([[
+ 1 line 1
+ 2 https://example.com
+ 3 line 3
+ 4 line 4]])
+
+ n.api.nvim_input_mouse('right', 'press', '', 0, 3, 4)
+ screen:expect({
+ grid = [[
+ 1 line 1 |
+ 2 https://example.com |
+ 3 line 3 |
+ 4 li^ne 4 |
+ {1:~ }{4: Inspect }{1: }|
+ {1:~ }{4: }{1: }|
+ {1:~ }{4: Paste }{1: }|
+ {4: Select All } |
+ ]],
+ })
+
+ n.api.nvim_input_mouse('right', 'press', '', 0, 1, 4)
+ screen:expect({
+ grid = [[
+ 1 line 1 |
+ 2 ht^tps://example.com |
+ 3 l{4: Open in web browser } |
+ 4 l{4: Inspect } |
+ {1:~ }{4: }{1: }|
+ {1:~ }{4: Paste }{1: }|
+ {1:~ }{4: Select All }{1: }|
+ {4: } |
+ ]],
+ })
+ end)
+ end)
+
+ -- describe('key mappings', function()
+ -- end)
+end)
diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua
index 880831d9f8..ab4cefaf84 100644
--- a/test/functional/editor/jump_spec.lua
+++ b/test/functional/editor/jump_spec.lua
@@ -194,7 +194,7 @@ describe("jumpoptions=stack behaves like 'tagstack'", function()
end)
end)
-describe('buffer deletion', function()
+describe('buffer deletion with jumpoptions+=clean', function()
local base_file = 'Xtest-functional-buffer-deletion'
local file1 = base_file .. '1'
local file2 = base_file .. '2'
@@ -227,6 +227,12 @@ describe('buffer deletion', function()
command('edit ' .. file3)
end)
+ after_each(function()
+ os.remove(file1)
+ os.remove(file2)
+ os.remove(file3)
+ end)
+
it('deletes jump list entries when the current buffer is deleted', function()
command('edit ' .. file1)
@@ -319,6 +325,44 @@ describe('buffer deletion', function()
end)
end)
+describe('buffer deletion with jumpoptions-=clean', function()
+ local base_file = 'Xtest-functional-buffer-deletion'
+ local file1 = base_file .. '1'
+ local file2 = base_file .. '2'
+ local base_content = 'text'
+ local content1 = base_content .. '1'
+ local content2 = base_content .. '2'
+
+ before_each(function()
+ clear()
+ command('clearjumps')
+ command('set jumpoptions-=clean')
+
+ write_file(file1, content1, false, false)
+ write_file(file2, content2, false, false)
+
+ command('edit ' .. file1)
+ command('edit ' .. file2)
+ end)
+
+ after_each(function()
+ os.remove(file1)
+ os.remove(file2)
+ end)
+
+ it('Ctrl-O reopens previous buffer with :bunload or :bdelete #28968', function()
+ eq(file2, fn.bufname(''))
+ command('bunload')
+ eq(file1, fn.bufname(''))
+ feed('<C-O>')
+ eq(file2, fn.bufname(''))
+ command('bdelete')
+ eq(file1, fn.bufname(''))
+ feed('<C-O>')
+ eq(file2, fn.bufname(''))
+ end)
+end)
+
describe('jumpoptions=view', function()
local file1 = 'Xtestfile-functional-editor-jumps'
local file2 = 'Xtestfile-functional-editor-jumps-2'
diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua
index 27c5eddac8..680a70b78a 100644
--- a/test/functional/editor/macro_spec.lua
+++ b/test/functional/editor/macro_spec.lua
@@ -148,6 +148,23 @@ helloFOO]]
eq({ 0, 1, 1, 0 }, fn.getpos('v'))
end)
+ it('can be recorded and replayed in Visual mode when ignorecase', function()
+ command('set ignorecase')
+ insert('foo BAR BAR foo BAR foo BAR BAR BAR foo BAR BAR')
+ feed('0vqifofRq')
+ eq({ 0, 1, 7, 0 }, fn.getpos('.'))
+ eq({ 0, 1, 1, 0 }, fn.getpos('v'))
+ feed('Q')
+ eq({ 0, 1, 19, 0 }, fn.getpos('.'))
+ eq({ 0, 1, 1, 0 }, fn.getpos('v'))
+ feed('Q')
+ eq({ 0, 1, 27, 0 }, fn.getpos('.'))
+ eq({ 0, 1, 1, 0 }, fn.getpos('v'))
+ feed('@i')
+ eq({ 0, 1, 43, 0 }, fn.getpos('.'))
+ eq({ 0, 1, 1, 0 }, fn.getpos('v'))
+ end)
+
it('can be replayed with @ in blockwise Visual mode', function()
insert [[
hello
diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua
index 87fe395608..30027e2fd6 100644
--- a/test/functional/editor/meta_key_spec.lua
+++ b/test/functional/editor/meta_key_spec.lua
@@ -145,7 +145,8 @@ describe('meta-keys #8226 #13042', function()
end)
it('ALT/META with vim.on_key()', function()
- feed('ifoo<CR>bar<CR>baz<Esc>gg0')
+ feed('ifoo<CR>bar<CR>baz<Esc>gg0viw"ay')
+ command('nnoremap … "')
exec_lua [[
keys = {}
@@ -157,15 +158,15 @@ describe('meta-keys #8226 #13042', function()
end)
]]
- -- <M-"> is reinterpreted as <Esc>"
- feed('qrviw"ayc$FOO.<M-">apq')
+ -- <M-"> and <M-…> are reinterpreted as <Esc>" and <Esc>…
+ feed('c$FOO.<M-">apA.<M-…>ap')
expect([[
- FOO.foo
+ FOO.foo.foo
bar
baz]])
- -- vim.on_key() callback should only receive <Esc>"
- eq('qrviw"ayc$FOO.<Esc>"apq', exec_lua [[return table.concat(keys, '')]])
- eq('qrviw"ayc$FOO.<Esc>"apq', exec_lua [[return table.concat(typed, '')]])
+ -- vim.on_key() callback should only receive <Esc>" and <Esc>…
+ eq('c$FOO.<Esc>"apA.<Esc>"ap', exec_lua [[return table.concat(keys, '')]])
+ eq('c$FOO.<Esc>"apA.<Esc>…ap', exec_lua [[return table.concat(typed, '')]])
end)
end)
diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua
index 70bdc5d4c2..efd7a37c0b 100644
--- a/test/functional/editor/mode_cmdline_spec.lua
+++ b/test/functional/editor/mode_cmdline_spec.lua
@@ -48,18 +48,14 @@ describe('cmdline', function()
it('redraws statusline when toggling overstrike', function()
local screen = Screen.new(60, 4)
- screen:set_default_attr_ids({
- [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
- [1] = { reverse = true, bold = true }, -- StatusLine
- })
screen:attach()
command('set laststatus=2 statusline=%!mode(1)')
feed(':')
screen:expect {
grid = [[
|
- {0:~ }|
- {1:c }|
+ {1:~ }|
+ {3:c }|
:^ |
]],
}
@@ -67,8 +63,8 @@ describe('cmdline', function()
screen:expect {
grid = [[
|
- {0:~ }|
- {1:cr }|
+ {1:~ }|
+ {3:cr }|
:^ |
]],
}
diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua
index fb3dda4bf4..87d5c46134 100644
--- a/test/functional/editor/mode_insert_spec.lua
+++ b/test/functional/editor/mode_insert_spec.lua
@@ -180,12 +180,6 @@ describe('insert-mode', function()
it('multi-char mapping updates screen properly #25626', function()
local screen = Screen.new(60, 6)
- screen:set_default_attr_ids({
- [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
- [1] = { bold = true, reverse = true }, -- StatusLine
- [2] = { reverse = true }, -- StatusLineNC
- [3] = { bold = true }, -- ModeMsg
- })
screen:attach()
command('vnew')
insert('foo\nfoo\nfoo')
@@ -197,10 +191,10 @@ describe('insert-mode', function()
grid = [[
foo │ |
foo │β^jβ |
- foo │{0:~ }|
- {0:~ }│{0:~ }|
- {2:[No Name] [+] }{1:[No Name] [+] }|
- {3:-- INSERT --} |
+ foo │{1:~ }|
+ {1:~ }│{1:~ }|
+ {2:[No Name] [+] }{3:[No Name] [+] }|
+ {5:-- INSERT --} |
]],
}
feed('k')
@@ -208,9 +202,9 @@ describe('insert-mode', function()
grid = [[
foo │ |
foo │^βββ |
- foo │{0:~ }|
- {0:~ }│{0:~ }|
- {2:[No Name] [+] }{1:[No Name] [+] }|
+ foo │{1:~ }|
+ {1:~ }│{1:~ }|
+ {2:[No Name] [+] }{3:[No Name] [+] }|
|
]],
}
@@ -357,4 +351,97 @@ describe('insert-mode', function()
eq(2, api.nvim_win_get_cursor(0)[1])
end)
end)
+
+ it('backspace after replacing multibyte chars', function()
+ local screen = Screen.new(30, 3)
+ screen:attach()
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'test ȧ̟̜̝̅̚m̆̉̐̐̇̈ å' })
+ feed('^Rabcdefghi')
+ screen:expect([[
+ abcdefghi^ |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcdefgh^å |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcdefg^ å |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcdef^m̆̉̐̐̇̈ å |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcde^ȧ̟̜̝̅̚m̆̉̐̐̇̈ å |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcd^ ȧ̟̜̝̅̚m̆̉̐̐̇̈ å |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<esc>')
+
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'wow 🧑‍🌾🏳️‍⚧️x' })
+ feed('^Rabcd')
+
+ screen:expect([[
+ abcd^🧑‍🌾🏳️‍⚧️x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('e')
+ screen:expect([[
+ abcde^🏳️‍⚧️x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('f')
+ screen:expect([[
+ abcdef^x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcde^🏳️‍⚧️x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abcd^🧑‍🌾🏳️‍⚧️x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+
+ feed('<bs>')
+ screen:expect([[
+ abc^ 🧑‍🌾🏳️‍⚧️x |
+ {1:~ }|
+ {5:-- REPLACE --} |
+ ]])
+ end)
end)
diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua
index 0b26494436..c20a6e5cb5 100644
--- a/test/functional/editor/tabpage_spec.lua
+++ b/test/functional/editor/tabpage_spec.lua
@@ -102,14 +102,9 @@ describe('tabpage', function()
it('switching tabpage after setting laststatus=3 #19591', function()
local screen = Screen.new(40, 8)
- screen:set_default_attr_ids({
- [0] = { bold = true, foreground = Screen.colors.Blue },
- [1] = { bold = true, reverse = true }, -- StatusLine
- [2] = { reverse = true }, -- TabLineFill
- [3] = { bold = true }, -- TabLineSel
- [4] = { background = Screen.colors.LightGrey, underline = true }, -- TabLine
- [5] = { bold = true, foreground = Screen.colors.Magenta },
- })
+ screen:add_extra_attr_ids {
+ [100] = { bold = true, foreground = Screen.colors.Fuchsia },
+ }
screen:attach()
command('tabnew')
@@ -118,18 +113,18 @@ describe('tabpage', function()
command('tabnext')
feed('<C-G>')
screen:expect([[
- {4: [No Name] }{3: [No Name] }{2: }{4:X}|
+ {24: [No Name] }{5: [No Name] }{2: }{24:X}|
^ |
- {0:~ }|*4
- {1:[No Name] }|
+ {1:~ }|*4
+ {3:[No Name] }|
"[No Name]" --No lines in buffer-- |
]])
command('vnew')
screen:expect([[
- {4: [No Name] }{3: }{5:2}{3: [No Name] }{2: }{4:X}|
+ {24: [No Name] }{5: }{100:2}{5: [No Name] }{2: }{24:X}|
^ │ |
- {0:~ }│{0:~ }|*4
- {1:[No Name] }|
+ {1:~ }│{1:~ }|*4
+ {3:[No Name] }|
"[No Name]" --No lines in buffer-- |
]])
end)