Compare commits

..

1 Commits

Author SHA1 Message Date
Brian Walshe
fa5110b18b
Merge 5b410d1e49 into 0dd933265f 2024-12-17 14:09:47 +00:00
14 changed files with 34 additions and 286 deletions

View File

@ -60,7 +60,6 @@ hi('PmenuMatch', { link = 'Pmenu' })
hi('PmenuMatchSel', { link = 'PmenuSel' }) hi('PmenuMatchSel', { link = 'PmenuSel' })
hi('PmenuExtra', { link = 'Pmenu' }) hi('PmenuExtra', { link = 'Pmenu' })
hi('PmenuExtraSel', { link = 'PmenuSel' }) hi('PmenuExtraSel', { link = 'PmenuSel' })
hi('ComplMatchIns', { link = 'Normal' })
hi('Substitute', { link = 'Search' }) hi('Substitute', { link = 'Search' })
hi('Whitespace', { link = 'NonText' }) hi('Whitespace', { link = 'NonText' })
hi('MsgSeparator', { link = 'StatusLine' }) hi('MsgSeparator', { link = 'StatusLine' })

View File

@ -101,8 +101,7 @@ The result of foldexpr then determines the fold level as follows:
"<1", "<2", .. a fold with this level ends at this line "<1", "<2", .. a fold with this level ends at this line
">1", ">2", .. a fold with this level starts at this line ">1", ">2", .. a fold with this level starts at this line
The result values "=", "s" and "a" are more expensive, please see The result values "=", "s" and "a" are more expensive, please see |fold-expr-slow|.
|fold-expr-slow|.
It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
will also start (end) when the fold level is higher (lower) than the fold will also start (end) when the fold level is higher (lower) than the fold
@ -118,7 +117,7 @@ For debugging the 'debug' option can be set to "msg", the error messages will
be visible then. be visible then.
If the 'foldexpr' expression starts with s: or |<SID>|, then it is replaced If the 'foldexpr' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Examples: > with the script ID (|local-function|). Examples: >
set foldexpr=s:MyFoldExpr() set foldexpr=s:MyFoldExpr()
set foldexpr=<SID>SomeFoldExpr() set foldexpr=<SID>SomeFoldExpr()
< <
@ -142,7 +141,7 @@ end in that line.
It may happen that folds are not updated properly. You can use |zx| or |zX| It may happen that folds are not updated properly. You can use |zx| or |zX|
to force updating folds. to force updating folds.
MINIMIZING COMPUTATIONAL COST *fold-expr-slow* Minimizing Computational Cost *fold-expr-slow*
Due to its computational cost, this fold method can make Vim unresponsive, Due to its computational cost, this fold method can make Vim unresponsive,
especially when the fold level of all lines have to be initially computed. especially when the fold level of all lines have to be initially computed.
@ -150,15 +149,13 @@ Afterwards, after each change, Vim restricts the computation of foldlevels
to those lines whose fold level was affected by it (and reuses the known to those lines whose fold level was affected by it (and reuses the known
foldlevels of all the others). foldlevels of all the others).
The fold expression should therefore strive to minimize the number of The fold expression should therefore strive to minimize the number of dependent
dependent lines needed for the computation of a given line: For example, try lines needed for the computation of a given line: For example, try to avoid the
to avoid the "=", "a" and "s" return values, because these will require the "=", "a" and "s" return values, because these will require the evaluation of the
evaluation of the fold levels on previous lines until an independent fold fold levels on previous lines until an independent fold level is found.
level is found.
If this proves difficult, the next best thing could be to cache all fold If this proves difficult, the next best thing could be to cache all fold levels
levels in a buffer-local variable (b:foldlevels) that is only updated on in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick|:
|b:changedtick|:
>vim >vim
func MyFoldFunc() func MyFoldFunc()
if b:lasttick == b:changedtick if b:lasttick == b:changedtick
@ -409,8 +406,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
Also forces recomputing folds, like |zx|. Also forces recomputing folds, like |zx|.
*zm* *zm*
zm Fold more: Subtract |v:count1| from 'foldlevel'. If zm Fold more: Subtract |v:count1| from 'foldlevel'. If 'foldlevel' was
'foldlevel' was already zero nothing happens. already zero nothing happens.
'foldenable' will be set. 'foldenable' will be set.
*zM* *zM*
@ -474,7 +471,7 @@ zk Move upwards to the end of the previous fold. A closed fold
EXECUTING COMMANDS ON FOLDS ~ EXECUTING COMMANDS ON FOLDS ~
:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen* :[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
Execute {cmd} on all lines that are not in a closed fold. Execute {cmd} on all lines that are not in a closed fold.
When [range] is given, only these lines are used. When [range] is given, only these lines are used.
Each time {cmd} is executed the cursor is positioned on the Each time {cmd} is executed the cursor is positioned on the
@ -562,7 +559,7 @@ When there is room after the text, it is filled with the character specified
by 'fillchars'. by 'fillchars'.
If the 'foldtext' expression starts with s: or |<SID>|, then it is replaced If the 'foldtext' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Examples: > with the script ID (|local-function|). Examples: >
set foldtext=s:MyFoldText() set foldtext=s:MyFoldText()
set foldtext=<SID>SomeFoldText() set foldtext=<SID>SomeFoldText()
< <

View File

@ -118,8 +118,8 @@ Note that when using ":" any motion becomes charwise exclusive.
*inclusive-motion-selection-exclusive* *inclusive-motion-selection-exclusive*
When 'selection' is "exclusive", |Visual| mode is active and an inclusive When 'selection' is "exclusive", |Visual| mode is active and an inclusive
motion has been used, the cursor position will be adjusted by another motion has been used, the cursor position will be adjusted by another
character to the right, so that the Visual selection includes the expected character to the right, so that visual selction includes the expected text and
text and can be acted upon. can be acted upon.
*forced-motion* *forced-motion*
FORCING A MOTION TO BE LINEWISE, CHARWISE OR BLOCKWISE FORCING A MOTION TO BE LINEWISE, CHARWISE OR BLOCKWISE

View File

@ -216,7 +216,6 @@ EDITOR
• On Windows, filename arguments on the command-line prefixed with "~\" or • On Windows, filename arguments on the command-line prefixed with "~\" or
"~/" are now expanded to the user's profile directory, not a relative path "~/" are now expanded to the user's profile directory, not a relative path
to a literal "~" directory. to a literal "~" directory.
• |hl-ComplMatchIns| shows matched text of the currently inserted completion.
• |hl-PmenuMatch| and |hl-PmenuMatchSel| show matched text in completion popup. • |hl-PmenuMatch| and |hl-PmenuMatchSel| show matched text in completion popup.
• |:read:| reads the output of an Ex command into the buffer. Example:> • |:read:| reads the output of an Ex command into the buffer. Example:>
:read :ls :read :ls

View File

@ -5243,8 +5243,6 @@ PmenuMatch Popup menu: Matched text in normal item. Combined with
*hl-PmenuMatchSel* *hl-PmenuMatchSel*
PmenuMatchSel Popup menu: Matched text in selected item. Combined with PmenuMatchSel Popup menu: Matched text in selected item. Combined with
|hl-PmenuMatch| and |hl-PmenuSel|. |hl-PmenuMatch| and |hl-PmenuSel|.
*hl-ComplMatchIns*
ComplMatchIns Matched text of the currently inserted completion.
*hl-Question* *hl-Question*
Question |hit-enter| prompt and yes/no questions. Question |hit-enter| prompt and yes/no questions.
*hl-QuickFixLine* *hl-QuickFixLine*

View File

@ -31,7 +31,6 @@
#include "nvim/highlight_defs.h" #include "nvim/highlight_defs.h"
#include "nvim/highlight_group.h" #include "nvim/highlight_group.h"
#include "nvim/indent.h" #include "nvim/indent.h"
#include "nvim/insexpand.h"
#include "nvim/mark_defs.h" #include "nvim/mark_defs.h"
#include "nvim/marktree_defs.h" #include "nvim/marktree_defs.h"
#include "nvim/match.h" #include "nvim/match.h"
@ -935,7 +934,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
colnr_T vcol_prev = -1; // "wlv.vcol" of previous character colnr_T vcol_prev = -1; // "wlv.vcol" of previous character
ScreenGrid *grid = &wp->w_grid; // grid specific to the window ScreenGrid *grid = &wp->w_grid; // grid specific to the window
const bool in_curline = wp == curwin && lnum == curwin->w_cursor.lnum;
const bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0; const bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0;
const bool has_foldtext = has_fold && *wp->w_p_fdt != NUL; const bool has_foldtext = has_fold && *wp->w_p_fdt != NUL;
@ -1119,7 +1117,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
} }
// Check if the char under the cursor should be inverted (highlighted). // Check if the char under the cursor should be inverted (highlighted).
if (!highlight_match && in_curline if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin
&& cursor_is_block_during_visual(*p_sel == 'e')) { && cursor_is_block_during_visual(*p_sel == 'e')) {
noinvcur = true; noinvcur = true;
} }
@ -1631,7 +1629,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
} }
// When still displaying '$' of change command, stop at cursor. // When still displaying '$' of change command, stop at cursor.
if (dollar_vcol >= 0 && in_curline && wlv.vcol >= wp->w_virtcol) { if (dollar_vcol >= 0 && wp == curwin
&& lnum == wp->w_cursor.lnum && wlv.vcol >= wp->w_virtcol) {
draw_virt_text(wp, buf, win_col_offset, &wlv.col, wlv.row); draw_virt_text(wp, buf, win_col_offset, &wlv.col, wlv.row);
// don't clear anything after wlv.col // don't clear anything after wlv.col
wlv_put_linebuf(wp, &wlv, wlv.col, false, bg_attr, 0); wlv_put_linebuf(wp, &wlv, wlv.col, false, bg_attr, 0);
@ -1787,16 +1786,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
wlv.char_attr = hl_combine_attr(char_attr_base, char_attr_pri); wlv.char_attr = hl_combine_attr(char_attr_base, char_attr_pri);
} }
// Apply ComplMatchIns highlight if needed.
if (wlv.filler_todo <= 0
&& (State & MODE_INSERT) && in_curline && ins_compl_active()) {
int ins_match_attr = ins_compl_col_range_attr((int)(ptr - line));
if (ins_match_attr > 0) {
char_attr_pri = hl_combine_attr(char_attr_pri, ins_match_attr);
wlv.char_attr = hl_combine_attr(char_attr_base, char_attr_pri);
}
}
if (draw_folded && has_foldtext && wlv.n_extra == 0 && wlv.col == win_col_offset) { if (draw_folded && has_foldtext && wlv.n_extra == 0 && wlv.col == win_col_offset) {
const int v = (int)(ptr - line); const int v = (int)(ptr - line);
linenr_T lnume = lnum + foldinfo.fi_lines - 1; linenr_T lnume = lnum + foldinfo.fi_lines - 1;
@ -2457,7 +2446,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
// With 'virtualedit' we may never reach cursor position, but we still // With 'virtualedit' we may never reach cursor position, but we still
// need to correct the cursor column, so do that at end of line. // need to correct the cursor column, so do that at end of line.
if (!did_wcol && wlv.filler_todo <= 0 if (!did_wcol && wlv.filler_todo <= 0
&& in_curline && conceal_cursor_line(wp) && wp == curwin && lnum == wp->w_cursor.lnum
&& conceal_cursor_line(wp)
&& (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) { && (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) {
wp->w_wcol = wlv.col - wlv.boguscols; wp->w_wcol = wlv.col - wlv.boguscols;
if (wlv.vcol + wlv.skip_cells < wp->w_virtcol) { if (wlv.vcol + wlv.skip_cells < wp->w_virtcol) {
@ -2650,7 +2640,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
// Update w_cline_height and w_cline_folded if the cursor line was // Update w_cline_height and w_cline_folded if the cursor line was
// updated (saves a call to plines_win() later). // updated (saves a call to plines_win() later).
if (in_curline) { if (wp == curwin && lnum == curwin->w_cursor.lnum) {
curwin->w_cline_row = startrow; curwin->w_cline_row = startrow;
curwin->w_cline_height = wlv.row - startrow; curwin->w_cline_height = wlv.row - startrow;
curwin->w_cline_folded = has_fold; curwin->w_cline_folded = has_fold;

View File

@ -173,7 +173,6 @@ static const char *highlight_init_both[] = {
"default link PmenuKind Pmenu", "default link PmenuKind Pmenu",
"default link PmenuKindSel PmenuSel", "default link PmenuKindSel PmenuSel",
"default link PmenuSbar Pmenu", "default link PmenuSbar Pmenu",
"default link ComplMatchIns Normal",
"default link Substitute Search", "default link Substitute Search",
"default link StatusLineTerm StatusLine", "default link StatusLineTerm StatusLine",
"default link StatusLineTermNC StatusLineNC", "default link StatusLineTermNC StatusLineNC",

View File

@ -256,7 +256,6 @@ static pos_T compl_startpos;
static int compl_length = 0; static int compl_length = 0;
static colnr_T compl_col = 0; ///< column where the text starts static colnr_T compl_col = 0; ///< column where the text starts
///< that is being completed ///< that is being completed
static colnr_T compl_ins_end_col = 0;
static char *compl_orig_text = NULL; ///< text as it was before static char *compl_orig_text = NULL; ///< text as it was before
///< completion started ///< completion started
/// Undo information to restore extmarks for original text. /// Undo information to restore extmarks for original text.
@ -283,11 +282,6 @@ static size_t spell_bad_len = 0; // length of located bad word
static int compl_selected_item = -1; static int compl_selected_item = -1;
// "compl_match_array" points the currently displayed list of entries in the
// popup menu. It is NULL when there is no popup menu.
static pumitem_T *compl_match_array = NULL;
static int compl_match_arraysize;
/// CTRL-X pressed in Insert mode. /// CTRL-X pressed in Insert mode.
void ins_ctrl_x(void) void ins_ctrl_x(void)
{ {
@ -949,30 +943,6 @@ static bool ins_compl_equal(compl_T *match, char *str, size_t len)
return strncmp(match->cp_str, str, len) == 0; return strncmp(match->cp_str, str, len) == 0;
} }
/// when len is -1 mean use whole length of p otherwise part of p
static void ins_compl_insert_bytes(char *p, int len)
FUNC_ATTR_NONNULL_ALL
{
if (len == -1) {
len = (int)strlen(p);
}
assert(len >= 0);
ins_bytes_len(p, (size_t)len);
compl_ins_end_col = curwin->w_cursor.col - 1;
}
/// Checks if the column is within the currently inserted completion text
/// column range. If it is, it returns a special highlight attribute.
/// -1 mean normal item.
int ins_compl_col_range_attr(int col)
{
if (col >= compl_col && col < compl_ins_end_col) {
return syn_name2attr("ComplMatchIns");
}
return -1;
}
/// Reduce the longest common string for match "match". /// Reduce the longest common string for match "match".
static void ins_compl_longest_match(compl_T *match) static void ins_compl_longest_match(compl_T *match)
{ {
@ -982,7 +952,7 @@ static void ins_compl_longest_match(compl_T *match)
bool had_match = (curwin->w_cursor.col > compl_col); bool had_match = (curwin->w_cursor.col > compl_col);
ins_compl_delete(false); ins_compl_delete(false);
ins_compl_insert_bytes(compl_leader + get_compl_len(), -1); ins_bytes(compl_leader + get_compl_len());
ins_redraw(false); ins_redraw(false);
// When the match isn't there (to avoid matching itself) remove it // When the match isn't there (to avoid matching itself) remove it
@ -1016,7 +986,7 @@ static void ins_compl_longest_match(compl_T *match)
*p = NUL; *p = NUL;
bool had_match = (curwin->w_cursor.col > compl_col); bool had_match = (curwin->w_cursor.col > compl_col);
ins_compl_delete(false); ins_compl_delete(false);
ins_compl_insert_bytes(compl_leader + get_compl_len(), -1); ins_bytes(compl_leader + get_compl_len());
ins_redraw(false); ins_redraw(false);
// When the match isn't there (to avoid matching itself) remove it // When the match isn't there (to avoid matching itself) remove it
@ -1088,6 +1058,11 @@ unsigned get_cot_flags(void)
return curbuf->b_cot_flags != 0 ? curbuf->b_cot_flags : cot_flags; return curbuf->b_cot_flags != 0 ? curbuf->b_cot_flags : cot_flags;
} }
/// "compl_match_array" points the currently displayed list of entries in the
/// popup menu. It is NULL when there is no popup menu.
static pumitem_T *compl_match_array = NULL;
static int compl_match_arraysize;
/// Remove any popup menu. /// Remove any popup menu.
static void ins_compl_del_pum(void) static void ins_compl_del_pum(void)
{ {
@ -1703,7 +1678,6 @@ void ins_compl_clear(void)
compl_cont_status = 0; compl_cont_status = 0;
compl_started = false; compl_started = false;
compl_matches = 0; compl_matches = 0;
compl_ins_end_col = 0;
XFREE_CLEAR(compl_pattern); XFREE_CLEAR(compl_pattern);
compl_patternlen = 0; compl_patternlen = 0;
XFREE_CLEAR(compl_leader); XFREE_CLEAR(compl_leader);
@ -1828,7 +1802,7 @@ static void ins_compl_new_leader(void)
{ {
ins_compl_del_pum(); ins_compl_del_pum();
ins_compl_delete(true); ins_compl_delete(true);
ins_compl_insert_bytes(compl_leader + get_compl_len(), -1); ins_bytes(compl_leader + get_compl_len());
compl_used_match = false; compl_used_match = false;
if (compl_started) { if (compl_started) {
@ -2163,7 +2137,7 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
const int compl_len = get_compl_len(); const int compl_len = get_compl_len();
const int len = (int)strlen(p); const int len = (int)strlen(p);
if (len > compl_len) { if (len > compl_len) {
ins_compl_insert_bytes(p + compl_len, len - compl_len); ins_bytes_len(p + compl_len, (size_t)(len - compl_len));
} }
} }
restore_orig_extmarks(); restore_orig_extmarks();
@ -3665,7 +3639,7 @@ void ins_compl_insert(bool in_compl_func)
// Make sure we don't go over the end of the string, this can happen with // Make sure we don't go over the end of the string, this can happen with
// illegal bytes. // illegal bytes.
if (compl_len < (int)strlen(compl_shown_match->cp_str)) { if (compl_len < (int)strlen(compl_shown_match->cp_str)) {
ins_compl_insert_bytes(compl_shown_match->cp_str + compl_len, -1); ins_bytes(compl_shown_match->cp_str + compl_len);
} }
compl_used_match = !match_at_original_text(compl_shown_match); compl_used_match = !match_at_original_text(compl_shown_match);
@ -3914,15 +3888,14 @@ static int ins_compl_next(bool allow_get_expansion, int count, bool insert_match
// Insert the text of the new completion, or the compl_leader. // Insert the text of the new completion, or the compl_leader.
if (compl_no_insert && !started) { if (compl_no_insert && !started) {
ins_compl_insert_bytes(compl_orig_text + get_compl_len(), -1); ins_bytes(compl_orig_text + get_compl_len());
compl_used_match = false; compl_used_match = false;
restore_orig_extmarks(); restore_orig_extmarks();
} else if (insert_match) { } else if (insert_match) {
if (!compl_get_longest || compl_used_match) { if (!compl_get_longest || compl_used_match) {
ins_compl_insert(in_compl_func); ins_compl_insert(in_compl_func);
} else { } else {
assert(compl_leader != NULL); ins_bytes(compl_leader + get_compl_len());
ins_compl_insert_bytes(compl_leader + get_compl_len(), -1);
} }
if (!strcmp(compl_curr_match->cp_str, compl_orig_text)) { if (!strcmp(compl_curr_match->cp_str, compl_orig_text)) {
restore_orig_extmarks(); restore_orig_extmarks();

View File

@ -35,7 +35,6 @@
#include "nvim/strings.h" #include "nvim/strings.h"
#include "nvim/textformat.h" #include "nvim/textformat.h"
#include "nvim/textobject.h" #include "nvim/textobject.h"
#include "nvim/ui.h"
#include "nvim/undo.h" #include "nvim/undo.h"
#include "nvim/vim_defs.h" #include "nvim/vim_defs.h"
#include "nvim/window.h" #include "nvim/window.h"
@ -1050,18 +1049,12 @@ void format_lines(linenr_T line_count, bool avoid_fex)
State = MODE_INSERT; // for open_line() State = MODE_INSERT; // for open_line()
smd_save = p_smd; smd_save = p_smd;
p_smd = false; p_smd = false;
insertchar(NUL, INSCHAR_FORMAT insertchar(NUL, INSCHAR_FORMAT
+ (do_comments ? INSCHAR_DO_COM : 0) + (do_comments ? INSCHAR_DO_COM : 0)
+ (do_comments && do_comments_list ? INSCHAR_COM_LIST : 0) + (do_comments && do_comments_list ? INSCHAR_COM_LIST : 0)
+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent); + (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
State = old_State; State = old_State;
p_smd = smd_save; p_smd = smd_save;
// Cursor shape may have been updated (e.g. by :normal) in insertchar(),
// so it needs to be updated here.
ui_cursor_shape();
second_indent = -1; second_indent = -1;
// at end of par.: need to set indent of next par. // at end of par.: need to set indent of next par.
need_set_indent = is_end_par; need_set_indent = is_end_par;

View File

@ -94,46 +94,6 @@ describe('ui mode_change event', function()
} }
end) end)
-- oldtest: Test_indent_norm_with_gq()
it('is restored to Normal mode after "gq" indents using :normal #12309', function()
screen:try_resize(60, 6)
n.exec([[
func Indent()
exe "normal! \<Ignore>"
return 0
endfunc
setlocal indentexpr=Indent()
call setline(1, [repeat('a', 80), repeat('b', 80)])
]])
feed('ggVG')
screen:expect {
grid = [[
{17:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{17:aaaaaaaaaaaaaaaaaaaa} |
^b{17:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}|
{17:bbbbbbbbbbbbbbbbbbbb} |
{1:~ }|
{5:-- VISUAL LINE --} |
]],
mode = 'visual',
}
feed('gq')
screen:expect {
grid = [[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
aaaaaaaaaaaaaaaaaaaa |
^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
bbbbbbbbbbbbbbbbbbbb |
{1:~ }|
|
]],
mode = 'normal',
}
end)
it('works in insert mode', function() it('works in insert mode', function()
feed('i') feed('i')
screen:expect { screen:expect {

View File

@ -5561,71 +5561,6 @@ describe('builtin popupmenu', function()
]]) ]])
feed('<C-E><ESC>') feed('<C-E><ESC>')
end) end)
-- oldtest: Test_pum_matchins_highlight()
it('with ComplMatchIns highlight', function()
exec([[
func Omni_test(findstart, base)
if a:findstart
return col(".")
endif
return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
endfunc
set omnifunc=Omni_test
hi ComplMatchIns guifg=red
]])
feed('Sαβγ <C-X><C-O>')
screen:expect([[
αβγ {8:foo}^ |
{1:~ }{s: foo }{1: }|
{1:~ }{n: bar }{1: }|
{1:~ }{n: }{1: }|
{1:~ }|*15
{2:-- }{5:match 1 of 3} |
]])
feed('<C-E><Esc>')
feed('Sαβγ <C-X><C-O><C-N>')
screen:expect([[
αβγ {8:bar}^ |
{1:~ }{n: foo }{1: }|
{1:~ }{s: bar }{1: }|
{1:~ }{n: }{1: }|
{1:~ }|*15
{2:-- }{5:match 2 of 3} |
]])
feed('<C-E><Esc>')
feed('Sαβγ <C-X><C-O><C-N><C-N>')
screen:expect([[
αβγ {8:}^ |
{1:~ }{n: foo }{1: }|
{1:~ }{n: bar }{1: }|
{1:~ }{s: }{1: }|
{1:~ }|*15
{2:-- }{5:match 3 of 3} |
]])
feed('<C-E><Esc>')
-- restore after accept
feed('Sαβγ <C-X><C-O><C-Y>')
screen:expect([[
αβγ foo^ |
{1:~ }|*18
{2:-- INSERT --} |
]])
feed('<Esc>')
-- restore after cancel completion
feed('Sαβγ <C-X><C-O><Space>')
screen:expect([[
αβγ foo ^ |
{1:~ }|*18
{2:-- INSERT --} |
]])
feed('<Esc>')
end)
end end
end end

View File

@ -1,8 +1,5 @@
" Test for various indent options " Test for various indent options
source shared.vim
source check.vim
func Test_preserveindent() func Test_preserveindent()
new new
" Test for autoindent copying indent from the previous line " Test for autoindent copying indent from the previous line
@ -306,50 +303,4 @@ func Test_indent_overflow_count2()
close! close!
endfunc endfunc
" Test that mouse shape is restored to Normal mode after using "gq" when
" 'indentexpr' executes :normal.
func Test_indent_norm_with_gq()
CheckFeature mouseshape
CheckCanRunGui
let lines =<< trim END
func Indent()
exe "normal! \<Ignore>"
return 0
endfunc
setlocal indentexpr=Indent()
END
call writefile(lines, 'Xindentexpr.vim', 'D')
let lines =<< trim END
vim9script
var mouse_shapes = []
setline(1, [repeat('a', 80), repeat('b', 80)])
feedkeys('ggVG')
timer_start(50, (_) => {
mouse_shapes += [getmouseshape()]
timer_start(50, (_) => {
feedkeys('gq')
timer_start(50, (_) => {
mouse_shapes += [getmouseshape()]
timer_start(50, (_) => {
writefile(mouse_shapes, 'Xmouseshapes')
quit!
})
})
})
})
END
call writefile(lines, 'Xmouseshape.vim', 'D')
call RunVim([], [], "-g -S Xindentexpr.vim -S Xmouseshape.vim")
call WaitForAssert({-> assert_equal(['rightup-arrow', 'arrow'],
\ readfile('Xmouseshapes'))}, 300)
call delete('Xmouseshapes')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -1713,49 +1713,4 @@ func Test_pum_keep_select()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc
func Test_pum_matchins_highlight()
CheckScreendump
let lines =<< trim END
func Omni_test(findstart, base)
if a:findstart
return col(".")
endif
return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
endfunc
set omnifunc=Omni_test
hi ComplMatchIns ctermfg=red
END
call writefile(lines, 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {})
call TermWait(buf)
call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>")
call VerifyScreenDump(buf, 'Test_pum_matchins_01', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf)
call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_02', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf)
call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_03', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
" restore after accept
call TermWait(buf)
call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-Y>")
call VerifyScreenDump(buf, 'Test_pum_matchins_04', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
" restore after cancel completion
call TermWait(buf)
call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<Space>")
call VerifyScreenDump(buf, 'Test_pum_matchins_05', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -59,8 +59,7 @@ func Test_window_preview_terminal()
CheckFeature quickfix CheckFeature quickfix
" CheckFeature terminal " CheckFeature terminal
" term ++curwin term " ++curwin
term
const buf_num = bufnr('$') const buf_num = bufnr('$')
call assert_equal(1, winnr('$')) call assert_equal(1, winnr('$'))
exe 'pbuffer' . buf_num exe 'pbuffer' . buf_num