diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 273 | ||||
-rw-r--r-- | test/functional/ui/diff_spec.lua | 26 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 60 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 9 |
4 files changed, 338 insertions, 30 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 1575cab591..ae5d34fa7a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1362,3 +1362,276 @@ if (h->n_buckets < new_n_buckets) { // expand end) end) + +describe('decorations: signs', function() + local screen, ns + before_each(function() + clear() + screen = Screen.new(50, 10) + screen:attach() + screen:set_default_attr_ids { + [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Grey}; + [2] = {foreground = Screen.colors.Blue1, bold = true}; + } + + ns = meths.create_namespace 'test' + meths.win_set_option(0, 'signcolumn', 'auto:9') + end) + + local example_text = [[ +l1 +l2 +l3 +l4 +l5 +]] + + it('can add a single sign (no end row)', function() + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) + + screen:expect{grid=[[ + {1: }^l1 | + S l2 | + {1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + end) + + it('can add a single sign (with end row)', function() + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) + + screen:expect{grid=[[ + {1: }^l1 | + S l2 | + {1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + end) + + it('can add multiple signs (single extmark)', function() + pending('TODO(lewis6991): Support ranged signs') + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) + + screen:expect{grid=[[ + {1: }^l1 | + S l2 | + S l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + end) + + it('can add multiple signs (multiple extmarks)', function() + pending('TODO(lewis6991): Support ranged signs') + insert(example_text) + feed'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) + meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4}) + + screen:expect{grid=[[ + {1: }^l1 | + S1l2 | + {1: }l3 | + S2l4 | + S2l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + end) + + it('can add multiple signs (multiple extmarks) 2', function() + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + + screen:expect{grid=[[ + {1: }^l1 | + S2S1l2 | + {1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + -- TODO(lewis6991): Support ranged signs + -- meths.buf_set_extmark(1, ns, 1, -1, {sign_text='S3', end_row = 2}) + + -- screen:expect{grid=[[ + -- {1: }^l1 | + -- S3S2S1l2 | + -- S3{1: }l3 | + -- {1: }l4 | + -- {1: }l5 | + -- {1: } | + -- {2:~ }| + -- {2:~ }| + -- {2:~ }| + -- | + -- ]]} + + end) + + it('can add multiple signs (multiple extmarks) 3', function() + pending('TODO(lewis6991): Support ranged signs') + + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) + meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3}) + + screen:expect{grid=[[ + {1: }^l1 | + S1{1: }l2 | + S2S1l3 | + S2{1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + end) + + it('can add multiple signs (multiple extmarks) 4', function() + insert(example_text) + feed 'gg' + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1}) + + screen:expect{grid=[[ + S1^l1 | + S2l2 | + {1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + end) + + it('works with old signs', function() + insert(example_text) + feed 'gg' + + helpers.command('sign define Oldsign text=x') + helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + + screen:expect{grid=[[ + S4S1^l1 | + S2x l2 | + S5{1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + end) + + it('works with old signs (with range)', function() + pending('TODO(lewis6991): Support ranged signs') + insert(example_text) + feed 'gg' + + helpers.command('sign define Oldsign text=x') + helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + + screen:expect{grid=[[ + S3S4S1^l1 | + S2S3x l2 | + S5S3{1: }l3 | + S3{1: }l4 | + S3{1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + end) + + it('can add a ranged sign (with start out of view)', function() + pending('TODO(lewis6991): Support ranged signs') + + insert(example_text) + command 'set signcolumn=yes:2' + feed 'gg' + feed '2<C-e>' + + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3}) + + screen:expect{grid=[[ + X {1: }^l3 | + X {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + end) + +end) diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index bd2692d19a..3a25d7e813 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -6,7 +6,7 @@ local clear = helpers.clear local command = helpers.command local insert = helpers.insert local write_file = helpers.write_file -local source = helpers.source +local exec = helpers.exec describe('Diff mode screen', function() local fname = 'Xtest-functional-diff-screen-1' @@ -1075,10 +1075,8 @@ it('diff updates line numbers below filler lines', function() [9] = {background = Screen.colors.LightMagenta}, [10] = {bold = true, foreground = Screen.colors.Brown}, [11] = {foreground = Screen.colors.Brown}, - [12] = {foreground = Screen.colors.Brown, bold = true, background = Screen.colors.Red}; - [13] = {background = Screen.colors.Gray90}; }) - source([[ + exec([[ call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b']) vnew call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b']) @@ -1135,24 +1133,6 @@ it('diff updates line numbers below filler lines', function() {3:[No Name] [+] }{7:[No Name] [+] }| | ]]) - command("set signcolumn number tgc cursorline cursorlineopt=number,line") - command("hi CursorLineNr guibg=red") - screen:expect{grid=[[ - {1: }a {3:│}{11: 2 }a | - {1: }a {3:│}{11: 1 }a | - {1: }a {3:│}{12:3 }{13:^a }| - {1: }{8:x}{9: }{3:│}{11: 1 }{8:y}{9: }| - {1: }{4:x }{3:│}{11: }{2:----------------}| - {1: }{4:x }{3:│}{11: }{2:----------------}| - {1: }b {3:│}{11: 2 }b | - {1: }b {3:│}{11: 3 }b | - {1: }b {3:│}{11: 4 }b | - {1: }b {3:│}{11: 5 }b | - {1: }b {3:│}{11: 6 }b | - {6:~ }{3:│}{6:~ }| - {3:[No Name] [+] }{7:[No Name] [+] }| - signcolumn=auto | - ]]} end) it('Align the filler lines when changing text in diff mode', function() @@ -1169,7 +1149,7 @@ it('Align the filler lines when changing text in diff mode', function() [7] = {foreground = Screen.colors.Blue1, bold = true}; [8] = {reverse = true, bold = true}; }) - source([[ + exec([[ call setline(1, range(1, 15)) vnew call setline(1, range(9, 15)) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 12643eec1e..64f0ba3419 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -840,7 +840,7 @@ describe("'listchars' highlight", function() end) end) -describe('CursorLine highlight', function() +describe('CursorLine and CursorLineNr highlights', function() before_each(clear) it('overridden by Error, ColorColumn if fg not set', function() @@ -1081,7 +1081,7 @@ describe('CursorLine highlight', function() ]]) end) - it('with split-windows in diff-mode', function() + it('with split windows in diff mode', function() local screen = Screen.new(50,12) screen:set_default_attr_ids({ [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, @@ -1093,7 +1093,6 @@ describe('CursorLine highlight', function() [7] = {background = Screen.colors.Red, foreground = Screen.colors.White}, [8] = {bold = true, foreground = Screen.colors.Blue1}, [9] = {bold = true, reverse = true}, - [10] = {bold = true}, }) screen:attach() @@ -1170,6 +1169,61 @@ describe('CursorLine highlight', function() background = Screen.colors.Red}, }) end) + + it('CursorLineNr shows correctly just below filler lines', function() + local screen = Screen.new(50,12) + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, + [3] = {reverse = true}, + [4] = {background = Screen.colors.LightBlue}, + [5] = {background = Screen.colors.Red, foreground = Screen.colors.White}, + [6] = {background = Screen.colors.White, bold = true, foreground = Screen.colors.Black}, + [7] = {bold = true, foreground = Screen.colors.Blue1}, + [8] = {bold = true, reverse = true}, + [9] = {foreground = Screen.colors.Brown}, + }) + screen:attach() + + command('hi CursorLine guibg=red guifg=white') + command('hi CursorLineNr guibg=white guifg=black gui=bold') + command('set cursorline number') + command('call setline(1, ["baz", "foo", "foo", "bar"])') + feed('2gg0') + command('vnew') + command('call setline(1, ["foo", "foo", "bar"])') + command('windo diffthis') + command('1wincmd w') + screen:expect([[ + {1: }{9: }{2:-------------------}{3:│}{1: }{9: 1 }{4:baz }| + {1: }{6: 1 }{5:^foo }{3:│}{1: }{6: 2 }{5:foo }| + {1: }{9: 2 }foo {3:│}{1: }{9: 3 }foo | + {1: }{9: 3 }bar {3:│}{1: }{9: 4 }bar | + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {8:[No Name] [+] }{3:[No Name] [+] }| + | + ]]) + command('set cursorlineopt=number') + screen:expect([[ + {1: }{9: }{2:-------------------}{3:│}{1: }{9: 1 }{4:baz }| + {1: }{6: 1 }^foo {3:│}{1: }{6: 2 }{5:foo }| + {1: }{9: 2 }foo {3:│}{1: }{9: 3 }foo | + {1: }{9: 3 }bar {3:│}{1: }{9: 4 }bar | + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {7:~ }{3:│}{7:~ }| + {8:[No Name] [+] }{3:[No Name] [+] }| + | + ]]) + end) end) describe('ColorColumn highlight', function() diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index a5af898652..3e94fdbf44 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1559,10 +1559,11 @@ end function Screen:_equal_attrs(a, b) return a.bold == b.bold and a.standout == b.standout and - a.underline == b.underline and a.undercurl == b.undercurl and - a.italic == b.italic and a.reverse == b.reverse and - a.foreground == b.foreground and a.background == b.background and - a.special == b.special and a.blend == b.blend and + a.underline == b.underline and a.underlineline == b.underlineline and + a.undercurl == b.undercurl and a.underdot == b.underdot and + a.underdash == b.underdash and a.italic == b.italic and + a.reverse == b.reverse and a.foreground == b.foreground and + a.background == b.background and a.special == b.special and a.blend == b.blend and a.strikethrough == b.strikethrough and a.fg_indexed == b.fg_indexed and a.bg_indexed == b.bg_indexed end |