From d9de4c0efb142e140bbddd87ffcb0bf222bb6fbc Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 3 Apr 2019 10:48:47 +0200 Subject: [PATCH] vim-patch:8.1.1072: extending sign and foldcolumn below the text is confusing (#9816) Problem: Extending sign and foldcolumn below the text is confusing. Solution: Let the sign and foldcolumn stop at the last text line, just like the line number column. Also stop the command line window leader. (Christian Brabandt) https://github.com/vim/vim/commit/8ee4c01b8c79a29065c1af05e5d9c0721069765f Closes https://github.com/neovim/neovim/issues/9613 --- src/nvim/screen.c | 136 ++++---- test/functional/ui/diff_spec.lua | 408 +++++++++++------------ test/functional/ui/fold_spec.lua | 48 +-- test/functional/ui/highlight_spec.lua | 18 +- test/functional/ui/sign_spec.lua | 168 +++++----- test/functional/viml/completion_spec.lua | 18 +- 6 files changed, 387 insertions(+), 409 deletions(-) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e66425d0c1..55f3417bb9 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1461,7 +1461,7 @@ static void win_update(win_T *wp) set_empty_rows(wp, srow); wp->w_botline = lnum; } else { - win_draw_end(wp, '@', ' ', srow, wp->w_grid.Rows, HLF_AT); + win_draw_end(wp, '@', ' ', true, srow, wp->w_grid.Rows, at_attr); wp->w_botline = lnum; } } else { @@ -1478,7 +1478,7 @@ static void win_update(win_T *wp) if (row + j > wp->w_grid.Rows) { j = wp->w_grid.Rows - row; } - win_draw_end(wp, i, i, row, row + (int)j, HLF_DED); + win_draw_end(wp, i, i, true, row, row + (int)j, HLF_DED); row += j; } } else if (dollar_vcol == -1) @@ -1486,7 +1486,8 @@ static void win_update(win_T *wp) // make sure the rest of the screen is blank // write the 'eob' character to rows that aren't part of the file. - win_draw_end(wp, wp->w_p_fcs_chars.eob, ' ', row, wp->w_grid.Rows, HLF_EOB); + win_draw_end(wp, wp->w_p_fcs_chars.eob, ' ', false, row, wp->w_grid.Rows, + HLF_EOB); } if (wp->w_redr_type >= REDRAW_TOP) { @@ -1548,87 +1549,66 @@ int win_signcol_width(win_T *wp) return 2; } -/* - * Clear the rest of the window and mark the unused lines with "c1". use "c2" - * as the filler character. - */ -static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T hl) +/// Call grid_fill() with columns adjusted for 'rightleft' if needed. +/// Return the new offset. +static int win_fill_end(win_T *wp, int c1, int c2, int off, int width, int row, + int endrow, int attr) +{ + int nn = off + width; + + if (nn > wp->w_grid.Columns) { + nn = wp->w_grid.Columns; + } + + if (wp->w_p_rl) { + grid_fill(&wp->w_grid, row, endrow, W_ENDCOL(wp) - nn, W_ENDCOL(wp) - off, + c1, c2, attr); + } else { + grid_fill(&wp->w_grid, row, endrow, off, nn, c1, c2, attr); + } + + return nn; +} + +/// Clear lines near the end of the window and mark the unused lines with "c1". +/// Use "c2" as filler character. +/// When "draw_margin" is true, then draw the sign/fold/number columns. +static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, + int endrow, hlf_T hl) { int n = 0; -# define FDC_OFF n - int fdc = compute_foldcolumn(wp, 0); + + if (draw_margin) { + // draw the fold column + int fdc = compute_foldcolumn(wp, 0); + if (fdc > 0) { + n = win_fill_end(wp, ' ', ' ', n, fdc, row, endrow, + win_hl_attr(wp, HLF_FC)); + } + // draw the sign column + int count = win_signcol_count(wp); + if (count > 0) { + n = win_fill_end(wp, ' ', ' ', n, win_signcol_width(wp) * count, row, + endrow, win_hl_attr(wp, HLF_SC)); + } + // draw the number column + if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) == NULL) { + n = win_fill_end(wp, ' ', ' ', n, number_width(wp) + 1, row, endrow, + win_hl_attr(wp, HLF_N)); + } + } int attr = hl_combine_attr(wp->w_hl_attr_normal, win_hl_attr(wp, hl)); if (wp->w_p_rl) { - // No check for cmdline window: should never be right-left. - n = fdc; - - if (n > 0) { - // draw the fold column at the right - if (n > wp->w_grid.Columns) { - n = wp->w_grid.Columns; - } - grid_fill(&wp->w_grid, row, endrow, wp->w_grid.Columns - n, - wp->w_grid.Columns, ' ', ' ', win_hl_attr(wp, HLF_FC)); - } - - int count = win_signcol_count(wp); - if (count > 0) { - int nn = n + win_signcol_width(wp) * count; - - // draw the sign column left of the fold column - if (nn > wp->w_grid.Columns) { - nn = wp->w_grid.Columns; - } - grid_fill(&wp->w_grid, row, endrow, wp->w_grid.Columns - nn, - wp->w_grid.Columns - n, ' ', ' ', win_hl_attr(wp, HLF_SC)); - n = nn; - } - - grid_fill(&wp->w_grid, row, endrow, 0, wp->w_grid.Columns - 1 - FDC_OFF, + grid_fill(&wp->w_grid, row, endrow, wp->w_wincol, W_ENDCOL(wp) - 1 - n, c2, c2, attr); - grid_fill(&wp->w_grid, row, endrow, - wp->w_grid.Columns - 1 - FDC_OFF, wp->w_grid.Columns - FDC_OFF, + grid_fill(&wp->w_grid, row, endrow, W_ENDCOL(wp) - 1 - n, W_ENDCOL(wp) - n, c1, c2, attr); } else { - if (cmdwin_type != 0 && wp == curwin) { - /* draw the cmdline character in the leftmost column */ - n = 1; - if (n > wp->w_grid.Columns) { - n = wp->w_grid.Columns; - } - grid_fill(&wp->w_grid, row, endrow, 0, n, cmdwin_type, ' ', - win_hl_attr(wp, HLF_AT)); - } - if (fdc > 0) { - int nn = n + fdc; - - // draw the fold column at the left - if (nn > wp->w_grid.Columns) { - nn = wp->w_grid.Columns; - } - grid_fill(&wp->w_grid, row, endrow, n, nn, ' ', ' ', - win_hl_attr(wp, HLF_FC)); - n = nn; - } - - int count = win_signcol_count(wp); - if (count > 0) { - int nn = n + win_signcol_width(wp) * count; - - // draw the sign column after the fold column - if (nn > wp->w_grid.Columns) { - nn = wp->w_grid.Columns; - } - grid_fill(&wp->w_grid, row, endrow, n, nn, ' ', ' ', - win_hl_attr(wp, HLF_SC)); - n = nn; - } - - grid_fill(&wp->w_grid, row, endrow, FDC_OFF, wp->w_grid.Columns, c1, c2, - attr); + grid_fill(&wp->w_grid, row, endrow, n, wp->w_grid.Columns, c1, c2, attr); } + set_empty_rows(wp, row); } @@ -4222,11 +4202,9 @@ win_line ( ) || lcs_eol_one == -1) break; - /* When the window is too narrow draw all "@" lines. */ - if (draw_state != WL_LINE - && filler_todo <= 0 - ) { - win_draw_end(wp, '@', ' ', row, wp->w_grid.Rows, HLF_AT); + // When the window is too narrow draw all "@" lines. + if (draw_state != WL_LINE && filler_todo <= 0) { + win_draw_end(wp, '@', ' ', true, row, wp->w_grid.Rows, HLF_AT); row = endrow; } diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index 8e6756e550..8eb2bbf779 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -62,12 +62,12 @@ describe('Diff mode screen', function() {1: }5 {3:│}{1: }5 | {1: }6 {3:│}{1: }6 | {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| {7:') screen:expect([[ {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| {7:') screen:expect([[ {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| {7:') screen:expect([[ {1:- }^ {3:│}{1:- } | - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| {7:') screen:expect([[ {1:- }^ {3:│}{1:- } | - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| - {1: }{6:~ }{3:│}{1: }{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| + {6:~ }{3:│}{6:~ }| {7:>}c | {2: }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) end) @@ -72,14 +72,14 @@ describe('Signs', function() {1:>>}b | {2: }c | {2: } | - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| {4:[No Name] [+] }| {2: }{3:a }| {1:>>}b | {2: }c | {2: } | - {2: }{0:~ }| + {0:~ }| {5:[No Name] [+] }| | ]]) @@ -102,15 +102,15 @@ describe('Signs', function() {2: }{6: 2 }{8:b }| {2: }{7: 3 }c | {1:>>}{7: 4 }{8:^ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) end) @@ -138,15 +138,15 @@ describe('Signs', function() XX{1:>>}{6: 2 }b | {1:>>}WW{6: 3 }c | {2: }{6: 4 }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) -- With the default setting, we get the sign with the top id. @@ -156,15 +156,15 @@ describe('Signs', function() {1:>>}{6: 2 }b | WW{6: 3 }c | {2: }{6: 4 }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) -- "auto:3" accommodates all the signs we defined so far. @@ -174,15 +174,15 @@ describe('Signs', function() XX{1:>>}{2: }{6: 2 }b | XX{1:>>}WW{6: 3 }c | {2: }{6: 4 }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) -- Check "yes:9". @@ -192,15 +192,15 @@ describe('Signs', function() XX{1:>>}{2: }{6: 2 }b | XX{1:>>}WW{2: }{6: 3 }c | {2: }{6: 4 }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) -- Check "auto:N" larger than the maximum number of signs defined in @@ -211,15 +211,15 @@ describe('Signs', function() XX{1:>>}{2: }{6: 2 }b | XX{1:>>}WW{6: 3 }c | {2: }{6: 4 }^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]} end) @@ -230,12 +230,12 @@ describe('Signs', function() feed(':sign place') screen:expect([[ {1:>>} | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| {4: }| :sign place | {9:--- Signs ---} | @@ -248,18 +248,18 @@ describe('Signs', function() feed('') screen:expect([[ {1:>>}^ | - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| - {2: }{0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) end) diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index a8d6135e3f..9d4cb325d9 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -904,9 +904,9 @@ describe('completion', function() | {8:[No Name] }| {0::}foo faa fee f^ | - {0::~ }| - {0::~ }| - {0::~ }| + {0:~ }| + {0:~ }| + {0:~ }| {9:[Command Line] }| {3:-- INSERT --} | ]] ) @@ -915,9 +915,9 @@ describe('completion', function() | {8:[No Name] }| {0::}foo faa fee foo^ | - {0::~ }{2: foo }{0: }| - {0::~ }{1: faa }{0: }| - {0::~ }{1: fee }{0: }| + {0:~ }{2: foo }{0: }| + {0:~ }{1: faa }{0: }| + {0:~ }{1: fee }{0: }| {9:[Command Line] }| {3:-- Keyword Local completion (^N^P) }{4:match 1 of 3} | ]]) @@ -926,9 +926,9 @@ describe('completion', function() | {8:[No Name] }| {0::}foo faa fee foo | - {0::~ }| - {0::~ }| - {0::~ }| + {0:~ }| + {0:~ }| + {0:~ }| {9:[Command Line] }| :foo faa fee foo^ | ]])