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.lua2
-rw-r--r--test/functional/ui/highlight_spec.lua3
-rw-r--r--test/functional/ui/input_spec.lua2
-rw-r--r--test/functional/ui/mouse_spec.lua319
-rw-r--r--test/functional/ui/output_spec.lua39
-rw-r--r--test/functional/ui/screen.lua8
-rw-r--r--test/functional/ui/screen_basic_spec.lua2
-rw-r--r--test/functional/ui/searchhl_spec.lua2
-rw-r--r--test/functional/ui/sign_spec.lua2
-rw-r--r--test/functional/ui/syntax_conceal_spec.lua2
-rw-r--r--test/functional/ui/wildmode_spec.lua2
11 files changed, 371 insertions, 12 deletions
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index 58f5b11de0..f91aa8d402 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, request, neq = helpers.execute, helpers.request, helpers.neq
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 85fca4d7ca..6ef40fff62 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local os = require('os')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
@@ -38,7 +38,6 @@ describe('manual syntax highlight', function()
os.remove('Xtest-functional-ui-highlight.tmp.vim')
end)
- -- test with "set hidden" even if the bug did not occur this way
it("works with buffer switch and 'hidden'", function()
execute('e tmp1.vim')
execute('e Xtest-functional-ui-highlight.tmp.vim')
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index 6f5cadaf81..407c576002 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim
local feed, next_message, eq = helpers.feed, helpers.next_message, helpers.eq
local expect = helpers.expect
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 993bbd5b0e..7b820347ac 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, execute = helpers.insert, helpers.execute
@@ -462,4 +462,321 @@ describe('Mouse input', function()
|
]])
end)
+
+ describe('on concealed text', function()
+ -- Helpful for reading the test expectations:
+ -- :match Error /\^/
+ local concealed = {
+ c = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }
+ }
+
+ before_each(function()
+ screen:try_resize(25, 7)
+ feed('ggdG')
+
+ execute('set concealcursor=n')
+ execute('set nowrap')
+ execute('syntax match NonText "\\<amet\\>" conceal')
+ execute('syntax match NonText "\\cs\\|g." conceal cchar=X')
+ execute('syntax match NonText "\\%(lo\\|cl\\)." conceal')
+ execute('syntax match NonText "Lo" conceal cchar=Y')
+
+ insert([[
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
+ Stet clita kasd gubergren, no sea takimata sanctus est.
+ ]])
+
+ feed('gg')
+ end)
+
+ it('(level 1) click on non-wrapped lines', function()
+ execute('let &conceallevel=1', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ {c:^Y}rem ip{c:X}um do{c: } {c:X}it {c: }, con|
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><1,0>')
+ screen:expect([[
+ {c:Y}^rem ip{c:X}um do{c: } {c:X}it {c: }, con|
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,0>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do{c: } {c:^X}it {c: }, con|
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en, no|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do{c: } {c:X}it {c: }, con|
+ {c:X}tet {c: }ta ka{c:X}d {c:X}^ber{c:X}en, no|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+ end) -- level 1 - non wrapped
+
+ it('(level 1) click on wrapped lines', function()
+ execute('let &conceallevel=1', 'let &wrap=1', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ {c:^Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
+ , con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><6,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
+ , con{c:X}^etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
+ , con{c:X}etetur {c:X}a^dip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet {c: }ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,3>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do{c: } {c:X}it {c: } |
+ , con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet {c: }ta ka{c:X}d {c:X}^ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+ end) -- level 1 - wrapped
+
+
+ it('(level 2) click on non-wrapped lines', function()
+ execute('let &conceallevel=2', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ {c:^Y}rem ip{c:X}um do {c:X}it , con{c:X}e|
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><1,0>')
+ screen:expect([[
+ {c:Y}^rem ip{c:X}um do {c:X}it , con{c:X}e|
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,0>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do {c:X}^it , con{c:X}e|
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en, no |
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do {c:X}it , con{c:X}e|
+ {c:X}tet ta ka{c:X}d {c:X}b^er{c:X}en, no |
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+ end) -- level 2 - non wrapped
+
+ it('(level 2) click on wrapped lines', function()
+ execute('let &conceallevel=2', 'let &wrap=1', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ {c:^Y}rem ip{c:X}um do {c:X}it |
+ , con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><6,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do {c:X}it |
+ , con{c:X}^etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do {c:X}it |
+ , con{c:X}etetur {c:X}a^dip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet ta ka{c:X}d {c:X}ber{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,3>')
+ screen:expect([[
+ {c:Y}rem ip{c:X}um do {c:X}it |
+ , con{c:X}etetur {c:X}adip{c:X}cin{c:X} |
+ elitr. |
+ {c:X}tet ta ka{c:X}d {c:X}b^er{c:X}en |
+ , no {c:X}ea takimata {c:X}anctu{c:X}|
+ e{c:X}t. |
+ |
+ ]], concealed)
+ end) -- level 2 - wrapped
+
+
+ it('(level 3) click on non-wrapped lines', function()
+ execute('let &conceallevel=3', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ ^rem ipum do it , conetetu|
+ tet ta kad beren, no ea t|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><1,0>')
+ screen:expect([[
+ r^em ipum do it , conetetu|
+ tet ta kad beren, no ea t|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,0>')
+ screen:expect([[
+ rem ipum do it ^, conetetu|
+ tet ta kad beren, no ea t|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ rem ipum do it , conetetu|
+ tet ta kad bere^n, no ea t|
+ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], concealed)
+ end) -- level 3 - non wrapped
+
+ it('(level 3) click on wrapped lines', function()
+ execute('let &conceallevel=3', 'let &wrap=1', 'echo')
+
+ feed('<esc><LeftMouse><0,0>')
+ screen:expect([[
+ ^rem ipum do it |
+ , conetetur adipcin |
+ elitr. |
+ tet ta kad beren |
+ , no ea takimata anctu |
+ et. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><6,1>')
+ screen:expect([[
+ rem ipum do it |
+ , cone^tetur adipcin |
+ elitr. |
+ tet ta kad beren |
+ , no ea takimata anctu |
+ et. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,1>')
+ screen:expect([[
+ rem ipum do it |
+ , conetetur adi^pcin |
+ elitr. |
+ tet ta kad beren |
+ , no ea takimata anctu |
+ et. |
+ |
+ ]], concealed)
+
+ feed('<esc><LeftMouse><15,3>')
+ screen:expect([[
+ rem ipum do it |
+ , conetetur adipcin |
+ elitr. |
+ tet ta kad bere^n |
+ , no ea takimata anctu |
+ et. |
+ |
+ ]], concealed)
+ end) -- level 3 - wrapped
+ end)
end)
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
new file mode 100644
index 0000000000..c7c8986527
--- /dev/null
+++ b/test/functional/ui/output_spec.lua
@@ -0,0 +1,39 @@
+local session = require('test.functional.helpers')(after_each)
+local child_session = require('test.functional.terminal.helpers')
+
+describe("shell command :!", function()
+ local screen
+ before_each(function()
+ session.clear()
+ screen = child_session.screen_setup(0, '["'..session.nvim_prog..
+ '", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it("displays output even without LF/EOF. #4646 #4569 #3772", function()
+ -- 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")
+ screen:expect([[
+ ~ |
+ ~ |
+ [No Name] |
+ :!printf foo; sleep 200 |
+ |
+ foo |
+ -- TERMINAL -- |
+ ]])
+ end)
+end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 6372cbe081..d7af2a4fce 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -105,7 +105,7 @@
-- To generate a text-only test without highlight checks,
-- use `screen:snapshot_util({},true)`
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(nil)
local request, run = helpers.request, helpers.run
local dedent = helpers.dedent
@@ -290,6 +290,10 @@ If everything else fails, use Screen:redraw_debug to help investigate what is
end
end
+function Screen:sleep(ms)
+ pcall(function() self:wait(function() return "error" end, ms) end)
+end
+
function Screen:_redraw(updates)
for _, update in ipairs(updates) do
-- print('--')
@@ -501,7 +505,7 @@ end
function Screen:snapshot_util(attrs, ignore)
-- util to generate screen test
- pcall(function() self:wait(function() return "error" end, 250) end)
+ self:sleep(250)
self:print_snapshot(attrs, ignore)
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index a4545eeff0..9249be4aec 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear
local feed, execute = helpers.feed, helpers.execute
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index e4217abcfe..894a75d355 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute = helpers.execute
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua
index c32a7b9381..2b6e294627 100644
--- a/test/functional/ui/sign_spec.lua
+++ b/test/functional/ui/sign_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index 66ea779011..c2ab0711c0 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
local insert = helpers.insert
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index c57d4abcbf..2a55d27567 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require('test.functional.helpers')
+local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
local funcs = helpers.funcs