From 39e83fa7cb4486d30f788c3b27594d106d5e76ab Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 24 Feb 2017 06:12:34 +0000 Subject: ui: allow external ui to draw wildmenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Björn Linse Updated docs and tests. --- test/functional/ui/wildmode_spec.lua | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 41a751c284..6ce76568db 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -179,3 +179,102 @@ describe('command line completion', function() ]]) end) end) + +describe('External wildmenu', function() + local screen + local items, selected = nil, nil + + before_each(function() + clear() + screen = Screen.new(25, 5) + screen:attach({rgb=true, ext_wildmenu=true}) + screen:set_on_event_handler(function(name, data) + if name == "wildmenu_show" then + items = data[1] + elseif name == "wildmenu_select" then + selected = data[1] + elseif name == "wildmenu_hide" then + items, selected = nil, nil + end + end) + end) + + after_each(function() + screen:detach() + end) + + it('works with :sign ', function() + local expected = { + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', + } + + command('set wildmode=full') + command('set wildmenu') + feed(':sign ') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign jump^ | + ]], nil, nil, function() + eq(expected, items) + eq(1, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign ^ | + ]], nil, nil, function() + eq(expected, items) + eq(-1, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + + + feed('a') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign definea^ | + ]], nil, nil, function() + eq(nil, items) + eq(nil, selected) + end) + end) +end) -- cgit From 1fcd8389429b51d1d388f7f0a43566b4bcc9b9f4 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 10 Sep 2017 13:23:48 +0200 Subject: Fix old inccomand tests, and add more for the new functionality. --- test/functional/ui/icmmulti_spec.lua | 692 +++++++++++++++++++++++++++++++++ test/functional/ui/inccommand_spec.lua | 48 +-- 2 files changed, 716 insertions(+), 24 deletions(-) create mode 100644 test/functional/ui/icmmulti_spec.lua (limited to 'test/functional/ui') diff --git a/test/functional/ui/icmmulti_spec.lua b/test/functional/ui/icmmulti_spec.lua new file mode 100644 index 0000000000..81ceaec111 --- /dev/null +++ b/test/functional/ui/icmmulti_spec.lua @@ -0,0 +1,692 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local command = helpers.command +local curbufmeths = helpers.curbufmeths +local eq = helpers.eq +local eval = helpers.eval +local feed_command = helpers.feed_command +local expect = helpers.expect +local feed = helpers.feed +local insert = helpers.insert +local meths = helpers.meths +local neq = helpers.neq +local ok = helpers.ok +local source = helpers.source +local wait = helpers.wait +local nvim = helpers.nvim + +local multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 +]] + +local multimatch_text = [[ + a bdc eae a fgl lzia r + x +]] + +local multibyte_text = [[ + £ ¥ ѫѫ PEPPERS +£ ¥ ѫfѫ + a£ ѫ¥KOL +£ ¥ libm +£ ¥ +]] + +local long_multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 + K L M + a b c + d e f + q r s + x y z + £ m n + t œ ¥ +]] +local function common_setup(screen, inccommand, text) + if screen then + command("syntax on") + command("set nohlsearch") + command("hi Substitute guifg=red guibg=yellow") + screen:attach() + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.Fuchsia}, + [2] = {foreground = Screen.colors.Brown, bold = true}, + [3] = {foreground = Screen.colors.SlateBlue}, + [4] = {bold = true, foreground = Screen.colors.SlateBlue}, + [5] = {foreground = Screen.colors.DarkCyan}, + [6] = {bold = true}, + [7] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue}, + [8] = {foreground = Screen.colors.Slateblue, underline = true}, + [9] = {background = Screen.colors.Yellow}, + [10] = {reverse = true}, + [11] = {reverse = true, bold=true}, + [12] = {foreground = Screen.colors.Red, background = Screen.colors.Yellow}, + [13] = {bold = true, foreground = Screen.colors.SeaGreen}, + [14] = {foreground = Screen.colors.White, background = Screen.colors.Red}, + [15] = {bold=true, foreground=Screen.colors.Blue}, + [16] = {background=Screen.colors.Grey90}, -- cursorline + vis = {background=Screen.colors.LightGrey} + }) + end + + command("set inccommand=" .. (inccommand and inccommand or "")) + + if text then + insert(text) + end +end + +describe(":substitute", function() + local screen = Screen.new(30,15) + + before_each(function() + clear() + end) + + it(", inccomand=split, highlights multiline substitutions", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| 1 {12:MMM} Y Z | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {11:[No Name] [+] }| + |1| 1 {12:MMM} | + |2|{12: K} | + |3|{12: LLL} Y Z | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccomand=nosplit, highlights multiline substitutions", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccomand=split, highlights multiple matches on a line", function() + common_setup(screen, "split", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| + {12:LK} r | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccomand=nosplit, highlights multiple matches on a line", function() + common_setup(screen, "nosplit", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccomand=split, with \\zs", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + {11:[No Name] [+] }| + |1| 1 2 3 | + |2| {12:OKO} B C | + |3| 4 5 6 | + |4| {12:OKO} Y Z | + | + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccomand=nosplit, with \\zs", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccomand=split, substitutions of different length", + function() + common_setup(screen, "split", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| T {12:123123} {12:22}T TTT {12:090804090}| + {12:804} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccomand=nosplit, substitutions of different length", function() + common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccomand=split, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "split", text) + feed(":%s/[QR]\\n") + screen:expect([[ + afa Q | + adf la;lkd R | + alx | + | + {15:~ }| + {11:[No Name] [+] }| + |3| afa Q | + |4| adf la;lkd R | + |5| alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n^ | + ]]) + + feed("/KKK") + screen:expect([[ + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccomand=nosplit, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "nosplit", text) + feed(":%s/[QR]\\n/KKK") + screen:expect([[ + T T123 T T123 T2T TT T23423424| + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccommand=split, multibyte text", function() + common_setup(screen, "split", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {11:[No Name] [+] }| + |1| {12:X¥¥} PEPPERS | + |2| {12:X¥¥} | + |3| a{12:X¥¥}¥KOL | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + {11:[No Name] [+] }| + |1| {12:X¥¥} | + |2|{12: a££ ¥} PEPPERS | + |3| {12:X¥¥} | + |4|{12: a££ ¥} | + |5| a{12:X¥¥} | + |6|{12: a££ ¥}¥KOL | + | + {10:[Preview] }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccommand=nosplit, multibyte text", function() + common_setup(screen, "nosplit", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} PEPPERS | + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:X¥¥} | + {12:a££ ¥} PEPPERS | + {12:X¥¥} | + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccomand=split, small cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=2") + + feed(":%s/[a-z]") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + a b c | + d e f | + q r s | + x y z | + £ m n | + t œ ¥ | + | + {11:[No Name] [+] }| + | 7| a b c | + | 8| d e f | + {10:[Preview] }| + :%s/[a-z]^ | + ]]) + + feed("/JLKR £") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + {12:JLKR £} b c | + {12:JLKR £} e f | + {12:JLKR £} r s | + {12:JLKR £} y z | + £ {12:JLKR £} n | + {12:JLKR £} œ ¥ | + | + {11:[No Name] [+] }| + | 7| {12:JLKR £} b c | + | 8| {12:JLKR £} e f | + {10:[Preview] }| + :%s/[a-z]/JLKR £^ | + ]]) + + feed("\\rѫ ab \\rXXXX") + screen:expect([[ + 7 8 9 | + K L M | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} b c | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} e f | + {12:JLKR £} | + {11:[No Name] [+] }| + | 7| {12:JLKR £} | + | 8|{12: ѫ ab } | + {10:[Preview] }| + :%s/[a-z]/JLKR £\rѫ ab \rXXX| + X^ | + ]]) + end) + + it(", inccomand=split, large cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=11") + + feed(":%s/. .$") + screen:expect([[ + t œ ¥ | + {11:[No Name] [+] }| + | 1| 1 2 3 | + | 2| A B C | + | 3| 4 5 6 | + | 4| X Y Z | + | 5| 7 8 9 | + | 6| K L M | + | 7| a b c | + | 8| d e f | + | 9| q r s | + |10| x y z | + |11| £ m n | + {10:[Preview] }| + :%s/. .$^ | + ]]) + + feed("/ YYY") + screen:expect([[ + t {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2| A {12: YYY} | + | 3| 4 {12: YYY} | + | 4| X {12: YYY} | + | 5| 7 {12: YYY} | + | 6| K {12: YYY} | + | 7| a {12: YYY} | + | 8| d {12: YYY} | + | 9| q {12: YYY} | + |10| x {12: YYY} | + |11| £ {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY^ | + ]]) + + feed("\\r KKK") + screen:expect([[ + a {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2|{12: KKK} | + | 3| A {12: YYY} | + | 4|{12: KKK} | + | 5| 4 {12: YYY} | + | 6|{12: KKK} | + | 7| X {12: YYY} | + | 8|{12: KKK} | + | 9| 7 {12: YYY} | + |10|{12: KKK} | + |11| K {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY\r KKK^ | + ]]) + end) + + it(", inccomand=split, lookaround", function() + common_setup(screen, "split", "something\neverything\nsomeone") + feed([[:%s/\(some\)\@=thing/one/]]) + screen:expect([[ + some{12:one} | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| some{12:one} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@<=thing/one/^ | + ]]) + feed("") + + feed([[:%s/\(some\)\@!thing/one/]]) + screen:expect([[ + something | + every{12:one} | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |2| every{12:one} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@]]) + + feed([[:%s/some\(thing\)\@=/every/]]) + screen:expect([[ + {12:every}thing | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:every}thing | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@=/every/^ | + ]]) + feed([[]]) + + feed([[:%s/some\(thing\)\@!/every/]]) + screen:expect([[ + everything | + {12:every}one | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| {12:every}one | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@!/every/^ | + ]]) + end) +end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index cc023ef10d..e22105b804 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -764,7 +764,7 @@ describe(":substitute, inccommand=split", function() feed("x") screen:expect([[ Inc substitution on | - xo lines | + {12:x}o lines | | {15:~ }| {15:~ }| @@ -805,7 +805,7 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw/XX") screen:expect([[ Inc substitution on | - XXo lines | + {12:XX}o lines | | {15:~ }| {15:~ }| @@ -894,7 +894,7 @@ describe(":substitute, inccommand=split", function() feed('M M M') feed(':%s/M/123/g') screen:expect([[ - 123 123 123 | + {12:123} {12:123} {12:123} | Inc substitution on | two lines | Inc substitution on | @@ -919,15 +919,15 @@ describe(":substitute, inccommand=split", function() insert(string.rep('abc abc abc\n', 20)) feed(':%s/abc/MMM/g') screen:expect([[ - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | {11:[No Name] [+] }| | 1| {12:MMM} {12:MMM} {12:MMM} | | 2| {12:MMM} {12:MMM} {12:MMM} | @@ -969,9 +969,9 @@ describe(":substitute, inccommand=split", function() screen:expect([[ BBo lines | Inc substitution on | - Xo lines | + {12:X}o lines | Inc substitution on | - Xo lines | + {12:X}o lines | {11:[No Name] [+] }| |1001| {12:X}o lines | |1003| {12:X}o lines | @@ -1069,8 +1069,8 @@ describe(":substitute, inccommand=split", function() feed(":1,2s/t/X") screen:expect([[ - Inc subsXitution on | - Xwo lines | + Inc subs{12:X}itution on | + {12:X}wo lines | Inc substitution on | two lines | | @@ -1134,7 +1134,7 @@ describe("inccommand=nosplit", function() two lines | Inc substitution on | two lines | - Line *.X | + Line *.{12:X} | {15:~ }| {15:~ }| {15:~ }| @@ -1150,7 +1150,7 @@ describe("inccommand=nosplit", function() two lines | Inc substitution on | two lines | - Line *.X here | + Line *.{12:X} here | {15:~ }| {15:~ }| {15:~ }| @@ -1198,9 +1198,9 @@ describe("inccommand=nosplit", function() feed("/BM") screen:expect([[ Inc substitution on | - BMo lines | + {12:BM}o lines | Inc substitution on | - BMo lines | + {12:BM}o lines | | {15:~ }| {15:~ }| @@ -1212,9 +1212,9 @@ describe("inccommand=nosplit", function() feed("/") screen:expect([[ Inc substitution on | - BMo lines | + {12:BM}o lines | Inc substitution on | - BMo lines | + {12:BM}o lines | | {15:~ }| {15:~ }| @@ -1245,8 +1245,8 @@ describe("inccommand=nosplit", function() feed(":1,2s/t/X") screen:expect([[ - Inc subsXitution on | - Xwo lines | + Inc subs{12:X}itution on | + {12:X}wo lines | Inc substitution on | two lines | | -- cgit From a4e4f2bd02b02975896ef62ec2abba8e15e85745 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 18 Sep 2017 22:47:09 +0200 Subject: Move tests into original file, lint, and add a test --- test/functional/ui/icmmulti_spec.lua | 692 --------------------------------- test/functional/ui/inccommand_spec.lua | 665 ++++++++++++++++++++++++++++++- 2 files changed, 664 insertions(+), 693 deletions(-) delete mode 100644 test/functional/ui/icmmulti_spec.lua (limited to 'test/functional/ui') diff --git a/test/functional/ui/icmmulti_spec.lua b/test/functional/ui/icmmulti_spec.lua deleted file mode 100644 index 81ceaec111..0000000000 --- a/test/functional/ui/icmmulti_spec.lua +++ /dev/null @@ -1,692 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local Screen = require('test.functional.ui.screen') -local clear = helpers.clear -local command = helpers.command -local curbufmeths = helpers.curbufmeths -local eq = helpers.eq -local eval = helpers.eval -local feed_command = helpers.feed_command -local expect = helpers.expect -local feed = helpers.feed -local insert = helpers.insert -local meths = helpers.meths -local neq = helpers.neq -local ok = helpers.ok -local source = helpers.source -local wait = helpers.wait -local nvim = helpers.nvim - -local multiline_text = [[ - 1 2 3 - A B C - 4 5 6 - X Y Z - 7 8 9 -]] - -local multimatch_text = [[ - a bdc eae a fgl lzia r - x -]] - -local multibyte_text = [[ - £ ¥ ѫѫ PEPPERS -£ ¥ ѫfѫ - a£ ѫ¥KOL -£ ¥ libm -£ ¥ -]] - -local long_multiline_text = [[ - 1 2 3 - A B C - 4 5 6 - X Y Z - 7 8 9 - K L M - a b c - d e f - q r s - x y z - £ m n - t œ ¥ -]] -local function common_setup(screen, inccommand, text) - if screen then - command("syntax on") - command("set nohlsearch") - command("hi Substitute guifg=red guibg=yellow") - screen:attach() - screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Fuchsia}, - [2] = {foreground = Screen.colors.Brown, bold = true}, - [3] = {foreground = Screen.colors.SlateBlue}, - [4] = {bold = true, foreground = Screen.colors.SlateBlue}, - [5] = {foreground = Screen.colors.DarkCyan}, - [6] = {bold = true}, - [7] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue}, - [8] = {foreground = Screen.colors.Slateblue, underline = true}, - [9] = {background = Screen.colors.Yellow}, - [10] = {reverse = true}, - [11] = {reverse = true, bold=true}, - [12] = {foreground = Screen.colors.Red, background = Screen.colors.Yellow}, - [13] = {bold = true, foreground = Screen.colors.SeaGreen}, - [14] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - [15] = {bold=true, foreground=Screen.colors.Blue}, - [16] = {background=Screen.colors.Grey90}, -- cursorline - vis = {background=Screen.colors.LightGrey} - }) - end - - command("set inccommand=" .. (inccommand and inccommand or "")) - - if text then - insert(text) - end -end - -describe(":substitute", function() - local screen = Screen.new(30,15) - - before_each(function() - clear() - end) - - it(", inccomand=split, highlights multiline substitutions", function() - common_setup(screen, "split", multiline_text) - feed("gg") - - feed(":%s/2\\_.*X/MMM") - screen:expect([[ - 1 {12:MMM} Y Z | - 7 8 9 | - | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |1| 1 {12:MMM} Y Z | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/2\_.*X/MMM^ | - ]]) - - feed("\\rK\\rLLL") - screen:expect([[ - 1 {12:MMM} | - {12:K} | - {12:LLL} Y Z | - 7 8 9 | - | - {11:[No Name] [+] }| - |1| 1 {12:MMM} | - |2|{12: K} | - |3|{12: LLL} Y Z | - | - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/2\_.*X/MMM\rK\rLLL^ | - ]]) - end) - - it(", inccomand=nosplit, highlights multiline substitutions", function() - common_setup(screen, "nosplit", multiline_text) - feed("gg") - - feed(":%s/2\\_.*X/MMM") - screen:expect([[ - 1 {12:MMM} Y Z | - 7 8 9 | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/2\_.*X/MMM^ | - ]]) - - feed("\\rK\\rLLL") - screen:expect([[ - 1 {12:MMM} | - {12:K} | - {12:LLL} Y Z | - 7 8 9 | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/2\_.*X/MMM\rK\rLLL^ | - ]]) - end) - - it(", inccomand=split, highlights multiple matches on a line", function() - common_setup(screen, "split", multimatch_text) - command("set gdefault") - feed("gg") - - feed(":%s/a/XLK") - screen:expect([[ - {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| - x | - | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| - {12:LK} r | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/a/XLK^ | - ]]) - end) - - it(", inccomand=nosplit, highlights multiple matches on a line", function() - common_setup(screen, "nosplit", multimatch_text) - command("set gdefault") - feed("gg") - - feed(":%s/a/XLK") - screen:expect([[ - {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| - x | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/a/XLK^ | - ]]) - end) - - it(", inccomand=split, with \\zs", function() - common_setup(screen, "split", multiline_text) - feed("gg") - - feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") - screen:expect([[ - 1 2 3 | - {12:OKO} B C | - 4 5 6 | - {12:OKO} Y Z | - 7 8 9 | - {11:[No Name] [+] }| - |1| 1 2 3 | - |2| {12:OKO} B C | - |3| 4 5 6 | - |4| {12:OKO} Y Z | - | - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/[0-9]\n\zs[A-Z]/OKO^ | - ]]) - end) - - it(", inccomand=nosplit, with \\zs", function() - common_setup(screen, "nosplit", multiline_text) - feed("gg") - - feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") - screen:expect([[ - 1 2 3 | - {12:OKO} B C | - 4 5 6 | - {12:OKO} Y Z | - 7 8 9 | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/[0-9]\n\zs[A-Z]/OKO^ | - ]]) - end) - - it(", inccomand=split, substitutions of different length", - function() - common_setup(screen, "split", "T T123 T2T TTT T090804\nx") - - feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") - screen:expect([[ - T {12:123123} {12:22}T TTT {12:090804090804} | - x | - {15:~ }| - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |1| T {12:123123} {12:22}T TTT {12:090804090}| - {12:804} | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/T\([0-9]\+\)/\1\1/g^ | - ]]) - end) - - it(", inccomand=nosplit, substitutions of different length", function() - common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx") - - feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") - screen:expect([[ - T {12:123123} {12:22}T TTT {12:090804090804} | - x | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/T\([0-9]\+\)/\1\1/g^ | - ]]) - end) - - it(", inccomand=split, contraction of lines", function() - local text = [[ - T T123 T T123 T2T TT T23423424 - x - afa Q - adf la;lkd R - alx - ]] - - common_setup(screen, "split", text) - feed(":%s/[QR]\\n") - screen:expect([[ - afa Q | - adf la;lkd R | - alx | - | - {15:~ }| - {11:[No Name] [+] }| - |3| afa Q | - |4| adf la;lkd R | - |5| alx | - | - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/[QR]\n^ | - ]]) - - feed("/KKK") - screen:expect([[ - x | - afa {12:KKK}adf la;lkd {12:KKK}alx | - | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |3| afa {12:KKK}adf la;lkd {12:KKK}alx | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/[QR]\n/KKK^ | - ]]) - end) - - it(", inccomand=nosplit, contraction of lines", function() - local text = [[ - T T123 T T123 T2T TT T23423424 - x - afa Q - adf la;lkd R - alx - ]] - - common_setup(screen, "nosplit", text) - feed(":%s/[QR]\\n/KKK") - screen:expect([[ - T T123 T T123 T2T TT T23423424| - x | - afa {12:KKK}adf la;lkd {12:KKK}alx | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/[QR]\n/KKK^ | - ]]) - end) - - it(", inccommand=split, multibyte text", function() - common_setup(screen, "split", multibyte_text) - feed(":%s/£.*ѫ/X¥¥") - screen:expect([[ - {12:X¥¥} | - a{12:X¥¥}¥KOL | - £ ¥ libm | - £ ¥ | - | - {11:[No Name] [+] }| - |1| {12:X¥¥} PEPPERS | - |2| {12:X¥¥} | - |3| a{12:X¥¥}¥KOL | - | - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/£.*ѫ/X¥¥^ | - ]]) - - feed("\\ra££ ¥") - screen:expect([[ - {12:a££ ¥} | - a{12:X¥¥} | - {12:a££ ¥}¥KOL | - £ ¥ libm | - £ ¥ | - {11:[No Name] [+] }| - |1| {12:X¥¥} | - |2|{12: a££ ¥} PEPPERS | - |3| {12:X¥¥} | - |4|{12: a££ ¥} | - |5| a{12:X¥¥} | - |6|{12: a££ ¥}¥KOL | - | - {10:[Preview] }| - :%s/£.*ѫ/X¥¥\ra££ ¥^ | - ]]) - end) - - it(", inccommand=nosplit, multibyte text", function() - common_setup(screen, "nosplit", multibyte_text) - feed(":%s/£.*ѫ/X¥¥") - screen:expect([[ - {12:X¥¥} PEPPERS | - {12:X¥¥} | - a{12:X¥¥}¥KOL | - £ ¥ libm | - £ ¥ | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/£.*ѫ/X¥¥^ | - ]]) - - feed("\\ra££ ¥") - screen:expect([[ - {12:X¥¥} | - {12:a££ ¥} PEPPERS | - {12:X¥¥} | - {12:a££ ¥} | - a{12:X¥¥} | - {12:a££ ¥}¥KOL | - £ ¥ libm | - £ ¥ | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :%s/£.*ѫ/X¥¥\ra££ ¥^ | - ]]) - end) - - it(", inccomand=split, small cmdwinheight", function() - common_setup(screen, "split", long_multiline_text) - command("set cmdwinheight=2") - - feed(":%s/[a-z]") - screen:expect([[ - X Y Z | - 7 8 9 | - K L M | - a b c | - d e f | - q r s | - x y z | - £ m n | - t œ ¥ | - | - {11:[No Name] [+] }| - | 7| a b c | - | 8| d e f | - {10:[Preview] }| - :%s/[a-z]^ | - ]]) - - feed("/JLKR £") - screen:expect([[ - X Y Z | - 7 8 9 | - K L M | - {12:JLKR £} b c | - {12:JLKR £} e f | - {12:JLKR £} r s | - {12:JLKR £} y z | - £ {12:JLKR £} n | - {12:JLKR £} œ ¥ | - | - {11:[No Name] [+] }| - | 7| {12:JLKR £} b c | - | 8| {12:JLKR £} e f | - {10:[Preview] }| - :%s/[a-z]/JLKR £^ | - ]]) - - feed("\\rѫ ab \\rXXXX") - screen:expect([[ - 7 8 9 | - K L M | - {12:JLKR £} | - {12:ѫ ab } | - {12:XXXX} b c | - {12:JLKR £} | - {12:ѫ ab } | - {12:XXXX} e f | - {12:JLKR £} | - {11:[No Name] [+] }| - | 7| {12:JLKR £} | - | 8|{12: ѫ ab } | - {10:[Preview] }| - :%s/[a-z]/JLKR £\rѫ ab \rXXX| - X^ | - ]]) - end) - - it(", inccomand=split, large cmdwinheight", function() - common_setup(screen, "split", long_multiline_text) - command("set cmdwinheight=11") - - feed(":%s/. .$") - screen:expect([[ - t œ ¥ | - {11:[No Name] [+] }| - | 1| 1 2 3 | - | 2| A B C | - | 3| 4 5 6 | - | 4| X Y Z | - | 5| 7 8 9 | - | 6| K L M | - | 7| a b c | - | 8| d e f | - | 9| q r s | - |10| x y z | - |11| £ m n | - {10:[Preview] }| - :%s/. .$^ | - ]]) - - feed("/ YYY") - screen:expect([[ - t {12: YYY} | - {11:[No Name] [+] }| - | 1| 1 {12: YYY} | - | 2| A {12: YYY} | - | 3| 4 {12: YYY} | - | 4| X {12: YYY} | - | 5| 7 {12: YYY} | - | 6| K {12: YYY} | - | 7| a {12: YYY} | - | 8| d {12: YYY} | - | 9| q {12: YYY} | - |10| x {12: YYY} | - |11| £ {12: YYY} | - {10:[Preview] }| - :%s/. .$/ YYY^ | - ]]) - - feed("\\r KKK") - screen:expect([[ - a {12: YYY} | - {11:[No Name] [+] }| - | 1| 1 {12: YYY} | - | 2|{12: KKK} | - | 3| A {12: YYY} | - | 4|{12: KKK} | - | 5| 4 {12: YYY} | - | 6|{12: KKK} | - | 7| X {12: YYY} | - | 8|{12: KKK} | - | 9| 7 {12: YYY} | - |10|{12: KKK} | - |11| K {12: YYY} | - {10:[Preview] }| - :%s/. .$/ YYY\r KKK^ | - ]]) - end) - - it(", inccomand=split, lookaround", function() - common_setup(screen, "split", "something\neverything\nsomeone") - feed([[:%s/\(some\)\@=thing/one/]]) - screen:expect([[ - some{12:one} | - everything | - someone | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |1| some{12:one} | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/\(some\)\@<=thing/one/^ | - ]]) - feed("") - - feed([[:%s/\(some\)\@!thing/one/]]) - screen:expect([[ - something | - every{12:one} | - someone | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |2| every{12:one} | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/\(some\)\@]]) - - feed([[:%s/some\(thing\)\@=/every/]]) - screen:expect([[ - {12:every}thing | - everything | - someone | - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |1| {12:every}thing | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/some\(thing\)\@=/every/^ | - ]]) - feed([[]]) - - feed([[:%s/some\(thing\)\@!/every/]]) - screen:expect([[ - everything | - {12:every}one | - {15:~ }| - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - |3| {12:every}one | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {10:[Preview] }| - :%s/some\(thing\)\@!/every/^ | - ]]) - end) -end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index e22105b804..25466974a9 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -21,6 +21,42 @@ local default_text = [[ two lines ]] +local multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 +]] + +local multimatch_text = [[ + a bdc eae a fgl lzia r + x +]] + +local multibyte_text = [[ + £ ¥ ѫѫ PEPPERS +£ ¥ ѫfѫ + a£ ѫ¥KOL +£ ¥ libm +£ ¥ +]] + +local long_multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 + K L M + a b c + d e f + q r s + x y z + £ m n + t œ ¥ +]] + local function common_setup(screen, inccommand, text) if screen then command("syntax on") @@ -1142,7 +1178,6 @@ describe("inccommand=nosplit", function() :%smagic/3.*/X^ | ]]) - feed([[]]) -- cancel feed(":%snomagic/3.*/X") -- start :snomagic command screen:expect([[ @@ -1178,6 +1213,28 @@ describe("inccommand=nosplit", function() feed('') end) + it("does not show window after toggling :set inccomand", function() + feed(":%s/tw/OKOK") + feed("") + command("set icm=split") + feed(":%s/tw/OKOK") + feed("") + command("set icm=nosplit") + feed(":%s/tw/OKOK") + screen:expect([[ + Inc substitution on | + {12:OKOK}o lines | + Inc substitution on | + {12:OKOK}o lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/tw/OKOK^ | + ]]) + end) + it('never shows preview buffer', function() feed_command("set hlsearch") @@ -1712,3 +1769,609 @@ describe("'inccommand' with 'gdefault'", function() eq({mode='n', blocking=false}, nvim("get_mode")) end) end) + +describe(":substitute", function() + local screen = Screen.new(30,15) + + before_each(function() + clear() + end) + + it(", inccomand=split, highlights multiline substitutions", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| 1 {12:MMM} Y Z | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {11:[No Name] [+] }| + |1| 1 {12:MMM} | + |2|{12: K} | + |3|{12: LLL} Y Z | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccomand=nosplit, highlights multiline substitutions", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccomand=split, highlights multiple matches on a line", function() + common_setup(screen, "split", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| + {12:LK} r | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccomand=nosplit, highlights multiple matches on a line", function() + common_setup(screen, "nosplit", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccomand=split, with \\zs", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + {11:[No Name] [+] }| + |1| 1 2 3 | + |2| {12:OKO} B C | + |3| 4 5 6 | + |4| {12:OKO} Y Z | + | + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccomand=nosplit, with \\zs", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccomand=split, substitutions of different length", + function() + common_setup(screen, "split", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| T {12:123123} {12:22}T TTT {12:090804090}| + {12:804} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccomand=nosplit, substitutions of different length", function() + common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccomand=split, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "split", text) + feed(":%s/[QR]\\n") + screen:expect([[ + afa Q | + adf la;lkd R | + alx | + | + {15:~ }| + {11:[No Name] [+] }| + |3| afa Q | + |4| adf la;lkd R | + |5| alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n^ | + ]]) + + feed("/KKK") + screen:expect([[ + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccomand=nosplit, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "nosplit", text) + feed(":%s/[QR]\\n/KKK") + screen:expect([[ + T T123 T T123 T2T TT T23423424| + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccommand=split, multibyte text", function() + common_setup(screen, "split", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {11:[No Name] [+] }| + |1| {12:X¥¥} PEPPERS | + |2| {12:X¥¥} | + |3| a{12:X¥¥}¥KOL | + | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + {11:[No Name] [+] }| + |1| {12:X¥¥} | + |2|{12: a££ ¥} PEPPERS | + |3| {12:X¥¥} | + |4|{12: a££ ¥} | + |5| a{12:X¥¥} | + |6|{12: a££ ¥}¥KOL | + | + {10:[Preview] }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccommand=nosplit, multibyte text", function() + common_setup(screen, "nosplit", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} PEPPERS | + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:X¥¥} | + {12:a££ ¥} PEPPERS | + {12:X¥¥} | + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccomand=split, small cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=2") + + feed(":%s/[a-z]") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + a b c | + d e f | + q r s | + x y z | + £ m n | + t œ ¥ | + | + {11:[No Name] [+] }| + | 7| a b c | + | 8| d e f | + {10:[Preview] }| + :%s/[a-z]^ | + ]]) + + feed("/JLKR £") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + {12:JLKR £} b c | + {12:JLKR £} e f | + {12:JLKR £} r s | + {12:JLKR £} y z | + £ {12:JLKR £} n | + {12:JLKR £} œ ¥ | + | + {11:[No Name] [+] }| + | 7| {12:JLKR £} b c | + | 8| {12:JLKR £} e f | + {10:[Preview] }| + :%s/[a-z]/JLKR £^ | + ]]) + + feed("\\rѫ ab \\rXXXX") + screen:expect([[ + 7 8 9 | + K L M | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} b c | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} e f | + {12:JLKR £} | + {11:[No Name] [+] }| + | 7| {12:JLKR £} | + | 8|{12: ѫ ab } | + {10:[Preview] }| + :%s/[a-z]/JLKR £\rѫ ab \rXXX| + X^ | + ]]) + end) + + it(", inccomand=split, large cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=11") + + feed(":%s/. .$") + screen:expect([[ + t œ ¥ | + {11:[No Name] [+] }| + | 1| 1 2 3 | + | 2| A B C | + | 3| 4 5 6 | + | 4| X Y Z | + | 5| 7 8 9 | + | 6| K L M | + | 7| a b c | + | 8| d e f | + | 9| q r s | + |10| x y z | + |11| £ m n | + {10:[Preview] }| + :%s/. .$^ | + ]]) + + feed("/ YYY") + screen:expect([[ + t {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2| A {12: YYY} | + | 3| 4 {12: YYY} | + | 4| X {12: YYY} | + | 5| 7 {12: YYY} | + | 6| K {12: YYY} | + | 7| a {12: YYY} | + | 8| d {12: YYY} | + | 9| q {12: YYY} | + |10| x {12: YYY} | + |11| £ {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY^ | + ]]) + + feed("\\r KKK") + screen:expect([[ + a {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2|{12: KKK} | + | 3| A {12: YYY} | + | 4|{12: KKK} | + | 5| 4 {12: YYY} | + | 6|{12: KKK} | + | 7| X {12: YYY} | + | 8|{12: KKK} | + | 9| 7 {12: YYY} | + |10|{12: KKK} | + |11| K {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY\r KKK^ | + ]]) + end) + + it(", inccomand=split, lookaround", function() + common_setup(screen, "split", "something\neverything\nsomeone") + feed([[:%s/\(some\)\@=thing/one/]]) + screen:expect([[ + some{12:one} | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| some{12:one} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@<=thing/one/^ | + ]]) + feed("") + + feed([[:%s/\(some\)\@!thing/one/]]) + screen:expect([[ + something | + every{12:one} | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |2| every{12:one} | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@]]) + + feed([[:%s/some\(thing\)\@=/every/]]) + screen:expect([[ + {12:every}thing | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:every}thing | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@=/every/^ | + ]]) + feed([[]]) + + feed([[:%s/some\(thing\)\@!/every/]]) + screen:expect([[ + everything | + {12:every}one | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| {12:every}one | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@!/every/^ | + ]]) + end) +end) -- cgit From be20b20cf3a845abf8e62f005a9ccbb0cde03e7d Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 23 Sep 2017 22:57:43 +0200 Subject: Adjust tests for the new preview window ... that does not have that superflous last line. Also, remove some indeterminism for the freebsd64 tests. Partially, those were suggested by the tests themselves, while successfull. Some of them were added after some testing because the lookaround test would fail on freebsd64 only. --- test/functional/ui/inccommand_spec.lua | 60 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 25466974a9..9196e0548e 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -725,7 +725,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] }| |2| two lines | |4| two lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -767,7 +767,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| two lines | |4| two lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -788,7 +788,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -807,7 +807,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:x}o lines | |4| {12:x}o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -826,7 +826,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -848,7 +848,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:XX}o lines | |4| {12:XX}o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -915,7 +915,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {9:tw}o lines | |4| {9:tw}o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -937,7 +937,7 @@ describe(":substitute, inccommand=split", function() two lines | {11:[No Name] [+] }| |1| {12:123} {12:123} {12:123} | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1113,7 +1113,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:X}itution on | |2| {12:X}wo lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1221,6 +1221,7 @@ describe("inccommand=nosplit", function() feed("") command("set icm=nosplit") feed(":%s/tw/OKOK") + wait() screen:expect([[ Inc substitution on | {12:OKOK}o lines | @@ -1641,7 +1642,7 @@ describe("'inccommand' split windows", function() {15:~ }{10:|}{15:~ }| {10:[No Name] [+] [No Name] [+] }| |2| two lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1680,7 +1681,7 @@ describe("'inccommand' split windows", function() {15:~ }| {10:[No Name] [+] }| |2| two lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1730,7 +1731,7 @@ describe("'inccommand' split windows", function() {15:~ }| {11:[No Name] [+] }| |2| two lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1790,7 +1791,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |1| 1 {12:MMM} Y Z | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1811,7 +1812,7 @@ describe(":substitute", function() |1| 1 {12:MMM} | |2|{12: K} | |3|{12: LLL} Y Z | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1878,7 +1879,7 @@ describe(":substitute", function() {11:[No Name] [+] }| |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| {12:LK} r | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1929,7 +1930,7 @@ describe(":substitute", function() |2| {12:OKO} B C | |3| 4 5 6 | |4| {12:OKO} Y Z | - | + {15:~ }| {15:~ }| {15:~ }| {10:[Preview] }| @@ -1975,7 +1976,7 @@ describe(":substitute", function() {11:[No Name] [+] }| |1| T {12:123123} {12:22}T TTT {12:090804090}| {12:804} | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2029,7 +2030,7 @@ describe(":substitute", function() |3| afa Q | |4| adf la;lkd R | |5| alx | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2046,7 +2047,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |3| afa {12:KKK}adf la;lkd {12:KKK}alx | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2100,7 +2101,7 @@ describe(":substitute", function() |1| {12:X¥¥} PEPPERS | |2| {12:X¥¥} | |3| a{12:X¥¥}¥KOL | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2122,7 +2123,7 @@ describe(":substitute", function() |4|{12: a££ ¥} | |5| a{12:X¥¥} | |6|{12: a££ ¥}¥KOL | - | + {15:~ }| {10:[Preview] }| :%s/£.*ѫ/X¥¥\ra££ ¥^ | ]]) @@ -2304,7 +2305,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |1| some{12:one} | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2313,8 +2314,9 @@ describe(":substitute", function() {10:[Preview] }| :%s/\(some\)\@<=thing/one/^ | ]]) - feed("") + feed("") + wait() feed([[:%s/\(some\)\@!thing/one/]]) screen:expect([[ something | @@ -2324,7 +2326,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |2| every{12:one} | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2333,8 +2335,9 @@ describe(":substitute", function() {10:[Preview] }| :%s/\(some\)\@]]) + feed([[]]) + wait() feed([[:%s/some\(thing\)\@=/every/]]) screen:expect([[ {12:every}thing | @@ -2344,7 +2347,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |1| {12:every}thing | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -2353,8 +2356,9 @@ describe(":substitute", function() {10:[Preview] }| :%s/some\(thing\)\@=/every/^ | ]]) - feed([[]]) + feed([[]]) + wait() feed([[:%s/some\(thing\)\@!/every/]]) screen:expect([[ everything | @@ -2364,7 +2368,7 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |3| {12:every}one | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| -- cgit From ab942b7ffb08ffa2f7f417916d8f0a509fd39af4 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 30 Sep 2017 23:20:40 +0200 Subject: Test for clearing the highlight --- test/functional/ui/inccommand_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 9196e0548e..da0f05bf07 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -948,6 +948,28 @@ describe(":substitute, inccommand=split", function() ]]) end) + it('highlights nothing when there\'s no match', function() + feed('gg') + feed(':%s/Inx') + screen:expect([[ + Inc substitution on | + two lines | + Inc substitution on | + two lines | + | + {11:[No Name] [+] }| + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/Inx^ | + ]]) + end) + it('previews correctly when previewhight is small', function() feed_command('set cwh=3') feed_command('set hls') -- cgit From 369ac900f97059de21d946aa460d4ef2b6899b3e Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 24 Sep 2017 13:57:47 +0200 Subject: Adjust tests for new highlighting. Also extend an old test to show of the new way. --- test/functional/ui/inccommand_spec.lua | 113 +++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 47 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index da0f05bf07..88de2f07de 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -718,13 +718,13 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {11:[No Name] }| - |2| two lines | - |4| two lines | + |2| {12:tw}o lines | + |4| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -760,13 +760,13 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {11:[No Name] [+] }| - |2| two lines | - |4| two lines | + |2| {12:tw}o lines | + |4| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -864,7 +864,7 @@ describe(":substitute, inccommand=split", function() screen:sleep(1) screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | Inc substitution on | two lines | | @@ -908,13 +908,13 @@ describe(":substitute, inccommand=split", function() -- 'cursorline' is NOT active during preview. screen:expect([[ Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | | {11:[No Name] [+] }| - |2| {9:tw}o lines | - |4| {9:tw}o lines | + |2| {12:tw}o lines | + |4| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -1264,9 +1264,9 @@ describe("inccommand=nosplit", function() feed(":%s/tw") screen:expect([[ Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | | {15:~ }| {15:~ }| @@ -1643,7 +1643,7 @@ describe("'inccommand' split windows", function() feed(":%s/tw") screen:expect([[ Inc substitution on {10:|}Inc substitution on| - two lines {10:|}two lines | + {12:tw}o lines {10:|}{12:tw}o lines | {10:|} | {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| @@ -1658,12 +1658,12 @@ describe("'inccommand' split windows", function() {15:~ }{10:|}{15:~ }| {11:[No Name] [+] }{10:|}{15:~ }| Inc substitution on {10:|}{15:~ }| - two lines {10:|}{15:~ }| + {12:tw}o lines {10:|}{15:~ }| {10:|}{15:~ }| {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| {10:[No Name] [+] [No Name] [+] }| - |2| two lines | + |2| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -1682,7 +1682,7 @@ describe("'inccommand' split windows", function() feed(":%s/tw") screen:expect([[ Inc substitution on {10:|}Inc substitution on| - two lines {10:|}two lines | + {12:tw}o lines {10:|}{12:tw}o lines | {10:|} | {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| @@ -1697,12 +1697,12 @@ describe("'inccommand' split windows", function() {15:~ }{10:|}{15:~ }| {11:[No Name] [+] }{10:[No Name] [+] }| Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {10:[No Name] [+] }| - |2| two lines | + |2| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -1732,7 +1732,7 @@ describe("'inccommand' split windows", function() screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| @@ -1752,7 +1752,7 @@ describe("'inccommand' split windows", function() {15:~ }| {15:~ }| {11:[No Name] [+] }| - |2| two lines | + |2| {12:tw}o lines | {15:~ }| {15:~ }| {15:~ }| @@ -1804,7 +1804,26 @@ describe(":substitute", function() common_setup(screen, "split", multiline_text) feed("gg") - feed(":%s/2\\_.*X/MMM") + feed(":%s/2\\_.*X") + screen:expect([[ + 1 {12:2 3} | + {12:A B C} | + {12:4 5 6} | + {12:X} Y Z | + 7 8 9 | + {11:[No Name] [+] }| + |1| 1 {12:2 3} | + |2|{12: A B C} | + |3|{12: 4 5 6} | + |4|{12: X} Y Z | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X^ | + ]]) + + feed("/MMM") screen:expect([[ 1 {12:MMM} Y Z | 7 8 9 | @@ -2043,15 +2062,15 @@ describe(":substitute", function() common_setup(screen, "split", text) feed(":%s/[QR]\\n") screen:expect([[ - afa Q | - adf la;lkd R | + afa {12:Q} | + adf la;lkd {12:R} | alx | | {15:~ }| {11:[No Name] [+] }| - |3| afa Q | - |4| adf la;lkd R | - |5| alx | + |3| afa {12:Q} | + |4|{12: }adf la;lkd {12:R} | + |5|{12: }alx | {15:~ }| {15:~ }| {15:~ }| @@ -2201,16 +2220,16 @@ describe(":substitute", function() X Y Z | 7 8 9 | K L M | - a b c | - d e f | - q r s | - x y z | - £ m n | - t œ ¥ | + {12:a} b c | + {12:d} e f | + {12:q} r s | + {12:x} y z | + £ {12:m} n | + {12:t} œ ¥ | | {11:[No Name] [+] }| - | 7| a b c | - | 8| d e f | + | 7| {12:a} b c | + | 8| {12:d} e f | {10:[Preview] }| :%s/[a-z]^ | ]]) @@ -2260,19 +2279,19 @@ describe(":substitute", function() feed(":%s/. .$") screen:expect([[ - t œ ¥ | + t {12:œ ¥} | {11:[No Name] [+] }| - | 1| 1 2 3 | - | 2| A B C | - | 3| 4 5 6 | - | 4| X Y Z | - | 5| 7 8 9 | - | 6| K L M | - | 7| a b c | - | 8| d e f | - | 9| q r s | - |10| x y z | - |11| £ m n | + | 1| 1 {12:2 3} | + | 2| A {12:B C} | + | 3| 4 {12:5 6} | + | 4| X {12:Y Z} | + | 5| 7 {12:8 9} | + | 6| K {12:L M} | + | 7| a {12:b c} | + | 8| d {12:e f} | + | 9| q {12:r s} | + |10| x {12:y z} | + |11| £ {12:m n} | {10:[Preview] }| :%s/. .$^ | ]]) -- cgit From 4daf63871adc2713ded2a6b8c07fe0ac4b6b3fc1 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 29 Oct 2017 18:21:26 +0100 Subject: Fix cmd modifier tests for the new highlight --- test/functional/ui/inccommand_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 88de2f07de..ceb2c83dd9 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -740,13 +740,13 @@ describe(":substitute, inccommand=split", function() it("shows preview when cmd modifiers are present", function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('') screen:expect([[two lines]], nil, nil, nil, true) -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('') screen:expect([[two lines]], nil, nil, nil, true) @@ -1219,13 +1219,13 @@ describe("inccommand=nosplit", function() it("shows preview when cmd modifiers are present", function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('') screen:expect([[two lines]], nil, nil, nil, true) -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('') screen:expect([[two lines]], nil, nil, nil, true) -- cgit From 04b3c327723587fa63f391884b8dfce44233cc77 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 5 Nov 2017 17:11:44 +0100 Subject: 'inccommand': Fix matches for zero-width (#7487) closes #7485 --- test/functional/ui/inccommand_spec.lua | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6646e65bad..53fd17c309 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -1791,6 +1791,42 @@ describe("'inccommand' with 'gdefault'", function() expect("A\nA") eq({mode='n', blocking=false}, nvim("get_mode")) end) + + it("does not crash on zero-width matches #7485", function() + common_setup(nil, "split", default_text) + command("set gdefault") + feed("gg") + feed("Vj") + feed(":s/\\%V") + eq({mode='c', blocking=false}, nvim("get_mode")) + feed("") + eq({mode='n', blocking=false}, nvim("get_mode")) + end) + + it("removes highlights after abort for a zero-width match", function() + local screen = Screen.new(30,5) + common_setup(screen, "nosplit", default_text) + command("set gdefault") + + feed(":%s/\\%1c/a/") + screen:expect([[ + {12:a}Inc substitution on | + {12:a}two lines | + {12:a} | + {15:~ }| + :%s/\%1c/a/^ | + ]]) + + feed("") + screen:expect([[ + Inc substitution on | + two lines | + ^ | + {15:~ }| + | + ]]) + end) + end) describe(":substitute", function() -- cgit