diff options
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 73 | ||||
-rw-r--r-- | test/functional/ui/syntax_conceal_spec.lua | 496 |
2 files changed, 567 insertions, 2 deletions
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index c531f838c1..3890f0f7ba 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -741,10 +741,11 @@ describe('ui/mouse/input', function() screen:set_default_attr_ids({ [0] = {bold=true, foreground=Screen.colors.Blue}, c = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + sm = {bold = true}, }) feed('ggdG') - feed_command('set concealcursor=n') + feed_command('set concealcursor=ni') feed_command('set nowrap') feed_command('set shiftwidth=2 tabstop=4 list listchars=tab:>-') feed_command('syntax match NonText "\\*" conceal') @@ -973,6 +974,76 @@ describe('ui/mouse/input', function() ]]) end) -- level 2 - non wrapped + it('(level 2) click on non-wrapped lines (insert mode)', function() + feed_command('let &conceallevel=2', 'echo') + + feed('<esc>i<LeftMouse><20,0>') + screen:expect([[ + Section{0:>>--->--->---}^t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + + feed('<LeftMouse><14,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} ^t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + + feed('<LeftMouse><18,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t^3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + + feed('<LeftMouse><0,2>') -- Weirdness + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + + feed('<LeftMouse><8,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + + feed('<LeftMouse><20,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + {sm:-- INSERT --} | + ]]) + end) -- level 2 - non wrapped (insert mode) + it('(level 2) click on wrapped lines', function() feed_command('let &conceallevel=2', 'let &wrap=1', 'echo') diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index e7a7004c1e..d678784dc9 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -12,7 +12,11 @@ describe('Screen', function() screen:attach() screen:set_default_attr_ids( { [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray} + [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}, + [2] = {bold = true, reverse = true}, + [3] = {reverse = true}, + [4] = {bold = true}, + [5] = {background = Screen.colors.Yellow}, } ) end) @@ -329,4 +333,494 @@ describe('Screen', function() ]]) end) end) -- conceallevel + + + describe("cursor movement", function() + before_each(function() + command("syn keyword concealy barf conceal cchar=b") + command("set cole=2") + feed('5Ofoo barf bar barf eggs<esc>') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo barf bar barf egg^s | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + end) + + it('between windows', function() + command("split") + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo barf bar barf egg^s | + | + {2:[No Name] [+] }| + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {3:[No Name] [+] }| + | + ]]) + feed('<c-w>w') + + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {3:[No Name] [+] }| + foo {1:b} bar {1:b} eggs | + foo barf bar barf egg^s | + | + {2:[No Name] [+] }| + | + ]]) + end) + + it('in insert mode', function() + feed('i') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo barf bar barf egg^s | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + + feed('<up>') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo barf bar barf egg^s | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + end) + + it('between modes cocu=iv', function() + command('set cocu=iv') + feed('gg') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + feed('i') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + feed('v') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- VISUAL --} | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + end) + + it('between modes cocu=n', function() + command('set cocu=n') + feed('gg') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + feed('i') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + + feed('v') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + {4:-- VISUAL --} | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('and open line', function() + feed('o') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + ^ | + | + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + end) + + it('and open line cocu=i', function() + command('set cocu=i') + feed('o') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + ^ | + | + {0:~ }| + {0:~ }| + {4:-- INSERT --} | + ]]) + end) + + describe('with incsearch', function() + before_each(function() + command('set incsearch hlsearch') + feed('2GA x<esc>3GA xy<esc>gg') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('cocu=', function() + feed('/') + screen:expect([[ + foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + + feed('x') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo barf bar barf eggs {3:x} | + foo {1:b} bar {1:b} eggs {5:x}y | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /x^ | + ]]) + + feed('y') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo barf bar barf eggs {3:xy} | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /xy^ | + ]]) + + feed('<c-w>') + screen:expect([[ + foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + end) + + it('cocu=c', function() + command('set cocu=c') + + feed('/') + -- NB: we don't do this redraw. Probably best to still skip it, + -- to avoid annoying distraction from the cmdline + screen:expect([[ + foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + + feed('x') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs {3:x} | + foo {1:b} bar {1:b} eggs {5:x}y | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /x^ | + ]]) + + feed('y') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs {3:xy} | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /xy^ | + ]]) + + feed('<c-w>') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('cocu=n', function() + command('set cocu=n') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + feed('/') + -- NB: we don't do this redraw. Probably best to still skip it, + -- to avoid annoying distraction from the cmdline + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + + feed('x') + screen:expect([[ + foo {1:b} bar {1:b} eggs | + foo barf bar barf eggs {3:x} | + foo {1:b} bar {1:b} eggs {5:x}y | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /x^ | + ]]) + + feed('<c-w>') + screen:expect([[ + foo barf bar barf eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]]) + + feed('<esc>') + screen:expect([[ + ^foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs x | + foo {1:b} bar {1:b} eggs xy | + foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs | + | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + end) + end) end) |