From 407abb3a6c5c1c706bf8797a1431e57e97a6b797 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Apr 2017 01:00:40 +0300 Subject: eval,ex_getln: Add support for coloring input() prompts --- test/functional/eval/input_spec.lua | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 74ad32bc6c..f0c1314754 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -23,10 +23,41 @@ before_each(function() function CustomListCompl(...) return ['FOO'] endfunction + + highlight RBP1 guibg=Red + highlight RBP2 guibg=Yellow + highlight RBP3 guibg=Green + highlight RBP4 guibg=Blue + let g:NUM_LVLS = 4 + function Redraw() + redraw! + return '' + endfunction + cnoremap {REDRAW} Redraw() + function RainBowParens(cmdline) + let ret = [] + let i = 0 + let lvl = 0 + while i < len(a:cmdline) + if a:cmdline[i] is# '(' + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + let lvl += 1 + elseif a:cmdline[i] is# ')' + let lvl -= 1 + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) + endif + let i += 1 + endwhile + return ret + endfunction ]]) screen:set_default_attr_ids({ EOB={bold = true, foreground = Screen.colors.Blue1}, T={foreground=Screen.colors.Red}, + RBP1={background=Screen.colors.Red}, + RBP2={background=Screen.colors.Yellow}, + RBP3={background=Screen.colors.Green}, + RBP4={background=Screen.colors.Blue}, }) end) @@ -196,6 +227,19 @@ describe('input()', function() eq('Vim(call):E118: Too many arguments for function: input', exc_exec('call input("prompt> ", "default", "file", "extra")')) end) + it('supports highlighting', function() + feed([[:call input({"highlight": "RainBowParens"})]]) + wait() + feed('(())') + wait() + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + {RBP1:(}{RBP2:()}{RBP1:)}^ | + ]]) + end) end) describe('inputdialog()', function() it('works with multiline prompts', function() @@ -363,4 +407,17 @@ describe('inputdialog()', function() eq('Vim(call):E118: Too many arguments for function: inputdialog', exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) + it('supports highlighting', function() + feed([[:call inputdialog({"highlight": "RainBowParens"})]]) + wait() + feed('(())') + wait() + screen:expect([[ + {EOB:~ }| + {EOB:~ }| + {EOB:~ }| + | + {RBP1:(}{RBP2:()}{RBP1:)}^ | + ]]) + end) end) -- cgit From 95fe5614a02948bcd0993c751acede34d2acb3c8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 22 May 2017 03:25:46 +0300 Subject: functests: Add missing wait() --- test/functional/eval/input_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index f0c1314754..5b259d5440 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq +local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear -- cgit From 1ba21b4a31ea5853673ba3d1baae3e862c1ef04a Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 13:02:45 +0300 Subject: functests: Remove unneeded wait()s --- test/functional/eval/input_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 5b259d5440..0571043efe 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -232,7 +232,6 @@ describe('input()', function() feed([[:call input({"highlight": "RainBowParens"})]]) wait() feed('(())') - wait() screen:expect([[ {EOB:~ }| {EOB:~ }| @@ -412,7 +411,6 @@ describe('inputdialog()', function() feed([[:call inputdialog({"highlight": "RainBowParens"})]]) wait() feed('(())') - wait() screen:expect([[ {EOB:~ }| {EOB:~ }| -- cgit From e129607988b88719935bc4af517e7ee2689f5871 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 22:04:39 +0300 Subject: functests: Replace wait() with nvim_async --- test/functional/eval/input_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 0571043efe..cfb91983c1 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq -local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec +local nvim_async = helpers.nvim_async local screen @@ -229,16 +229,16 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call input({"highlight": "RainBowParens"})]]) - wait() + nvim_async('command', 'call input({"highlight": "RainBowParens"})') feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) + feed('') end) end) describe('inputdialog()', function() @@ -408,15 +408,15 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call inputdialog({"highlight": "RainBowParens"})]]) - wait() + nvim_async('command', 'call inputdialog({"highlight": "RainBowParens"})') feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) + feed('') end) end) -- cgit From 1011462b40502e6039494e70a870f0360f152b1b Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 27 Jul 2017 18:49:13 +0300 Subject: Revert "functests: Replace wait() with nvim_async" This reverts commit e129607988b88719935bc4af517e7ee2689f5871. Tests stopped working in CI. --- test/functional/eval/input_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index cfb91983c1..0571043efe 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,13 +2,13 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq +local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec -local nvim_async = helpers.nvim_async local screen @@ -229,16 +229,16 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - nvim_async('command', 'call input({"highlight": "RainBowParens"})') + feed([[:call input({"highlight": "RainBowParens"})]]) + wait() feed('(())') screen:expect([[ - | {EOB:~ }| {EOB:~ }| {EOB:~ }| + | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) - feed('') end) end) describe('inputdialog()', function() @@ -408,15 +408,15 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - nvim_async('command', 'call inputdialog({"highlight": "RainBowParens"})') + feed([[:call inputdialog({"highlight": "RainBowParens"})]]) + wait() feed('(())') screen:expect([[ - | {EOB:~ }| {EOB:~ }| {EOB:~ }| + | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) - feed('') end) end) -- cgit From efb03903eb667bc14992dffcd77d04385371abed Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 6 Aug 2017 14:43:46 +0300 Subject: functests: Remove wait() from input_spec --- test/functional/eval/input_spec.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test/functional/eval') diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua index 0571043efe..5ae23e17d0 100644 --- a/test/functional/eval/input_spec.lua +++ b/test/functional/eval/input_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local eq = helpers.eq -local wait = helpers.wait local feed = helpers.feed local meths = helpers.meths local clear = helpers.clear @@ -229,14 +228,14 @@ describe('input()', function() exc_exec('call input("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call input({"highlight": "RainBowParens"})]]) - wait() + command('nnoremap X input({"highlight": "RainBowParens"})[-1]') + feed([[X]]) feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) end) @@ -408,14 +407,14 @@ describe('inputdialog()', function() exc_exec('call inputdialog("prompt> ", "default", "file", "extra")')) end) it('supports highlighting', function() - feed([[:call inputdialog({"highlight": "RainBowParens"})]]) - wait() + command('nnoremap X inputdialog({"highlight": "RainBowParens"})[-1]') + feed([[X]]) feed('(())') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - | {RBP1:(}{RBP2:()}{RBP1:)}^ | ]]) end) -- cgit