diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-08-23 13:44:53 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-23 13:44:53 +0800 |
| commit | 99265d099c2c366eea936438734a323d1fb9b341 (patch) | |
| tree | 32cc38ad61372c1977f7e295c4e6a6a86acad510 | |
| parent | 3e80b39a8ef9d33090800642d25fadbd282af337 (diff) | |
| parent | 908f247c224db88ffd25e207314d41031519b128 (diff) | |
| download | rneovim-99265d099c2c366eea936438734a323d1fb9b341.tar.gz rneovim-99265d099c2c366eea936438734a323d1fb9b341.tar.bz2 rneovim-99265d099c2c366eea936438734a323d1fb9b341.zip | |
Merge pull request #24844 from zeertzjq/vim-9.0.1783
vim-patch:9.0.1783: Display issues with virt text smoothscroll and showbreak
| -rw-r--r-- | src/nvim/charset.c | 1 | ||||
| -rw-r--r-- | src/nvim/drawline.c | 53 | ||||
| -rw-r--r-- | src/nvim/edit.c | 6 | ||||
| -rw-r--r-- | src/nvim/plines.c | 131 | ||||
| -rw-r--r-- | src/nvim/plines.h | 1 | ||||
| -rw-r--r-- | test/functional/ui/decorations_spec.lua | 923 | ||||
| -rw-r--r-- | test/old/testdir/test_listlbr.vim | 47 | ||||
| -rw-r--r-- | test/old/testdir/test_listlbr_utf8.vim | 83 |
8 files changed, 709 insertions, 536 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 4030d818c8..d11cbddccf 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -991,6 +991,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en chartabsize_T cts; bool on_NUL = false; init_chartabsize_arg(&cts, wp, pos->lnum, 0, line, line); + cts.cts_max_head_vcol = -1; // This function is used very often, do some speed optimizations. // When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 753baa2675..fa2aecff86 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -132,9 +132,12 @@ typedef struct { bool reset_extra_attr; - int skip_cells; // nr of cells to skip for virtual text - int skipped_cells; // nr of skipped virtual text cells - bool more_virt_inline_chunks; // indicates if there is more inline virtual text after n_extra + int skip_cells; ///< nr of cells to skip for w_leftcol + ///< or w_skipcol or concealing + int skipped_cells; ///< nr of skipped cells for virtual text + ///< to be added to wlv.vcol later + bool more_virt_inline_chunks; ///< indicates if there is more inline virtual text + ///< after n_extra } winlinevars_T; /// for line_putchar. Contains the state that needs to be remembered from @@ -1090,9 +1093,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl int n_attr3 = 0; // chars with overruling special attr int saved_attr3 = 0; // char_attr saved for n_attr3 - int n_skip = 0; // nr of chars to skip for 'nowrap' or - // concealing - int fromcol_prev = -2; // start of inverting after cursor bool noinvcur = false; // don't invert the cursor bool lnum_in_visual_area = false; @@ -1500,10 +1500,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl char *prev_ptr = ptr; chartabsize_T cts; int charsize = 0; + int head = 0; init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, ptr); + cts.cts_max_head_vcol = (int)v; while (cts.cts_vcol < v && *cts.cts_ptr != NUL) { - charsize = win_lbr_chartabsize(&cts, NULL); + head = 0; + charsize = win_lbr_chartabsize(&cts, &head); cts.cts_vcol += charsize; prev_ptr = cts.cts_ptr; MB_PTR_ADV(cts.cts_ptr); @@ -1530,17 +1533,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl if (wlv.vcol > v) { wlv.vcol -= charsize; ptr = prev_ptr; - // If the character fits on the screen, don't need to skip it. - // Except for a TAB. - if (utf_ptr2cells(ptr) >= charsize || *ptr == TAB) { - n_skip = (int)(v - wlv.vcol); - } } - // If there the text doesn't reach to the desired column, need to skip - // "skip_cells" cells when virtual text follows. - if ((!wp->w_p_wrap || (lnum == wp->w_topline && wp->w_skipcol > 0)) && v > wlv.vcol) { - wlv.skip_cells = (int)(v - wlv.vcol); + if (v > wlv.vcol) { + wlv.skip_cells = (int)v - wlv.vcol - head; } // Adjust for when the inverted text is before the screen, @@ -1808,9 +1804,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl decor_attr = 0; search_attr_from_match = false; } - if (wlv.n_extra > 0) { - n_skip = 0; - } } } @@ -2027,6 +2020,12 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl // Get a character from the line itself. c0 = c = (uint8_t)(*ptr); mb_c = c; + + if (c == NUL) { + // no more cells to skip + wlv.skip_cells = 0; + } + // If the UTF-8 character is more than one byte: Decode it // into "mb_c". mb_l = utfc_ptr2len(ptr); @@ -2118,7 +2117,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl // If a double-width char doesn't fit at the left side display a '<' in // the first column. Don't do this for unprintable characters. - if (n_skip > 0 && mb_l > 1 && wlv.n_extra == 0) { + if (wlv.skip_cells > 0 && mb_l > 1 && wlv.n_extra == 0) { wlv.n_extra = 1; wlv.c_extra = MB_FILLER_CHAR; wlv.c_final = NUL; @@ -2619,9 +2618,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl } wlv.n_extra = 0; wlv.n_attr = 0; - } else if (n_skip == 0) { + } else if (wlv.skip_cells == 0) { is_concealing = true; - n_skip = 1; + wlv.skip_cells = 1; } mb_c = c; mb_utf8 = check_mb_utf8(&c, u8cc); @@ -2630,7 +2629,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl is_concealing = false; } - if (n_skip > 0 && did_decrement_ptr) { + if (wlv.skip_cells > 0 && did_decrement_ptr) { // not showing the '>', put pointer back to avoid getting stuck ptr++; } @@ -2641,7 +2640,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl if (!did_wcol && wlv.draw_state == WL_LINE && wp == curwin && lnum == wp->w_cursor.lnum && conceal_cursor_line(wp) - && (int)wp->w_virtcol <= wlv.vcol + n_skip) { + && (int)wp->w_virtcol <= wlv.vcol + wlv.skip_cells) { if (wp->w_p_rl) { wp->w_wcol = grid->cols - wlv.col + wlv.boguscols - 1; } else { @@ -2946,7 +2945,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl // Store character to be displayed. // Skip characters that are left of the screen for 'nowrap'. - if (wlv.draw_state < WL_LINE || n_skip <= 0) { + if (wlv.draw_state < WL_LINE || wlv.skip_cells <= 0) { // Store the character. if (wp->w_p_rl && utf_char2cells(mb_c) > 1) { // A double-wide character is: put first half in left cell. @@ -2999,7 +2998,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl wlv.col++; } } else if (wp->w_p_cole > 0 && is_concealing) { - n_skip--; + wlv.skip_cells--; wlv.vcol_off++; if (wlv.n_extra > 0) { wlv.vcol_off += wlv.n_extra; @@ -3055,7 +3054,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl } } } else { - n_skip--; + wlv.skip_cells--; } // The skipped cells need to be accounted for in vcol. diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 915399ec78..869b226856 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -232,7 +232,8 @@ static void insert_enter(InsertState *s) may_trigger_modechanged(); stop_insert_mode = false; - // need to position cursor again when on a TAB + // need to position cursor again when on a TAB and + // when on a char with inline virtual text if (gchar_cursor() == TAB || curbuf->b_virt_text_inline > 0) { curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); } @@ -3471,7 +3472,8 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) State = MODE_NORMAL; may_trigger_modechanged(); - // need to position cursor again when on a TAB + // need to position cursor again when on a TAB and + // when on a char with inline virtual text if (gchar_cursor() == TAB || curbuf->b_virt_text_inline > 0) { curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); } diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 431e4cd8c9..c2447103dc 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -369,16 +369,19 @@ int lbr_chartabsize_adv(chartabsize_T *cts) return retval; } +/// Get the number of characters taken up on the screen indicated by "cts". +/// "cts->cts_cur_text_width_left" and "cts->cts_cur_text_width_right" are set +/// to the extra size for inline virtual text. /// This function is used very often, keep it fast!!!! /// -/// If "headp" not NULL, set *headp to the size of what we for 'showbreak' -/// string at start of line. Warning: *headp is only set if it's a non-zero -/// value, init to 0 before calling. +/// If "headp" not NULL, set "*headp" to the size of 'showbreak'/'breakindent' +/// included in the return value. +/// When "cts->cts_max_head_vcol" is positive, only count in "*headp" the size +/// of 'showbreak'/'breakindent' before "cts->cts_max_head_vcol". +/// When "cts->cts_max_head_vcol" is negative, only count in "*headp" the size +/// of 'showbreak'/'breakindent' before where cursor should be placed. /// -/// @param cts -/// @param headp -/// -/// @return The number of characters taken up on the screen. +/// Warning: "*headp" may not be set if it's 0, init to 0 before calling. int win_lbr_chartabsize(chartabsize_T *cts, int *headp) { win_T *wp = cts->cts_win; @@ -388,7 +391,6 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) colnr_T col_adj = 0; // vcol + screen size of tab int mb_added = 0; - int numberextra; cts->cts_cur_text_width_left = 0; cts->cts_cur_text_width_right = 0; @@ -449,7 +451,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) && (wp->w_width_inner != 0)) { // Count all characters from first non-blank after a blank up to next // non-blank after a blank. - numberextra = win_col_off(wp); + int numberextra = win_col_off(wp); colnr_T col2 = vcol; colnr_T colmax = (colnr_T)(wp->w_width_inner - numberextra - col_adj); @@ -490,72 +492,95 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) // May have to add something for 'breakindent' and/or 'showbreak' // string at start of line. - // Set *headp to the size of what we add. // Do not use 'showbreak' at the NUL after the text. - int added = 0; - char *const sbr = c == NUL ? empty_option : get_showbreak_value(wp); - if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && vcol != 0) { - colnr_T sbrlen = 0; - int numberwidth = win_col_off(wp); - - numberextra = numberwidth; - vcol += numberextra + mb_added; - - if (vcol >= (colnr_T)wp->w_width_inner) { - vcol -= wp->w_width_inner; - numberextra = wp->w_width_inner - (numberextra - win_col_off2(wp)); - if (vcol >= numberextra && numberextra > 0) { - vcol %= numberextra; + int head = mb_added; + char *const sbr + // XXX: there should be a better check deeper below + = ((c == NUL && cts->cts_cur_text_width_left + cts->cts_cur_text_width_right == 0) + ? empty_option : get_showbreak_value(wp)); + if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap) { + int col_off_prev = win_col_off(wp); + int width2 = wp->w_width_inner - col_off_prev + win_col_off2(wp); + colnr_T wcol = vcol + col_off_prev; + // cells taken by 'showbreak'/'breakindent' before current char + int head_prev = 0; + if (wcol >= wp->w_width_inner) { + wcol -= wp->w_width_inner; + col_off_prev = wp->w_width_inner - width2; + if (wcol >= width2 && width2 > 0) { + wcol %= width2; } if (*sbr != NUL) { - sbrlen = (colnr_T)mb_charlen(sbr); - if (vcol >= sbrlen) { - vcol -= sbrlen; - } + head_prev += vim_strsize(sbr); } - if (vcol >= numberextra && numberextra > 0) { - vcol %= numberextra; - } else if (vcol > 0 && numberextra > 0) { - vcol += numberwidth - win_col_off2(wp); + if (wp->w_p_bri) { + head_prev += get_breakindent_win(wp, line); } - - numberwidth -= win_col_off2(wp); + if (wcol < head_prev) { + wcol = head_prev; + } + wcol += col_off_prev; } - if (vcol == 0 || (vcol + size + sbrlen > (colnr_T)wp->w_width_inner)) { + if ((vcol > 0 && wcol == col_off_prev + head_prev) + || wcol + size > wp->w_width_inner) { + int added = 0; + colnr_T max_head_vcol = cts->cts_max_head_vcol; + + if (vcol > 0 && wcol == col_off_prev + head_prev) { + added += head_prev; + if (max_head_vcol <= 0 || vcol < max_head_vcol) { + head += head_prev; + } + } + + // cells taken by 'showbreak'/'breakindent' halfway current char + int head_mid = 0; if (*sbr != NUL) { - if (size + sbrlen + numberwidth > (colnr_T)wp->w_width_inner) { + head_mid += vim_strsize(sbr); + } + if (wp->w_p_bri) { + head_mid += get_breakindent_win(wp, line); + } + if (head_mid > 0) { + if (wcol + size > wp->w_width_inner) { // Calculate effective window width. - int width = (colnr_T)wp->w_width_inner - sbrlen - numberwidth; - int prev_width = vcol ? ((colnr_T)wp->w_width_inner - (sbrlen + vcol)) - : 0; + int prev_rem = wp->w_width_inner - wcol; + int width = width2 - head_mid; if (width <= 0) { width = 1; } - added += ((size - prev_width) / width) * vim_strsize(sbr); - if ((size - prev_width) % width) { - // Wrapped, add another length of 'sbr'. - added += vim_strsize(sbr); + // divide "size - prev_width" by "width", rounding up + int cnt = (size - prev_rem + width - 1) / width; + added += cnt * head_mid; + + if (max_head_vcol == 0 || vcol + size + added < max_head_vcol) { + head += cnt * head_mid; + } else if (max_head_vcol > vcol + head_prev + prev_rem) { + head += (max_head_vcol - (vcol + head_prev + prev_rem) + + width2 - 1) / width2 * head_mid; + } else if (max_head_vcol < 0) { + int off = 0; + if (c != NUL || !(State & MODE_NORMAL)) { + off += cts->cts_cur_text_width_left; + } + if (c != NUL && (State & MODE_NORMAL)) { + off += cts->cts_cur_text_width_right; + } + if (off >= prev_rem) { + head += (1 + (off - prev_rem) / width) * head_mid; + } } - } else { - added += vim_strsize(sbr); } } - if (wp->w_p_bri) { - added += get_breakindent_win(wp, line); - } - size += added; - if (vcol != 0) { - added = 0; - } } } if (headp != NULL) { - *headp = added + mb_added; + *headp = head; } return size; } diff --git a/src/nvim/plines.h b/src/nvim/plines.h index d89dc7b6f6..153d84e8bb 100644 --- a/src/nvim/plines.h +++ b/src/nvim/plines.h @@ -19,6 +19,7 @@ typedef struct { MarkTreeIter cts_iter[1]; int cts_vcol; ///< virtual column at current position + int cts_max_head_vcol; ///< see win_lbr_chartabsize() } chartabsize_T; #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ed562555e3..4e3214da71 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1658,7 +1658,7 @@ describe('decorations: inline virtual text', function() local screen, ns before_each( function() clear() - screen = Screen.new(50, 10) + screen = Screen.new(50, 3) screen:attach() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; @@ -1689,6 +1689,7 @@ describe('decorations: inline virtual text', function() it('works', function() + screen:try_resize(50, 10) insert(example_text) feed 'gg' screen:expect{grid=[[ @@ -1748,6 +1749,7 @@ describe('decorations: inline virtual text', function() end) it('works with empty chunk', function() + screen:try_resize(50, 10) insert(example_text) feed 'gg' screen:expect{grid=[[ @@ -1796,142 +1798,86 @@ describe('decorations: inline virtual text', function() it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '4l' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10: virtual text virtual text }^5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('adjusts cursor location correctly when inserting around inline virtual text', function() insert('12345678') feed '$' - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10: virtual text }567^8 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('has correct highlighting with multi-byte characters', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:múlti-byté chñröcters 修补}567^8 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('has correct cursor position when inserting around virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '3l' feed 'a' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:^virtual text}5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} feed '<ESC>' screen:expect{grid=[[ 123^4{10:virtual text}5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | ]]} feed '^' feed '4l' feed 'i' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:^virtual text}5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} end) it('has correct cursor position with virtual text on an empty line', function() - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ {10:^virtual text} | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('text is drawn correctly with a wrapping virtual text', function() + screen:try_resize(50, 8) feed('o<esc>') insert([[aaaaaaa bbbbbbb]]) - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, - { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | @@ -1939,13 +1885,11 @@ bbbbbbb]]) bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| | ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | ^aaaaaaa | @@ -1953,13 +1897,11 @@ bbbbbbb]]) bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | @@ -1967,13 +1909,11 @@ bbbbbbb]]) bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | @@ -1981,13 +1921,11 @@ bbbbbbb]]) ^bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('ggic') - screen:expect { grid = [[ + screen:expect{grid=[[ c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XX} | aaaaaaa | @@ -1995,10 +1933,8 @@ bbbbbbb]]) bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} end) it('regexp \\%V does not count trailing virtual text', function() @@ -2021,104 +1957,60 @@ bbbbbbb]]) ]]} end) - it('cursor position is correct with virtual text attached to hard tabs', function() + it('cursor position is correct with virtual text attached to hard TABs', function() command('set noexpandtab') feed('i') feed('<TAB>') feed('<TAB>') feed('test') feed('<ESC>') - meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('0') - screen:expect { grid = [[ + screen:expect{grid=[[ ^ {10:virtual text} test | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} ^ test | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} ^test | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} t^est | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} te^st | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('cursor position is correct with virtual text on an empty line', function() command('set linebreak') insert('one twoword') feed('0') - meths.buf_set_extmark(0, ns, 0, 3, - { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ ^one{10:: virtual text} twoword | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} end) it('search highlight is correct', function() @@ -2128,47 +2020,26 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - screen:expect { grid = [[ + screen:expect{grid=[[ ^foo foo f{10:AAABBB}oo bar | foo foo f{10:CCCDDD}oo bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('/foo') - screen:expect { grid = [[ + screen:expect{grid=[[ {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| /foo^ | - ]]} + ]]} meths.buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('<C-G>') - screen:expect{ grid = [[ + screen:expect{grid=[[ {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ |