From 337b6179df852350b52409fd3806e4b47ab2875b Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Sat, 1 Apr 2017 20:50:29 +0100 Subject: 'pastetoggle': support value >1 char (#6421) If we `set pastetoggle=abcde`, and manually type it, then `vgetorpeek()` sees part of the option before it has all been inserted into the typebuffer. To signify this it sets `keylen = KEYLEN_PART_KEY`, but the condition about whether to return the current key from `vgetorpeek()` only checks for `keylen = KEYLEN_PART_MAP`. Add a check for `KEYLEN_PART_KEY` to account for the `'pastetoggle'` option. --- test/functional/options/pastetoggle_spec.lua | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/functional/options/pastetoggle_spec.lua (limited to 'test/functional/options') diff --git a/test/functional/options/pastetoggle_spec.lua b/test/functional/options/pastetoggle_spec.lua new file mode 100644 index 0000000000..e449df31f5 --- /dev/null +++ b/test/functional/options/pastetoggle_spec.lua @@ -0,0 +1,37 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local feed = helpers.feed +local execute = helpers.execute +local eq = helpers.eq +local eval = helpers.eval +local sleep = helpers.sleep + +describe("'pastetoggle' option", function() + before_each(function() + clear() + execute('set nopaste') + execute('set pastetoggle=a') + end) + it("toggles 'paste'", function() + eq(eval('&paste'), 0) + feed('a') + -- Need another key so that the vgetorpeek() function returns. + feed('j') + eq(eval('&paste'), 1) + end) + it("multiple key 'pastetoggle' is waited for", function() + eq(eval('&paste'), 0) + local pastetoggle = 'lllll' + execute('set pastetoggle=' .. pastetoggle) + execute('set timeoutlen=1', 'set ttimoutlen=10000') + feed(pastetoggle:sub(0, 2)) + -- sleep() for long enough that vgetorpeek() is gotten into, but short + -- enough that ttimeoutlen is not reached. + sleep(200) + feed(pastetoggle:sub(3, -1)) + -- Need another key so that the vgetorpeek() function returns. + feed('j') + eq(eval('&paste'), 1) + end) +end) -- cgit From 9158cc171f46ebae0a0d3d1721aa5b7d829bcba5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 8 Apr 2017 23:48:22 +0300 Subject: functests: Refactor options/pastetoggle Note: typo, ttimeoutlen not set ever. Mention @hardenedapple --- test/functional/options/pastetoggle_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/options') diff --git a/test/functional/options/pastetoggle_spec.lua b/test/functional/options/pastetoggle_spec.lua index e449df31f5..ec3c60fe37 100644 --- a/test/functional/options/pastetoggle_spec.lua +++ b/test/functional/options/pastetoggle_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local feed = helpers.feed -local execute = helpers.execute +local command = helpers.command local eq = helpers.eq local eval = helpers.eval local sleep = helpers.sleep @@ -10,8 +10,8 @@ local sleep = helpers.sleep describe("'pastetoggle' option", function() before_each(function() clear() - execute('set nopaste') - execute('set pastetoggle=a') + command('set nopaste') + command('set pastetoggle=a') end) it("toggles 'paste'", function() eq(eval('&paste'), 0) @@ -23,8 +23,8 @@ describe("'pastetoggle' option", function() it("multiple key 'pastetoggle' is waited for", function() eq(eval('&paste'), 0) local pastetoggle = 'lllll' - execute('set pastetoggle=' .. pastetoggle) - execute('set timeoutlen=1', 'set ttimoutlen=10000') + command('set pastetoggle=' .. pastetoggle) + command('set timeoutlen=1 ttimeoutlen=10000') feed(pastetoggle:sub(0, 2)) -- sleep() for long enough that vgetorpeek() is gotten into, but short -- enough that ttimeoutlen is not reached. -- cgit From 65fb622000af8e3dbb65480e1581758ecf4ba3e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 00:12:26 +0300 Subject: functests: Replace execute with either command or feed_command Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed. --- test/functional/options/defaults_spec.lua | 4 ++-- test/functional/options/shortmess_spec.lua | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/options') diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index f57fe5fa23..f43d8eeafa 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local meths = helpers.meths -local execute = helpers.execute +local command = helpers.command local clear = helpers.clear local eval = helpers.eval local eq = helpers.eq @@ -25,7 +25,7 @@ describe('startup defaults', function() local function expect_filetype(expected) local screen = Screen.new(48, 4) screen:attach() - execute('filetype') + command('filetype') screen:expect([[ ^ | ~ | diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua index 22e8a39b79..99a574ec46 100644 --- a/test/functional/options/shortmess_spec.lua +++ b/test/functional/options/shortmess_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, execute = helpers.clear, helpers.execute +local clear, feed_command = helpers.clear, helpers.feed_command if helpers.pending_win32(pending) then return end @@ -19,7 +19,7 @@ describe("'shortmess'", function() describe('"F" flag', function() it('hides messages about the files read', function() - execute('e test') + feed_command('e test') screen:expect([[ ^ | ~ | @@ -27,8 +27,8 @@ describe("'shortmess'", function() ~ | "test" is a directory | ]]) - execute('set shortmess=F') - execute('e test') + feed_command('set shortmess=F') + feed_command('e test') screen:expect([[ ^ | ~ | -- cgit