From 9ab9eb1220113d247dd1eb089cb6576a135b8699 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 08:28:20 +0800 Subject: fix(source): make changing 'shellslash' change expand() result --- test/functional/ex_cmds/source_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 13a40fcc53..4bc3355e9e 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -13,6 +13,10 @@ local exec_lua = helpers.exec_lua local eval = helpers.eval local exec_capture = helpers.exec_capture local neq = helpers.neq +local matches = helpers.matches +local iswin = helpers.iswin +local mkdir = helpers.mkdir +local rmdir = helpers.rmdir describe(':source', function() before_each(function() @@ -39,6 +43,30 @@ describe(':source', function() os.remove(test_file) end) + it("changing 'shellslash' changes the result of expand()", function() + if not iswin() then + pending("'shellslash' only works on Windows") + return + end + mkdir('Xshellslash') + local script = [[ + let g:result1 = expand('') + set shellslash + let g:result2 = expand('') + set noshellslash + let g:result3 = expand('') + ]] + write_file([[Xshellslash/Xexpand.vim]], script) + + meths.set_option('shellslash', false) + command([[source Xshellslash/Xexpand.vim]]) + matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result1')) + matches([[Xshellslash/Xexpand%.vim]], meths.get_var('result2')) + matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result3')) + + rmdir('Xshellslash') + end) + it('current buffer', function() insert([[ let a = 2 -- cgit From d1464d16d6897144b29c22f8113aad9b7210e14c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 13:40:01 +0800 Subject: fix(source): fix expand('') no longer works for Lua --- test/functional/ex_cmds/source_spec.lua | 59 ++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 4bc3355e9e..163ded43f9 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -48,21 +48,38 @@ describe(':source', function() pending("'shellslash' only works on Windows") return end + meths.set_option('shellslash', false) mkdir('Xshellslash') - local script = [[ - let g:result1 = expand('') + + write_file([[Xshellslash/Xstack.vim]], [[ + let g:stack1 = expand('') set shellslash - let g:result2 = expand('') + let g:stack2 = expand('') set noshellslash - let g:result3 = expand('') - ]] - write_file([[Xshellslash/Xexpand.vim]], script) + let g:stack3 = expand('') + ]]) - meths.set_option('shellslash', false) - command([[source Xshellslash/Xexpand.vim]]) - matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result1')) - matches([[Xshellslash/Xexpand%.vim]], meths.get_var('result2')) - matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result3')) + for _ = 1, 2 do + command([[source Xshellslash/Xstack.vim]]) + matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack1')) + matches([[Xshellslash/Xstack%.vim]], meths.get_var('stack2')) + matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack3')) + end + + write_file([[Xshellslash/Xstack.lua]], [[ + vim.g.stack1 = vim.fn.expand('') + vim.o.shellslash = true + vim.g.stack2 = vim.fn.expand('') + vim.o.shellslash = false + vim.g.stack3 = vim.fn.expand('') + ]]) + + for _ = 1, 2 do + command([[source Xshellslash/Xstack.lua]]) + matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack1')) + matches([[Xshellslash/Xstack%.lua]], meths.get_var('stack2')) + matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack3')) + end rmdir('Xshellslash') end) @@ -145,11 +162,18 @@ describe(':source', function() it('can source lua files', function() local test_file = 'test.lua' - write_file (test_file, [[vim.g.sourced_lua = 1]]) - - exec('source ' .. test_file) + write_file(test_file, [[ + vim.g.sourced_lua = 1 + vim.g.sfile_value = vim.fn.expand('') + vim.g.stack_value = vim.fn.expand('') + ]]) + command('set shellslash') + command('source ' .. test_file) eq(1, eval('g:sourced_lua')) + matches([[/test%.lua$]], meths.get_var('sfile_value')) + matches([[/test%.lua$]], meths.get_var('stack_value')) + os.remove(test_file) end) @@ -181,13 +205,15 @@ describe(':source', function() it('can source current lua buffer without argument', function() local test_file = 'test.lua' - write_file (test_file, [[ + write_file(test_file, [[ vim.g.c = 10 vim.g.c = 11 vim.g.c = 12 a = [=[ \ 1 "\ 2]=] + vim.g.sfile_value = vim.fn.expand('') + vim.g.stack_value = vim.fn.expand('') ]]) command('edit '..test_file) @@ -195,6 +221,9 @@ describe(':source', function() eq(12, eval('g:c')) eq(' \\ 1\n "\\ 2', exec_lua('return _G.a')) + eq(':source (no file)', meths.get_var('sfile_value')) + eq(':source (no file)', meths.get_var('stack_value')) + os.remove(test_file) end) -- cgit From f5588ee8968c564f6f7b0e42ac0ad44f83489659 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 17 Aug 2022 17:50:40 +0600 Subject: feat: allow :wincmd to accept a count (#19815) Let :wincmd command accept a count like what its documentation suggests. Previously it could only accept a range, which led to some ambiguity on which attribute should be used when executing :wincmd using nvim_cmd. Closes #19662. Also fix a typo in a related Vim test: vim-patch:9.0.0223: typo in diffmode test Problem: Typo in diffmode test. Solution: Fix the typo. (closes vim/vim#10932) https://github.com/vim/vim/commit/5fd6ab820b4a0aaa5c6020852f39d118375fab49 --- test/functional/ex_cmds/wincmd_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/functional/ex_cmds/wincmd_spec.lua (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/wincmd_spec.lua b/test/functional/ex_cmds/wincmd_spec.lua new file mode 100644 index 0000000000..b1f174f445 --- /dev/null +++ b/test/functional/ex_cmds/wincmd_spec.lua @@ -0,0 +1,13 @@ +local helpers = require("test.functional.helpers")(after_each) +local clear = helpers.clear +local eq = helpers.eq +local funcs = helpers.funcs +local command = helpers.command + +it(':wincmd accepts a count', function() + clear() + command('vsplit') + eq(1, funcs.winnr()) + command('wincmd 2 w') + eq(2, funcs.winnr()) +end) -- cgit From 068a998e609b2568ad280e1753beb2a1251354a5 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 17 Aug 2022 16:19:35 +0200 Subject: fix(tests): remove irrelevant usage of display-=msgsep These were just added to avoid churn when changing the default of 'display'. To simplify message handling logic, we might want to remove support for printing messages in default_grid later on. This would allow things like printing error messages safely in the middle of redraw, or a future graduation of the 'multigrid' feature. --- test/functional/ex_cmds/oldfiles_spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index 003ab64dd4..5f87c3cdd9 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -29,7 +29,6 @@ describe(':oldfiles', function() it('shows most recently used files', function() local screen = Screen.new(100, 5) screen:attach() - feed_command("set display-=msgsep") feed_command('edit testfile1') feed_command('edit testfile2') feed_command('wshada') @@ -37,7 +36,7 @@ describe(':oldfiles', function() local oldfiles = helpers.meths.get_vvar('oldfiles') feed_command('oldfiles') screen:expect([[ - testfile2 | + | 1: ]].. add_padding(oldfiles[1]) ..[[ | 2: ]].. add_padding(oldfiles[2]) ..[[ | | -- cgit