diff options
Diffstat (limited to 'test/functional/ui/mouse_spec.lua')
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 1077 |
1 files changed, 955 insertions, 122 deletions
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index a433143266..8d35df6f48 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1,42 +1,38 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths -local insert, execute = helpers.insert, helpers.execute +local insert, feed_command = helpers.insert, helpers.feed_command local eq, funcs = helpers.eq, helpers.funcs +local command = helpers.command -describe('Mouse input', function() +describe('ui/mouse/input', function() local screen - local hlgroup_colors = { - NonText = Screen.colors.Blue, - Visual = Screen.colors.LightGrey - } - before_each(function() clear() meths.set_option('mouse', 'a') meths.set_option('listchars', 'eol:$') - -- set mouset to very high value to ensure that even in valgrind/travis, - -- nvim will still pick multiple clicks - meths.set_option('mouset', 5000) screen = Screen.new(25, 5) screen:attach() screen:set_default_attr_ids({ - [1] = {background = hlgroup_colors.Visual}, + [0] = {bold=true, foreground=Screen.colors.Blue}, + [1] = {background = Screen.colors.LightGrey}, [2] = {bold = true}, [3] = { - foreground = hlgroup_colors.NonText, - background = hlgroup_colors.Visual, + foreground = Screen.colors.Blue, + background = Screen.colors.LightGrey, bold = true, }, + [4] = {reverse = true}, + [5] = {bold = true, reverse = true}, }) - screen:set_default_attr_ignore( {{bold=true, foreground=hlgroup_colors.NonText}} ) + command("set display-=msgsep") feed('itesting<cr>mouse<cr>support and selection<esc>') screen:expect([[ testing | mouse | support and selectio^n | - ~ | + {0:~ }| | ]]) end) @@ -45,13 +41,13 @@ describe('Mouse input', function() screen:detach() end) - it('left click moves cursor', function() + it('single left click moves cursor', function() feed('<LeftMouse><2,1>') screen:expect([[ testing | mo^use | support and selection | - ~ | + {0:~ }| | ]]) feed('<LeftMouse><0,0>') @@ -59,95 +55,368 @@ describe('Mouse input', function() ^testing | mouse | support and selection | - ~ | + {0:~ }| | ]]) end) + it('double left click enters visual mode', function() + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + screen:expect([[ + {1:testin}^g | + mouse | + support and selection | + {0:~ }| + {2:-- VISUAL --} | + ]]) + end) + + it('triple left click enters visual line mode', function() + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + screen:expect([[ + ^t{1:esting}{3: } | + mouse | + support and selection | + {0:~ }| + {2:-- VISUAL LINE --} | + ]]) + end) + + it('quadruple left click enters visual block mode', function() + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + feed('<LeftMouse><0,0>') + feed('<LeftRelease><0,0>') + screen:expect([[ + ^testing | + mouse | + support and selection | + {0:~ }| + {2:-- VISUAL BLOCK --} | + ]]) + end) + + describe('tab drag', function() + before_each(function() + screen:set_default_attr_ids( { + [0] = {bold=true, foreground=Screen.colors.Blue}, + tab = { background=Screen.colors.LightGrey, underline=true }, + sel = { bold=true }, + fill = { reverse=true } + }) + end) + + it('in tabline on filler space moves tab to the end', function() + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><4,0>') + screen:expect([[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftDrag><14,0>') + screen:expect([[ + {tab: + bar }{sel: + foo }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('in tabline to the left moves tab left', function() + if helpers.skip_fragile(pending, + os.getenv("TRAVIS") and (helpers.os_name() == "osx" + or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN")) -- #4874 + then + return + end + + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><11,0>') + screen:expect{grid=[[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]], unchanged=true} + feed('<LeftDrag><6,0>') + screen:expect([[ + {sel: + bar }{tab: + foo }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('in tabline to the right moves tab right', function() + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><4,0>') + screen:expect([[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftDrag><7,0>') + screen:expect([[ + {tab: + bar }{sel: + foo }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('out of tabline under filler space moves tab to the end', function() + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><4,0>') + screen:expect([[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftDrag><4,1>') + screen:expect{grid=[[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]], unchanged=true} + feed('<LeftDrag><14,1>') + screen:expect([[ + {tab: + bar }{sel: + foo }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('out of tabline to the left moves tab left', function() + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><11,0>') + screen:expect{grid=[[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]], unchanged=true} + feed('<LeftDrag><11,1>') + screen:expect{grid=[[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]], unchanged=true} + feed('<LeftDrag><6,1>') + screen:expect([[ + {sel: + bar }{tab: + foo }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + end) + + it('out of tabline to the right moves tab right', function() + feed_command('%delete') + insert('this is foo') + feed_command('silent file foo | tabnew | file bar') + insert('this is bar') + screen:expect([[ + {tab: + foo }{sel: + bar }{fill: }{tab:X}| + this is ba^r | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftMouse><4,0>') + screen:expect([[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + feed('<LeftDrag><4,1>') + screen:expect{grid=[[ + {sel: + foo }{tab: + bar }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]], unchanged=true} + feed('<LeftDrag><7,1>') + screen:expect([[ + {tab: + bar }{sel: + foo }{fill: }{tab:X}| + this is fo^o | + {0:~ }| + {0:~ }| + | + ]]) + end) + end) + describe('tabline', function() - local tab_attrs = { - tab = { background=Screen.colors.LightGrey, underline=true }, - sel = { bold=true }, - fill = { reverse=true } - } + before_each(function() + screen:set_default_attr_ids( { + [0] = {bold=true, foreground=Screen.colors.Blue}, + tab = { background=Screen.colors.LightGrey, underline=true }, + sel = { bold=true }, + fill = { reverse=true } + }) + end) it('left click in default tabline (position 4) switches to tab', function() - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r | - ~ | - ~ | + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - ~ | - ~ | + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) end) it('left click in default tabline (position 24) closes tab', function() meths.set_option('hidden', true) - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r | - ~ | - ~ | + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) feed('<LeftMouse><24,0>') screen:expect([[ this is fo^o | - ~ | - ~ | - ~ | + {0:~ }| + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) end) it('double click in default tabline (position 4) opens new tab', function() meths.set_option('hidden', true) - execute('%delete') + feed_command('%delete') insert('this is foo') - execute('silent file foo | tabnew | file bar') + feed_command('silent file foo | tabnew | file bar') insert('this is bar') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r | - ~ | - ~ | + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) feed('<2-LeftMouse><4,0>') screen:expect([[ {sel: Name] }{tab: + foo + bar }{fill: }{tab:X}| ^ | - ~ | - ~ | + {0:~ }| + {0:~ }| | - ]], tab_attrs) + ]]) end) describe('%@ label', function() before_each(function() - execute([[ + feed_command([[ function Test(...) let g:reply = a:000 return copy(a:000) " Check for memory leaks: return should be freed endfunction ]]) - execute([[ + feed_command([[ function Test2(...) return call('Test', a:000 + [2]) endfunction @@ -158,9 +427,9 @@ describe('Mouse input', function() {fill:test-test2 }| mouse | support and selectio^n | - ~ | + {0:~ }| | - ]], tab_attrs) + ]]) meths.set_var('reply', {}) end) @@ -216,7 +485,7 @@ describe('Mouse input', function() testing | mo^use | support and selection | - ~ | + {0:~ }| | ]]) feed('<LeftDrag><4,1>') @@ -224,7 +493,7 @@ describe('Mouse input', function() testing | mo{1:us}^e | support and selection | - ~ | + {0:~ }| {2:-- VISUAL --} | ]]) feed('<LeftDrag><2,2>') @@ -232,7 +501,7 @@ describe('Mouse input', function() testing | mo{1:use}{3: } | {1:su}^pport and selection | - ~ | + {0:~ }| {2:-- VISUAL --} | ]]) feed('<LeftDrag><0,0>') @@ -240,46 +509,47 @@ describe('Mouse input', function() ^t{1:esting}{3: } | {1:mou}se | support and selection | - ~ | + {0:~ }| {2:-- VISUAL --} | ]]) end) it('left drag changes visual selection after tab click', function() - local tab_attrs = { + screen:set_default_attr_ids({ + [0] = {bold=true, foreground=Screen.colors.Blue}, tab = { background=Screen.colors.LightGrey, underline=true }, sel = { bold=true }, fill = { reverse=true }, vis = { background=Screen.colors.LightGrey } - } - execute('silent file foo | tabnew | file bar') + }) + feed_command('silent file foo | tabnew | file bar') insert('this is bar') - execute('tabprevious') -- go to first tab + feed_command('tabprevious') -- go to first tab screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| mouse | support and selectio^n | - ~ | - | - ]], tab_attrs) + {0:~ }| + :tabprevious | + ]]) feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab helpers.wait() feed('<LeftMouse><0,1>') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| ^this is bar | - ~ | - ~ | - | - ]], tab_attrs) + {0:~ }| + {0:~ }| + :tabprevious | + ]]) feed('<LeftDrag><4,1>') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| {vis:this}^ is bar | - ~ | - ~ | + {0:~ }| + {0:~ }| {sel:-- VISUAL --} | - ]], tab_attrs) + ]]) end) it('two clicks will select the word and enter VISUAL', function() @@ -288,7 +558,7 @@ describe('Mouse input', function() testing | mouse | {1:suppor}^t and selection | - ~ | + {0:~ }| {2:-- VISUAL --} | ]]) end) @@ -299,7 +569,7 @@ describe('Mouse input', function() testing | mouse | {1:su}^p{1:port and selection}{3: } | - ~ | + {0:~ }| {2:-- VISUAL LINE --} | ]]) end) @@ -310,7 +580,7 @@ describe('Mouse input', function() testing | mouse | su^pport and selection | - ~ | + {0:~ }| {2:-- VISUAL BLOCK --} | ]]) end) @@ -321,7 +591,7 @@ describe('Mouse input', function() ^testing | mouse | support and selection | - ~ | + {0:~ }| | ]]) feed('<RightMouse><2,2>') @@ -329,7 +599,7 @@ describe('Mouse input', function() {1:testing}{3: } | {1:mouse}{3: } | {1:su}^pport and selection | - ~ | + {0:~ }| {2:-- VISUAL --} | ]]) end) @@ -360,79 +630,78 @@ describe('Mouse input', function() mouse scrolling ]]) screen:try_resize(53, 14) - execute('sp', 'vsp') - screen:set_default_attr_ignore( {{bold=true, foreground=hlgroup_colors.NonText}, - {reverse=true}, {bold=true, reverse=true}} ) + feed_command('sp', 'vsp') screen:expect([[ - lines |lines | - to |to | - test |test | - mouse scrolling |mouse scrolling | - ^ | | - ~ |~ | - [No Name] [+] [No Name] [+] | + lines {4:│}lines | + to {4:│}to | + test {4:│}test | + mouse scrolling {4:│}mouse scrolling | + ^ {4:│} | + {0:~ }{4:│}{0:~ }| + {5:[No Name] [+] }{4:[No Name] [+] }| to | test | mouse scrolling | | - ~ | - [No Name] [+] | + {0:~ }| + {4:[No Name] [+] }| :vsp | ]]) - feed('<MouseUp><0,0>') + feed('<ScrollWheelDown><0,0>') screen:expect([[ - mouse scrolling |lines | - ^ |to | - ~ |test | - ~ |mouse scrolling | - ~ | | - ~ |~ | - [No Name] [+] [No Name] [+] | + mouse scrolling {4:│}lines | + ^ {4:│}to | + {0:~ }{4:│}test | + {0:~ }{4:│}mouse scrolling | + {0:~ }{4:│} | + {0:~ }{4:│}{0:~ }| + {5:[No Name] [+] }{4:[No Name] [+] }| to | test | mouse scrolling | | - ~ | - [No Name] [+] | - | + {0:~ }| + {4:[No Name] [+] }| + :vsp | ]]) - feed('<MouseDown><27,0>') + feed('<ScrollWheelUp><27,0>') screen:expect([[ - mouse scrolling |text | - ^ |with | - ~ |many | - ~ |lines | - ~ |to | - ~ |test | - [No Name] [+] [No Name] [+] | + mouse scrolling {4:│}text | + ^ {4:│}with | + {0:~ }{4:│}many | + {0:~ }{4:│}lines | + {0:~ }{4:│}to | + {0:~ }{4:│}test | + {5:[No Name] [+] }{4:[No Name] [+] }| to | test | mouse scrolling | | - ~ | - [No Name] [+] | - | + {0:~ }| + {4:[No Name] [+] }| + :vsp | ]]) - feed('<MouseDown><27,7><MouseDown>') + feed('<ScrollWheelUp><27,7><ScrollWheelUp>') screen:expect([[ - mouse scrolling |text | - ^ |with | - ~ |many | - ~ |lines | - ~ |to | - ~ |test | - [No Name] [+] [No Name] [+] | + mouse scrolling {4:│}text | + ^ {4:│}with | + {0:~ }{4:│}many | + {0:~ }{4:│}lines | + {0:~ }{4:│}to | + {0:~ }{4:│}test | + {5:[No Name] [+] }{4:[No Name] [+] }| Inserting | text | with | many | lines | - [No Name] [+] | - | + {4:[No Name] [+] }| + :vsp | ]]) end) it('horizontal scrolling', function() + command('set sidescroll=0') feed("<esc>:set nowrap<cr>") feed("a <esc>20Ab<esc>") @@ -440,7 +709,7 @@ describe('Mouse input', function() | | bbbbbbbbbbbbbbb^b | - ~ | + {0:~ }| | ]]) @@ -449,7 +718,7 @@ describe('Mouse input', function() | | n bbbbbbbbbbbbbbbbbbb^b | - ~ | + {0:~ }| | ]]) @@ -458,8 +727,572 @@ describe('Mouse input', function() g | | ^t and selection bbbbbbbbb| - ~ | + {0:~ }| | ]]) end) + + describe('on concealed text', function() + -- Helpful for reading the test expectations: + -- :match Error /\^/ + + before_each(function() + screen:try_resize(25, 7) + 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=ni') + feed_command('set nowrap') + feed_command('set shiftwidth=2 tabstop=4 list listchars=tab:>-') + feed_command('syntax match NonText "\\*" conceal') + feed_command('syntax match NonText "cats" conceal cchar=X') + feed_command('syntax match NonText "x" conceal cchar=>') + + -- First column is there to retain the tabs. + insert([[ + |Section *t1* + | *t2* *t3* *t4* + |x 私は猫が大好き *cats* ✨🐈✨ + ]]) + + feed('gg<c-v>Gxgg') + end) + + it('(level 1) click on non-wrapped lines', function() + feed_command('let &conceallevel=1', 'echo') + + feed('<esc><LeftMouse><0,0>') + screen:expect([[ + ^Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><1,0>') + screen:expect([[ + S^ection{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><21,0>') + screen:expect([[ + Section{0:>>--->--->---}{c: }^t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><21,1>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t^3{c: } {c: }| + {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><0,2>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:^>} 私は猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><7,2>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:>} 私は^猫が大好き{0:>---}{c: X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><21,2>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + {c:>} 私は猫が大好き{0:>---}{c: ^X } {0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + end) -- level 1 - non wrapped + + it('(level 1) click on wrapped lines', function() + feed_command('let &conceallevel=1', 'let &wrap=1', 'echo') + + feed('<esc><LeftMouse><24,1>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c:^ }| + t4{c: } | + {c:>} 私は猫が大好き{0:>---}{c: X} | + {c: } ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><0,2>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + ^t4{c: } | + {c:>} 私は猫が大好き{0:>---}{c: X} | + {c: } ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><8,3>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + t4{c: } | + {c:>} 私は猫^が大好き{0:>---}{c: X} | + {c: } ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><21,3>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + t4{c: } | + {c:>} 私は猫が大好き{0:>---}{c: ^X} | + {c: } ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><4,4>') + screen:expect([[ + Section{0:>>--->--->---}{c: }t1{c: } | + {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| + t4{c: } | + {c:>} 私は猫が大好き{0:>---}{c: X} | + {c: } ✨^🐈✨ | + | + | + ]]) + end) -- level 1 - wrapped + + + it('(level 2) click on non-wrapped lines', function() + feed_command('let &conceallevel=2', 'echo') + + feed('<esc><LeftMouse><20,0>') + screen:expect([[ + Section{0:>>--->--->---}^t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><14,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} ^t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><18,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t^3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><0,2>') -- Weirdness + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><8,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><20,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}| + | + {0:~ }| + {0:~ }| + | + ]]) + 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') + + feed('<esc><LeftMouse><20,0>') + screen:expect([[ + Section{0:>>--->--->---}^t1 | + {0:>--->--->---} t2 t3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><14,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} ^t2 t3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><18,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t^3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + -- NOTE: The click would ideally be on the 't' in 't4', but wrapping + -- caused the invisible '*' right before 't4' to remain on the previous + -- screen line. This is being treated as expected because fixing this is + -- out of scope for mouse clicks. Should the wrapping behavior of + -- concealed characters change in the future, this case should be + -- reevaluated. + feed('<esc><LeftMouse><0,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 ^ | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><1,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t^4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><0,3>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + {c:^>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><20,3>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:^X} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><1,4>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ^✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><5,4>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + {c:>} 私は猫が大好き{0:>---}{c:X} | + ✨🐈^✨ | + | + | + ]]) + end) -- level 2 - wrapped + + + it('(level 3) click on non-wrapped lines', function() + feed_command('let &conceallevel=3', 'echo') + + feed('<esc><LeftMouse><0,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + ^ 私は猫が大好き{0:>----} ✨🐈| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><1,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + ^私は猫が大好き{0:>----} ✨🐈| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><13,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + 私は猫が大好^き{0:>----} ✨🐈| + | + {0:~ }| + {0:~ }| + | + ]]) + + feed('<esc><LeftMouse><20,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 t4 | + 私は猫が大好き{0:>----}^ ✨🐈| + | + {0:~ }| + {0:~ }| + | + ]]) + end) -- level 3 - non wrapped + + it('(level 3) click on wrapped lines', function() + feed_command('let &conceallevel=3', 'let &wrap=1', 'echo') + + feed('<esc><LeftMouse><14,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} ^t2 t3 | + t4 | + 私は猫が大好き{0:>----} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><18,1>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t^3 | + t4 | + 私は猫が大好き{0:>----} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><1,2>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t^4 | + 私は猫が大好き{0:>----} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><0,3>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + ^ 私は猫が大好き{0:>----} | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><20,3>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + 私は猫が大好き{0:>----}^ | + ✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><1,4>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + 私は猫が大好き{0:>----} | + ^✨🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><3,4>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + 私は猫が大好き{0:>----} | + ✨^🐈✨ | + | + | + ]]) + + feed('<esc><LeftMouse><5,4>') + screen:expect([[ + Section{0:>>--->--->---}t1 | + {0:>--->--->---} t2 t3 | + t4 | + 私は猫が大好き{0:>----} | + ✨🐈^✨ | + | + | + ]]) + + end) -- level 3 - wrapped + end) end) |