diff options
Diffstat (limited to 'test/functional/ui/inccommand_user_spec.lua')
-rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 142 |
1 files changed, 41 insertions, 101 deletions
diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index da7508fad1..a714df72b7 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -1,6 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local api = helpers.api local clear = helpers.clear +local eq = helpers.eq local exec_lua = helpers.exec_lua local insert = helpers.insert local feed = helpers.feed @@ -236,16 +238,16 @@ describe("'inccommand' for user commands", function() clear() screen = Screen.new(40, 17) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow1}, - [2] = {foreground = Screen.colors.Blue1, bold = true}, - [3] = {reverse = true}, - [4] = {reverse = true, bold = true}, - [5] = {foreground = Screen.colors.Blue}, + [1] = { background = Screen.colors.Yellow1 }, + [2] = { foreground = Screen.colors.Blue1, bold = true }, + [3] = { reverse = true }, + [4] = { reverse = true, bold = true }, + [5] = { foreground = Screen.colors.Blue }, }) screen:attach() exec_lua(setup_replace_cmd) command('set cmdwinheight=5') - insert[[ + insert [[ text on line 1 more text on line 2 oh no, even more text @@ -270,13 +272,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the {1:cats} stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Replace text cats^ | ]]) end) @@ -318,13 +314,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 | ]]) end) @@ -342,13 +332,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the cats stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Replace text cats | ]]) end) @@ -366,13 +350,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :.Replace text cats^ | ]]) end) @@ -425,13 +403,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the cats stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :C^ | ]]) assert_alive() @@ -481,13 +453,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | a.a.a.a. | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Test a.a.a.a.^ | ]]) feed('<C-V><Esc>u') @@ -501,13 +467,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | a.a.a. | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Test a.a.a.a.{5:^[}u^ | ]]) feed('<Esc>') @@ -521,13 +481,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 | ]]) end @@ -543,6 +497,22 @@ describe("'inccommand' for user commands", function() test_preview_break_undo() end) end) + + it('disables preview if preview buffer cannot be created #27086', function() + command('set inccommand=split') + api.nvim_buf_set_name(0, '[Preview]') + exec_lua([[ + vim.api.nvim_create_user_command('Test', function() end, { + nargs = '*', + preview = function(_, _, _) + return 2 + end + }) + ]]) + eq('split', api.nvim_get_option_value('inccommand', {})) + feed(':Test') + eq('nosplit', api.nvim_get_option_value('inccommand', {})) + end) end) describe("'inccommand' with multiple buffers", function() @@ -552,21 +522,21 @@ describe("'inccommand' with multiple buffers", function() clear() screen = Screen.new(40, 17) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow1}, - [2] = {foreground = Screen.colors.Blue1, bold = true}, - [3] = {reverse = true}, - [4] = {reverse = true, bold = true} + [1] = { background = Screen.colors.Yellow1 }, + [2] = { foreground = Screen.colors.Blue1, bold = true }, + [3] = { reverse = true }, + [4] = { reverse = true, bold = true }, }) screen:attach() exec_lua(setup_replace_cmd) command('set cmdwinheight=10') - insert[[ + insert [[ foo bar baz bar baz foo baz foo bar ]] command('vsplit | enew') - insert[[ + insert [[ bar baz foo baz foo bar foo bar baz @@ -581,17 +551,7 @@ describe("'inccommand' with multiple buffers", function() baz {1:bar} bar │ bar baz {1:bar} | {1:bar} bar baz │ baz {1:bar} bar | │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar^ | ]]) @@ -601,17 +561,7 @@ describe("'inccommand' with multiple buffers", function() baz bar bar │ bar baz bar | bar bar baz │ baz bar bar | ^ │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar | ]]) @@ -645,17 +595,7 @@ describe("'inccommand' with multiple buffers", function() baz bar bar │ bar baz bar | bar bar baz │ baz bar bar | ^ │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar | ]]) |