diff options
-rw-r--r-- | src/nvim/buffer.c | 1 | ||||
-rw-r--r-- | src/nvim/drawline.c | 143 | ||||
-rw-r--r-- | src/nvim/drawscreen.c | 9 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 3 | ||||
-rw-r--r-- | src/nvim/main.c | 4 | ||||
-rw-r--r-- | src/nvim/spell.c | 25 | ||||
-rw-r--r-- | src/nvim/spellfile.c | 2 | ||||
-rw-r--r-- | src/nvim/spellsuggest.c | 2 | ||||
-rw-r--r-- | src/nvim/ui.c | 3 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 59 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 37 | ||||
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/ui/spell_spec.lua | 42 | ||||
-rw-r--r-- | test/functional/ui/statuscolumn_spec.lua | 6 | ||||
-rw-r--r-- | test/old/testdir/test_spell.vim | 15 |
15 files changed, 254 insertions, 109 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 11b79fcede..dab07487cd 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3444,7 +3444,6 @@ void resettitle(void) { ui_call_set_icon(cstr_as_string(lasticon)); ui_call_set_title(cstr_as_string(lasttitle)); - ui_flush(); } #if defined(EXITFREE) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index c228fd905f..c9a27ceedf 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1028,7 +1028,7 @@ static void win_line_continue(winlinevars_T *wlv) /// @param lnum line to display /// @param startrow first row relative to window grid /// @param endrow last grid row to be redrawn -/// @param nochange not updating for changed text +/// @param mod_top top line updated for changed text /// @param number_only only update the number column /// @param foldinfo fold info for this line /// @param[in, out] providers decoration providers active this line @@ -1036,7 +1036,7 @@ static void win_line_continue(winlinevars_T *wlv) /// or explicitly return `false`. /// /// @return the number of last row the line occupies. -int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, bool number_only, +int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int mod_top, bool number_only, foldinfo_T foldinfo, DecorProviders *providers, char **provider_err) { winlinevars_T wlv; // variables passed between functions @@ -1049,7 +1049,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, static char *at_end_str = ""; // used for p_extra when displaying curwin->w_p_lcs_chars.eol // at end-of-line - bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0; + const bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0; int saved_attr2 = 0; // char_attr saved for n_attr int n_attr3 = 0; // chars with overruling special attr @@ -1075,6 +1075,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, int vcol_save_attr = 0; // saved attr for 'cursorcolumn' int decor_attr = 0; // attributes desired by syntax and extmarks bool has_syntax = false; // this buffer has syntax highl. + int folded_attr = 0; // attributes for folded line int save_did_emsg; int eol_hl_off = 0; // 1 if highlighted char after EOL bool draw_color_col = false; // highlight colorcolumn @@ -1159,7 +1160,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, wlv.vcol_sbr = -1; buf_T *buf = wp->w_buffer; - bool end_fill = (lnum == buf->b_ml.ml_line_count + 1); + const bool end_fill = (lnum == buf->b_ml.ml_line_count + 1); if (!number_only) { // To speed up the loop below, set extra_check when there is linebreak, @@ -1226,12 +1227,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, // When there was a sentence end in the previous line may require a // word starting with capital in this line. In line 1 always check - // the first word. - if (lnum != capcol_lnum) { - cap_col = -1; - } - if (lnum == 1) { + // the first word. Also check for sentence end in the line above + // when updating the first row in a window, the top line with + // changed text in a window, or if the previous line is folded. + if (lnum == 1 + || ((startrow == 0 || mod_top == lnum + || hasFoldingWin(wp, lnum - 1, NULL, NULL, true, NULL)) + && check_need_cap(wp, lnum, 0))) { cap_col = 0; + } else if (lnum != capcol_lnum) { + cap_col = -1; } capcol_lnum = 0; } @@ -1724,7 +1729,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, wlv.draw_state = WL_LINE; if (has_decor && wlv.row == startrow + wlv.filler_lines) { // hide virt_text on text hidden by 'nowrap' - decor_redraw_col(wp, wlv.vcol, wlv.off, true, &decor_state); + decor_redraw_col(wp, (colnr_T)(ptr - line), wlv.off, true, &decor_state); } win_line_continue(&wlv); // use wlv.saved_ values } @@ -1760,7 +1765,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, && wlv.col == win_col_offset && wlv.n_extra == 0 && wlv.row == startrow + wlv.filler_lines) { - wlv.char_attr = win_hl_attr(wp, HLF_FL); + wlv.char_attr = folded_attr = win_hl_attr(wp, HLF_FL); linenr_T lnume = lnum + foldinfo.fi_lines - 1; memset(buf_fold, ' ', FOLD_TEXT_LEN); @@ -1802,7 +1807,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, } int extmark_attr = 0; - if (wlv.draw_state == WL_LINE && !has_fold + if (wlv.draw_state == WL_LINE && (area_highlighting || has_spell || extra_check)) { // handle Visual or match highlighting in this line if (wlv.vcol == wlv.fromcol @@ -1821,63 +1826,65 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, area_active = false; } - if (has_decor && v >= 0) { - bool selected = (area_active || (area_highlighting && noinvcur - && wlv.vcol == wp->w_virtcol)); - extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, - selected, &decor_state); - - bool do_save = false; - handle_inline_virtual_text(wp, &wlv, v, &do_save); - if (do_save) { - // restore search_attr and area_attr when n_extra is down to zero - // TODO(bfredl): this is ugly as fuck. look if we can do this some other way. - saved_search_attr = search_attr; - saved_area_attr = area_attr; - saved_search_attr_from_match = search_attr_from_match; - search_attr_from_match = false; - search_attr = 0; - area_attr = 0; - extmark_attr = 0; - n_skip = 0; + if (!has_fold) { + if (has_decor && v >= 0) { + bool selected = (area_active || (area_highlighting && noinvcur + && wlv.vcol == wp->w_virtcol)); + extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, + selected, &decor_state); + + bool do_save = false; + handle_inline_virtual_text(wp, &wlv, v, &do_save); + if (do_save) { + // restore search_attr and area_attr when n_extra is down to zero + // TODO(bfredl): this is ugly as fuck. look if we can do this some other way. + saved_search_attr = search_attr; + saved_area_attr = area_attr; + saved_search_attr_from_match = search_attr_from_match; + search_attr_from_match = false; + search_attr = 0; + area_attr = 0; + extmark_attr = 0; + n_skip = 0; + } } - } - - if (wlv.n_extra == 0) { - // Check for start/end of 'hlsearch' and other matches. - // After end, check for start/end of next match. - // When another match, have to check for start again. - v = (ptr - line); - search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, &screen_search_hl, - &has_match_conc, &match_conc, lcs_eol_one, - &on_last_col, &search_attr_from_match); - ptr = line + v; // "line" may have been changed - // Do not allow a conceal over EOL otherwise EOL will be missed - // and bad things happen. - if (*ptr == NUL) { - has_match_conc = 0; + if (wlv.n_extra == 0) { + // Check for start/end of 'hlsearch' and other matches. + // After end, check for start/end of next match. + // When another match, have to check for start again. + v = (ptr - line); + search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, &screen_search_hl, + &has_match_conc, &match_conc, lcs_eol_one, + &on_last_col, &search_attr_from_match); + ptr = line + v; // "line" may have been changed + + // Do not allow a conceal over EOL otherwise EOL will be missed + // and bad things happen. + if (*ptr == NUL) { + has_match_conc = 0; + } } - } - if (wlv.diff_hlf != (hlf_T)0) { - // When there is extra text (eg: virtual text) it gets the - // diff highlighting for the line, but not for changed text. - if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start - && wlv.n_extra == 0) { - wlv.diff_hlf = HLF_TXD; // changed text - } - if (wlv.diff_hlf == HLF_TXD && ((ptr - line > change_end && wlv.n_extra == 0) - || (wlv.n_extra > 0 && wlv.extra_for_extmark))) { - wlv.diff_hlf = HLF_CHD; // changed line - } - wlv.line_attr = win_hl_attr(wp, (int)wlv.diff_hlf); - // Overlay CursorLine onto diff-mode highlight. - if (wlv.cul_attr) { - wlv.line_attr = 0 != wlv.line_attr_lowprio // Low-priority CursorLine - ? hl_combine_attr(hl_combine_attr(wlv.cul_attr, wlv.line_attr), - hl_get_underline()) - : hl_combine_attr(wlv.line_attr, wlv.cul_attr); + if (wlv.diff_hlf != (hlf_T)0) { + // When there is extra text (eg: virtual text) it gets the + // diff highlighting for the line, but not for changed text. + if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start + && wlv.n_extra == 0) { + wlv.diff_hlf = HLF_TXD; // changed text + } + if (wlv.diff_hlf == HLF_TXD && ((ptr - line > change_end && wlv.n_extra == 0) + || (wlv.n_extra > 0 && wlv.extra_for_extmark))) { + wlv.diff_hlf = HLF_CHD; // changed line + } + wlv.line_attr = win_hl_attr(wp, (int)wlv.diff_hlf); + // Overlay CursorLine onto diff-mode highlight. + if (wlv.cul_attr) { + wlv.line_attr = 0 != wlv.line_attr_lowprio // Low-priority CursorLine + ? hl_combine_attr(hl_combine_attr(wlv.cul_attr, wlv.line_attr), + hl_get_underline()) + : hl_combine_attr(wlv.line_attr, wlv.cul_attr); + } } } @@ -1904,6 +1911,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, attr_pri = false; wlv.char_attr = decor_attr; } + + if (folded_attr != 0) { + wlv.char_attr = hl_combine_attr(folded_attr, wlv.char_attr); + } } // Get the next character to put on the screen. @@ -2193,7 +2204,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, p = prev_ptr; } cap_col -= (int)(prev_ptr - line); - size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange); + size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, mod_top == 0); assert(tmplen <= INT_MAX); int len = (int)tmplen; word_end = (int)v + len; diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 7f7c721379..4f79ba87af 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -2222,9 +2222,8 @@ static void win_update(win_T *wp, DecorProviders *providers) } // Display one line - row = win_line(wp, lnum, srow, - foldinfo.fi_lines ? srow : wp->w_grid.rows, - mod_top == 0, false, foldinfo, &line_providers, &provider_err); + row = win_line(wp, lnum, srow, foldinfo.fi_lines ? srow : wp->w_grid.rows, + mod_top, false, foldinfo, &line_providers, &provider_err); if (foldinfo.fi_lines == 0) { wp->w_lines[idx].wl_folded = false; @@ -2261,7 +2260,7 @@ static void win_update(win_T *wp, DecorProviders *providers) // text doesn't need to be drawn, but the number column does. foldinfo_T info = wp->w_p_cul && lnum == wp->w_cursor.lnum ? cursorline_fi : fold_info(wp, lnum); - (void)win_line(wp, lnum, srow, wp->w_grid.rows, true, true, + (void)win_line(wp, lnum, srow, wp->w_grid.rows, mod_top, true, info, &line_providers, &provider_err); } @@ -2359,7 +2358,7 @@ static void win_update(win_T *wp, DecorProviders *providers) // for ml_line_count+1 and only draw filler lines foldinfo_T info = { 0 }; row = win_line(wp, wp->w_botline, row, wp->w_grid.rows, - false, false, info, &line_providers, &provider_err); + mod_top, false, info, &line_providers, &provider_err); } } else if (dollar_vcol == -1) { wp->w_botline = lnum; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9666d80de2..39a54fa236 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4875,9 +4875,6 @@ static void ex_stop(exarg_T *eap) ui_call_suspend(); ui_flush(); - maketitle(); - resettitle(); // force updating the title - ui_refresh(); // may have resized window apply_autocmds(EVENT_VIMRESUME, NULL, NULL, false, NULL); } diff --git a/src/nvim/main.c b/src/nvim/main.c index 6015bbd06e..d4fbf8ce93 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1056,6 +1056,10 @@ static void command_line_scan(mparm_T *parmp) version(); os_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { +#ifdef MSWIN + // set stdout to binary to avoid crlf in --api-info output + _setmode(STDOUT_FILENO, _O_BINARY); +#endif FileDescriptor fp; const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, kFileWriteOnly); diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 498bd56b9e..778266e5ac 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1312,7 +1312,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att } else if (curline && wp == curwin) { // For spellbadword(): check if first word needs a capital. col = (colnr_T)getwhitecols(line); - if (check_need_cap(lnum, col)) { + if (check_need_cap(curwin, lnum, col)) { capcol = col; } @@ -2536,25 +2536,24 @@ int spell_casefold(const win_T *wp, char *str, int len, char *buf, int buflen) } // Check if the word at line "lnum" column "col" is required to start with a -// capital. This uses 'spellcapcheck' of the current buffer. -bool check_need_cap(linenr_T lnum, colnr_T col) +// capital. This uses 'spellcapcheck' of the buffer in window "wp". +bool check_need_cap(win_T *wp, linenr_T lnum, colnr_T col) { - bool need_cap = false; - - if (curwin->w_s->b_cap_prog == NULL) { + if (wp->w_s->b_cap_prog == NULL) { return false; } - char *line = get_cursor_line_ptr(); + bool need_cap = false; + char *line = col ? ml_get_buf(wp->w_buffer, lnum, false) : NULL; char *line_copy = NULL; colnr_T endcol = 0; - if (getwhitecols(line) >= (int)col) { + if (col == 0 || getwhitecols(line) >= col) { // At start of line, check if previous line is empty or sentence // ends there. if (lnum == 1) { need_cap = true; } else { - line = ml_get(lnum - 1); + line = ml_get_buf(wp->w_buffer, lnum - 1, false); if (*skipwhite(line) == NUL) { need_cap = true; } else { @@ -2571,13 +2570,13 @@ bool check_need_cap(linenr_T lnum, colnr_T col) if (endcol > 0) { // Check if sentence ends before the bad word. regmatch_T regmatch = { - .regprog = curwin->w_s->b_cap_prog, + .regprog = wp->w_s->b_cap_prog, .rm_ic = false }; char *p = line + endcol; while (true) { MB_PTR_BACK(line, p); - if (p == line || spell_iswordp_nmw(p, curwin)) { + if (p == line || spell_iswordp_nmw(p, wp)) { break; } if (vim_regexec(®match, p, 0) @@ -2586,7 +2585,7 @@ bool check_need_cap(linenr_T lnum, colnr_T col) break; } } - curwin->w_s->b_cap_prog = regmatch.regprog; + wp->w_s->b_cap_prog = regmatch.regprog; } xfree(line_copy); @@ -3601,7 +3600,7 @@ static bool spell_expand_need_cap; void spell_expand_check_cap(colnr_T col) { - spell_expand_need_cap = check_need_cap(curwin->w_cursor.lnum, col); + spell_expand_need_cap = check_need_cap(curwin, curwin->w_cursor.lnum, col); } // Get list of spelling suggestions. diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 5e4a429cc7..e81cebe18a 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -3131,7 +3131,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile) // Remove CR, LF and white space from the end. White space halfway through // the word is kept to allow multi-word terms like "et al.". l = (int)strlen(line); - while (l > 0 && line[l - 1] <= ' ') { + while (l > 0 && (uint8_t)line[l - 1] <= ' ') { l--; } if (l == 0) { diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 84be88be7b..1c34c2487f 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -509,7 +509,7 @@ void spell_suggest(int count) // Get the word and its length. // Figure out if the word should be capitalised. - int need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col); + int need_cap = check_need_cap(curwin, curwin->w_cursor.lnum, curwin->w_cursor.col); // Make a copy of current line since autocommands may free the line. line = xstrdup(get_cursor_line_ptr()); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 8c31032492..87a0271f3d 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -15,7 +15,7 @@ #include "nvim/api/ui.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" -#include "nvim/buffer_defs.h" +#include "nvim/buffer.h" #include "nvim/cursor_shape.h" #include "nvim/drawscreen.h" #include "nvim/ex_getln.h" @@ -348,6 +348,7 @@ void ui_attach_impl(UI *ui, uint64_t chanid) uis[ui_count++] = ui; ui_refresh_options(); + resettitle(); for (UIExtension i = kUIGlobalCount; (int)i < kUIExtCount; i++) { ui_set_ext_option(ui, i, ui->ui_ext[i]); diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 1e21d90be9..3ed31033fa 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -10,6 +10,7 @@ local expect_events = helpers.expect_events local meths = helpers.meths local curbufmeths = helpers.curbufmeths local command = helpers.command +local assert_alive = helpers.assert_alive describe('decorations providers', function() local screen @@ -80,7 +81,7 @@ describe('decorations providers', function() local ns2 = api.nvim_create_namespace "ns2" api.nvim_set_decoration_provider(ns2, {}) ]]) - helpers.assert_alive() + assert_alive() end) it('leave a trace', function() @@ -826,6 +827,26 @@ describe('extmark decorations', function() end -- ?古古古古?古古 | | ]]} + + screen:try_resize(50, 2) + command('set nowrap') + meths.buf_set_lines(0, 12, 12, true, {'-- ' .. ('…'):rep(57)}) + feed('G') + meths.buf_set_extmark(0, ns, 12, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + screen:expect{grid=[[ + ^-- …………………………………………………………………………………………………………{4:!!!!!}……| + | + ]]} + feed('40zl') + screen:expect{grid=[[ + ^………{4:!!!!!}……………………………… | + | + ]]} + feed('10zl') + screen:expect{grid=[[ + ^………………………… | + | + ]]} end) it('can have virtual text of overlay position and styling', function() @@ -1094,7 +1115,7 @@ describe('extmark decorations', function() {1:~ }| | ]]} - helpers.assert_alive() + assert_alive() end) it('conceal #19007', function() @@ -1305,6 +1326,9 @@ describe('decorations: inline virtual text', function() [13] = {reverse = true}; [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; [15] = {bold = true, reverse = true}; + [16] = {foreground = Screen.colors.Red}; + [17] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}; + [18] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Red}; } ns = meths.create_namespace 'test' @@ -2018,6 +2042,37 @@ bbbbbbb]]) ]], }) end) + + it('does not crash at column 0 when folded in a wide window', function() + screen:try_resize(82, 4) + command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') + command('set cursorline') + insert([[ + aaaaa + bbbbb + ccccc]]) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + fooaaaaa | + bbbbb | + {16:cccc^c }| + | + ]]} + command('1,2fold') + screen:expect{grid=[[ + {17:+-- 2 lines: aaaaa·······························································}| + {16:cccc^c }| + {1:~ }| + | + ]]} + feed('k') + screen:expect{grid=[[ + {18:^+-- 2 lines: aaaaa·······························································}| + ccccc | + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 2afe27ecc7..520979a2c2 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -42,9 +42,10 @@ describe("folded lines", function() [9] = {bold = true, foreground = Screen.colors.Brown}, [10] = {background = Screen.colors.LightGrey, underline = true}, [11] = {bold=true}, - [12] = {background = Screen.colors.Grey90, underline = true}, - [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, - [14] = {background = Screen.colors.LightGray}, + [12] = {foreground = Screen.colors.Red}, + [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, + [14] = {background = Screen.colors.Red}, + [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red}, }) end) @@ -88,10 +89,9 @@ describe("folded lines", function() end end) - it("foldcolumn highlighted with CursorLineFold when 'cursorline' is set", function() + local function test_folded_cursorline() command("set number cursorline foldcolumn=2") command("hi link CursorLineFold Search") - command("hi! CursorLine gui=underline guibg=Grey90") insert(content1) feed("ggzf3jj") if multigrid then @@ -239,6 +239,22 @@ describe("folded lines", function() | ]]) end + end + + describe("when 'cursorline' is set", function() + it('with high-priority CursorLine', function() + command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") + test_folded_cursorline() + end) + + it('with low-priority CursorLine', function() + command("hi! CursorLine guibg=NONE guifg=NONE gui=underline") + local attrs = screen:get_default_attr_ids() + attrs[12] = {underline = true} + attrs[13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true} + screen:set_default_attr_ids(attrs) + test_folded_cursorline() + end) end) it("work with spell", function() @@ -2017,7 +2033,8 @@ describe("folded lines", function() end end) - it('Folded highlight does not disappear in Visual selection #19691', function() + it('Folded and Visual highlights are combined #19691', function() + command('hi! Visual guibg=Red') insert([[ " foo " {{{1 @@ -2044,9 +2061,9 @@ describe("folded lines", function() [3:---------------------------------------------]| ## grid 2 {14:" fo}o | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" ba}r | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" b}^az | {1:~ }| {1:~ }| @@ -2056,9 +2073,9 @@ describe("folded lines", function() else screen:expect([[ {14:" fo}o | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" ba}r | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" b}^az | {1:~ }| {1:~ }| diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index b31e40d4ab..67e3b774b4 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -117,6 +117,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.title) end) + screen:detach() + screen.title = nil + screen:attach() + screen:expect(function() + eq(expected, screen.title) + end) end) end) @@ -128,6 +134,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.icon) end) + screen:detach() + screen.icon = nil + screen:attach() + screen:expect(function() + eq(expected, screen.icon) + end) end) end) diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 7f11b06f78..630d0d0948 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -28,6 +28,7 @@ describe("'spell'", function() [7] = {foreground = Screen.colors.Blue}, [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, [9] = {bold = true}, + [10] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, }) end) @@ -82,7 +83,7 @@ describe("'spell'", function() end) -- oldtest: Test_spell_screendump_spellcap() - it('has correct highlight at start of line with trailing space', function() + it('SpellCap highlight at start of line', function() exec([=[ call setline(1, [ \" This line has a sepll error. and missing caps and trailing spaces. ", @@ -117,7 +118,7 @@ describe("'spell'", function() | ]]) -- Deleting a full stop removes missing Cap in next line - feed('5Gddk$x') + feed('5Gdd<C-L>k$x') screen:expect([[ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | {2:another} missing cap here. | @@ -140,6 +141,43 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Folding an empty line does not remove Cap in next line + feed('uzfk:<Esc>') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + {10:^+-- 2 lines: and here.·························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Folding the end of a sentence does not remove Cap in next line + -- and editing a line does not remove Cap in current line + feed('Jzfkk$x') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + -- Cap is correctly applied in the first row of a window + feed('<C-E><C-L>') + screen:expect([[ + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) end) -- oldtest: Test_spell_compatible() diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index f349b182c9..c218bd8fd6 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -196,10 +196,10 @@ describe('statuscolumn', function() [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey}, [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, [4] = {bold = true, foreground = Screen.colors.Brown}, - [5] = {background = Screen.colors.Grey90, underline = true}, - [6] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, + [5] = {foreground = Screen.colors.Red}, + [6] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, }) - command('hi! CursorLine gui=underline guibg=Grey90') + command('hi! CursorLine guifg=Red guibg=NONE') screen:expect([[ {1: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1: │ }a | diff --git a/test/old/testdir/test_spell.vim b/test/old/testdir/test_spell.vim index 14d6ce30c4..b0b2668758 100644 --- a/test/old/testdir/test_spell.vim +++ b/test/old/testdir/test_spell.vim @@ -1003,13 +1003,26 @@ func Test_spell_screendump_spellcap() call VerifyScreenDump(buf, 'Test_spell_3', {}) " Deleting a full stop removes missing Cap in next line - call term_sendkeys(buf, "5Gddk$x") + call term_sendkeys(buf, "5Gdd\<C-L>k$x") call VerifyScreenDump(buf, 'Test_spell_4', {}) " Undo also updates the next line (go to command line to remove message) call term_sendkeys(buf, "u:\<Esc>") call VerifyScreenDump(buf, 'Test_spell_5', {}) + " Folding an empty line does not remove Cap in next line + call term_sendkeys(buf, "uzfk:\<Esc>") + call VerifyScreenDump(buf, 'Test_spell_6', {}) + + " Folding the end of a sentence does not remove Cap in next line + " and editing a line does not remove Cap in current line + call term_sendkeys(buf, "Jzfkk$x") + call VerifyScreenDump(buf, 'Test_spell_7', {}) + + " Cap is correctly applied in the first row of a window + call term_sendkeys(buf, "\<C-E>\<C-L>") + call VerifyScreenDump(buf, 'Test_spell_8', {}) + " clean up call StopVimInTerminal(buf) endfunc |