mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:partial:9.0.1166: code is indented more than necessary (#21716)
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11792)1cfb14aa97
Partial port as some highlight.c changes depend on previous patches. Cherry-pick fname_match() change from patch 8.2.4959. Omit internal_func_check_arg_types(): only used for Vim9 script. N/A patches for version.c: vim-patch:9.0.1167: EditorConfig files do not have their own filetype Problem: EditorConfig files do not have their own filetype. Solution: Add the "editorconfig" filetype. (Gregory Anders, closes vim/vim#11779)d41262ed06
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
364b131f42
commit
dc7edce650
@ -2676,19 +2676,20 @@ static int arg_augroup_get(char **argp)
|
||||
{
|
||||
char *p;
|
||||
char *arg = *argp;
|
||||
int group = AUGROUP_ALL;
|
||||
|
||||
for (p = arg; *p && !ascii_iswhite(*p) && *p != '|'; p++) {}
|
||||
if (p > arg) {
|
||||
char *group_name = xstrnsave(arg, (size_t)(p - arg));
|
||||
group = augroup_find(group_name);
|
||||
if (group == AUGROUP_ERROR) {
|
||||
group = AUGROUP_ALL; // no match, use all groups
|
||||
} else {
|
||||
*argp = skipwhite(p); // match, skip over group name
|
||||
}
|
||||
xfree(group_name);
|
||||
if (p <= arg) {
|
||||
return AUGROUP_ALL;
|
||||
}
|
||||
|
||||
char *group_name = xstrnsave(arg, (size_t)(p - arg));
|
||||
int group = augroup_find(group_name);
|
||||
if (group == AUGROUP_ERROR) {
|
||||
group = AUGROUP_ALL; // no match, use all groups
|
||||
} else {
|
||||
*argp = skipwhite(p); // match, skip over group name
|
||||
}
|
||||
xfree(group_name);
|
||||
return group;
|
||||
}
|
||||
|
||||
|
@ -359,8 +359,9 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg)
|
||||
}
|
||||
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, false, curbuf, &retval);
|
||||
|
||||
// if (retval != OK) {
|
||||
if (retval == FAIL) {
|
||||
return FAIL;
|
||||
return retval;
|
||||
}
|
||||
|
||||
// The autocommands may have changed the current buffer. Apply the
|
||||
@ -2473,19 +2474,22 @@ static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case)
|
||||
char *match = NULL;
|
||||
char *p;
|
||||
|
||||
if (name != NULL) {
|
||||
// Ignore case when 'fileignorecase' or the argument is set.
|
||||
rmp->rm_ic = p_fic || ignore_case;
|
||||
if (vim_regexec(rmp, name, (colnr_T)0)) {
|
||||
// extra check for valid arguments
|
||||
if (name == NULL || rmp->regprog == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Ignore case when 'fileignorecase' or the argument is set.
|
||||
rmp->rm_ic = p_fic || ignore_case;
|
||||
if (vim_regexec(rmp, name, (colnr_T)0)) {
|
||||
match = name;
|
||||
} else if (rmp->regprog != NULL) {
|
||||
// Replace $(HOME) with '~' and try matching again.
|
||||
p = home_replace_save(NULL, name);
|
||||
if (vim_regexec(rmp, p, (colnr_T)0)) {
|
||||
match = name;
|
||||
} else if (rmp->regprog != NULL) {
|
||||
// Replace $(HOME) with '~' and try matching again.
|
||||
p = home_replace_save(NULL, name);
|
||||
if (vim_regexec(rmp, p, (colnr_T)0)) {
|
||||
match = name;
|
||||
}
|
||||
xfree(p);
|
||||
}
|
||||
xfree(p);
|
||||
}
|
||||
|
||||
return match;
|
||||
@ -2592,17 +2596,18 @@ void buflist_setfpos(buf_T *const buf, win_T *const win, linenr_T lnum, colnr_T
|
||||
static bool wininfo_other_tab_diff(wininfo_T *wip)
|
||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (wip->wi_opt.wo_diff) {
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
// return false when it's a window in the current tab page, thus
|
||||
// the buffer was in diff mode here
|
||||
if (wip->wi_win == wp) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (!wip->wi_opt.wo_diff) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
// return false when it's a window in the current tab page, thus
|
||||
// the buffer was in diff mode here
|
||||
if (wip->wi_win == wp) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Find info for the current window in buffer "buf".
|
||||
@ -2625,25 +2630,27 @@ static wininfo_T *find_wininfo(buf_T *buf, bool need_options, bool skip_diff_buf
|
||||
}
|
||||
}
|
||||
|
||||
if (wip != NULL) {
|
||||
return wip;
|
||||
}
|
||||
|
||||
// If no wininfo for curwin, use the first in the list (that doesn't have
|
||||
// 'diff' set and is in another tab page).
|
||||
// If "need_options" is true skip entries that don't have options set,
|
||||
// unless the window is editing "buf", so we can copy from the window
|
||||
// itself.
|
||||
if (wip == NULL) {
|
||||
if (skip_diff_buffer) {
|
||||
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
|
||||
if (!wininfo_other_tab_diff(wip)
|
||||
&& (!need_options
|
||||
|| wip->wi_optset
|
||||
|| (wip->wi_win != NULL
|
||||
&& wip->wi_win->w_buffer == buf))) {
|
||||
break;
|
||||
}
|
||||
if (skip_diff_buffer) {
|
||||
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
|
||||
if (!wininfo_other_tab_diff(wip)
|
||||
&& (!need_options
|
||||
|| wip->wi_optset
|
||||
|| (wip->wi_win != NULL
|
||||
&& wip->wi_win->w_buffer == buf))) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
wip = buf->b_wininfo;
|
||||
}
|
||||
} else {
|
||||
wip = buf->b_wininfo;
|
||||
}
|
||||
return wip;
|
||||
}
|
||||
|
@ -1585,21 +1585,24 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
|
||||
case CMD_dsplit:
|
||||
// Skip count.
|
||||
arg = (const char *)skipwhite(skipdigits(arg));
|
||||
if (*arg == '/') { // Match regexp, not just whole words.
|
||||
for (++arg; *arg && *arg != '/'; arg++) {
|
||||
if (*arg == '\\' && arg[1] != NUL) {
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
if (*arg) {
|
||||
arg = (const char *)skipwhite(arg + 1);
|
||||
if (*arg != '/') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Check for trailing illegal characters.
|
||||
if (*arg == NUL || strchr("|\"\n", *arg) == NULL) {
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
// Match regexp, not just whole words.
|
||||
for (++arg; *arg && *arg != '/'; arg++) {
|
||||
if (*arg == '\\' && arg[1] != NUL) {
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
if (*arg) {
|
||||
arg = (const char *)skipwhite(arg + 1);
|
||||
|
||||
// Check for trailing illegal characters.
|
||||
if (*arg == NUL || strchr("|\"\n", *arg) == NULL) {
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -317,13 +317,15 @@ static int get_maxbacktrace_level(char *sname)
|
||||
{
|
||||
int maxbacktrace = 0;
|
||||
|
||||
if (sname != NULL) {
|
||||
char *p = sname;
|
||||
char *q;
|
||||
while ((q = strstr(p, "..")) != NULL) {
|
||||
p = q + 2;
|
||||
maxbacktrace++;
|
||||
}
|
||||
if (sname == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *p = sname;
|
||||
char *q;
|
||||
while ((q = strstr(p, "..")) != NULL) {
|
||||
p = q + 2;
|
||||
maxbacktrace++;
|
||||
}
|
||||
return maxbacktrace;
|
||||
}
|
||||
@ -458,20 +460,21 @@ void dbg_check_breakpoint(exarg_T *eap)
|
||||
/// @return true when the debug mode is entered this time.
|
||||
bool dbg_check_skipped(exarg_T *eap)
|
||||
{
|
||||
if (debug_skipped) {
|
||||
// Save the value of got_int and reset it. We don't want a previous
|
||||
// interruption cause flushing the input buffer.
|
||||
int prev_got_int = got_int;
|
||||
got_int = false;
|
||||
debug_breakpoint_name = debug_skipped_name;
|
||||
// eap->skip is true
|
||||
eap->skip = false;
|
||||
dbg_check_breakpoint(eap);
|
||||
eap->skip = true;
|
||||
got_int |= prev_got_int;
|
||||
return true;
|
||||
if (!debug_skipped) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Save the value of got_int and reset it. We don't want a previous
|
||||
// interruption cause flushing the input buffer.
|
||||
int prev_got_int = got_int;
|
||||
got_int = false;
|
||||
debug_breakpoint_name = debug_skipped_name;
|
||||
// eap->skip is true
|
||||
eap->skip = false;
|
||||
dbg_check_breakpoint(eap);
|
||||
eap->skip = true;
|
||||
got_int |= prev_got_int;
|
||||
return true;
|
||||
}
|
||||
|
||||
static garray_T dbg_breakp = { 0, 0, sizeof(struct debuggy), 4, NULL };
|
||||
|
@ -1528,30 +1528,31 @@ int get_digraph(bool cmdline)
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
|
||||
if (c != ESC) {
|
||||
if (c == ESC) { // ESC cancels CTRL-K
|
||||
return NUL;
|
||||
}
|
||||
|
||||
if (IS_SPECIAL(c)) {
|
||||
// insert special key code
|
||||
return c;
|
||||
}
|
||||
|
||||
if (cmdline) {
|
||||
if ((char2cells(c) == 1) && c < 128 && (cmdline_star == 0)) {
|
||||
putcmdline((char)c, true);
|
||||
}
|
||||
} else {
|
||||
add_to_showcmd(c);
|
||||
}
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
int cc = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
|
||||
if (cc != ESC) {
|
||||
// ESC cancels CTRL-K
|
||||
if (IS_SPECIAL(c)) {
|
||||
// insert special key code
|
||||
return c;
|
||||
}
|
||||
|
||||
if (cmdline) {
|
||||
if ((char2cells(c) == 1) && c < 128 && (cmdline_star == 0)) {
|
||||
putcmdline((char)c, true);
|
||||
}
|
||||
} else {
|
||||
add_to_showcmd(c);
|
||||
}
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
int cc = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
|
||||
if (cc != ESC) {
|
||||
// ESC cancels CTRL-K
|
||||
return digraph_get(c, cc, true);
|
||||
}
|
||||
return digraph_get(c, cc, true);
|
||||
}
|
||||
return NUL;
|
||||
}
|
||||
|
@ -859,14 +859,14 @@ static void f_cindent(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
win_T *get_optional_window(typval_T *argvars, int idx)
|
||||
{
|
||||
win_T *win = curwin;
|
||||
if (argvars[idx].v_type == VAR_UNKNOWN) {
|
||||
return curwin;
|
||||
}
|
||||
|
||||
if (argvars[idx].v_type != VAR_UNKNOWN) {
|
||||
win = find_win_by_nr_or_id(&argvars[idx]);
|
||||
if (win == NULL) {
|
||||
emsg(_(e_invalwindow));
|
||||
return NULL;
|
||||
}
|
||||
win_T *win = find_win_by_nr_or_id(&argvars[idx]);
|
||||
if (win == NULL) {
|
||||
emsg(_(e_invalwindow));
|
||||
return NULL;
|
||||
}
|
||||
return win;
|
||||
}
|
||||
@ -6109,55 +6109,57 @@ static int get_search_arg(typval_T *varp, int *flagsp)
|
||||
{
|
||||
int dir = FORWARD;
|
||||
|
||||
if (varp->v_type != VAR_UNKNOWN) {
|
||||
char nbuf[NUMBUFLEN];
|
||||
const char *flags = tv_get_string_buf_chk(varp, nbuf);
|
||||
if (flags == NULL) {
|
||||
return 0; // Type error; errmsg already given.
|
||||
}
|
||||
int mask;
|
||||
while (*flags != NUL) {
|
||||
switch (*flags) {
|
||||
case 'b':
|
||||
dir = BACKWARD; break;
|
||||
case 'w':
|
||||
p_ws = true; break;
|
||||
case 'W':
|
||||
p_ws = false; break;
|
||||
default:
|
||||
mask = 0;
|
||||
if (flagsp != NULL) {
|
||||
switch (*flags) {
|
||||
case 'c':
|
||||
mask = SP_START; break;
|
||||
case 'e':
|
||||
mask = SP_END; break;
|
||||
case 'm':
|
||||
mask = SP_RETCOUNT; break;
|
||||
case 'n':
|
||||
mask = SP_NOMOVE; break;
|
||||
case 'p':
|
||||
mask = SP_SUBPAT; break;
|
||||
case 'r':
|
||||
mask = SP_REPEAT; break;
|
||||
case 's':
|
||||
mask = SP_SETPCMARK; break;
|
||||
case 'z':
|
||||
mask = SP_COLUMN; break;
|
||||
}
|
||||
}
|
||||
if (mask == 0) {
|
||||
semsg(_(e_invarg2), flags);
|
||||
dir = 0;
|
||||
} else {
|
||||
*flagsp |= mask;
|
||||
if (varp->v_type == VAR_UNKNOWN) {
|
||||
return FORWARD;
|
||||
}
|
||||
|
||||
char nbuf[NUMBUFLEN];
|
||||
const char *flags = tv_get_string_buf_chk(varp, nbuf);
|
||||
if (flags == NULL) {
|
||||
return 0; // Type error; errmsg already given.
|
||||
}
|
||||
int mask;
|
||||
while (*flags != NUL) {
|
||||
switch (*flags) {
|
||||
case 'b':
|
||||
dir = BACKWARD; break;
|
||||
case 'w':
|
||||
p_ws = true; break;
|
||||
case 'W':
|
||||
p_ws = false; break;
|
||||
default:
|
||||
mask = 0;
|
||||
if (flagsp != NULL) {
|
||||
switch (*flags) {
|
||||
case 'c':
|
||||
mask = SP_START; break;
|
||||
case 'e':
|
||||
mask = SP_END; break;
|
||||
case 'm':
|
||||
mask = SP_RETCOUNT; break;
|
||||
case 'n':
|
||||
mask = SP_NOMOVE; break;
|
||||
case 'p':
|
||||
mask = SP_SUBPAT; break;
|
||||
case 'r':
|
||||
mask = SP_REPEAT; break;
|
||||
case 's':
|
||||
mask = SP_SETPCMARK; break;
|
||||
case 'z':
|
||||
mask = SP_COLUMN; break;
|
||||
}
|
||||
}
|
||||
if (dir == 0) {
|
||||
break;
|
||||
if (mask == 0) {
|
||||
semsg(_(e_invarg2), flags);
|
||||
dir = 0;
|
||||
} else {
|
||||
*flagsp |= mask;
|
||||
}
|
||||
flags++;
|
||||
}
|
||||
if (dir == 0) {
|
||||
break;
|
||||
}
|
||||
flags++;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
@ -46,31 +46,33 @@ static int win_getid(typval_T *argvars)
|
||||
}
|
||||
int winnr = (int)tv_get_number(&argvars[0]);
|
||||
win_T *wp;
|
||||
if (winnr > 0) {
|
||||
if (argvars[1].v_type == VAR_UNKNOWN) {
|
||||
wp = firstwin;
|
||||
} else {
|
||||
tabpage_T *tp = NULL;
|
||||
int tabnr = (int)tv_get_number(&argvars[1]);
|
||||
FOR_ALL_TABS(tp2) {
|
||||
if (--tabnr == 0) {
|
||||
tp = tp2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (tp == curtab) {
|
||||
wp = firstwin;
|
||||
} else {
|
||||
wp = tp->tp_firstwin;
|
||||
if (winnr <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argvars[1].v_type == VAR_UNKNOWN) {
|
||||
wp = firstwin;
|
||||
} else {
|
||||
tabpage_T *tp = NULL;
|
||||
int tabnr = (int)tv_get_number(&argvars[1]);
|
||||
FOR_ALL_TABS(tp2) {
|
||||
if (--tabnr == 0) {
|
||||
tp = tp2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; wp != NULL; wp = wp->w_next) {
|
||||
if (--winnr == 0) {
|
||||
return wp->handle;
|
||||
}
|
||||
if (tp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (tp == curtab) {
|
||||
wp = firstwin;
|
||||
} else {
|
||||
wp = tp->tp_firstwin;
|
||||
}
|
||||
}
|
||||
for (; wp != NULL; wp = wp->w_next) {
|
||||
if (--winnr == 0) {
|
||||
return wp->handle;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -288,16 +290,18 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar)
|
||||
}
|
||||
}
|
||||
|
||||
if (nr > 0) {
|
||||
for (win_T *wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
|
||||
wp != twin; wp = wp->w_next) {
|
||||
if (wp == NULL) {
|
||||
// didn't find it in this tabpage
|
||||
nr = 0;
|
||||
break;
|
||||
}
|
||||
nr++;
|
||||
if (nr <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (win_T *wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
|
||||
wp != twin; wp = wp->w_next) {
|
||||
if (wp == NULL) {
|
||||
// didn't find it in this tabpage
|
||||
nr = 0;
|
||||
break;
|
||||
}
|
||||
nr++;
|
||||
}
|
||||
return nr;
|
||||
}
|
||||
|
@ -4510,32 +4510,30 @@ void free_old_sub(void)
|
||||
/// @return true when it was created.
|
||||
bool prepare_tagpreview(bool undo_sync)
|
||||
{
|
||||
if (curwin->w_p_pvw) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is already a preview window open, use that one.
|
||||
if (!curwin->w_p_pvw) {
|
||||
bool found_win = false;
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
if (wp->w_p_pvw) {
|
||||
win_enter(wp, undo_sync);
|
||||
found_win = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found_win) {
|
||||
// There is no preview window open yet. Create one.
|
||||
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0)
|
||||
== FAIL) {
|
||||
return false;
|
||||
}
|
||||
curwin->w_p_pvw = true;
|
||||
curwin->w_p_wfh = true;
|
||||
RESET_BINDING(curwin); // don't take over 'scrollbind' and 'cursorbind'
|
||||
curwin->w_p_diff = false; // no 'diff'
|
||||
set_string_option_direct("fdc", -1, // no 'foldcolumn'
|
||||
"0", OPT_FREE, SID_NONE);
|
||||
return true;
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
if (wp->w_p_pvw) {
|
||||
win_enter(wp, undo_sync);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
// There is no preview window open yet. Create one.
|
||||
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0)
|
||||
== FAIL) {
|
||||
return false;
|
||||
}
|
||||
curwin->w_p_pvw = true;
|
||||
curwin->w_p_wfh = true;
|
||||
RESET_BINDING(curwin); // don't take over 'scrollbind' and 'cursorbind'
|
||||
curwin->w_p_diff = false; // no 'diff'
|
||||
set_string_option_direct("fdc", -1, // no 'foldcolumn'
|
||||
"0", OPT_FREE, SID_NONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Shows the effects of the :substitute command being typed ('inccommand').
|
||||
|
@ -4083,12 +4083,14 @@ static char *get_cmdline_completion(void)
|
||||
}
|
||||
CmdlineInfo *p = get_ccline_ptr();
|
||||
|
||||
if (p != NULL && p->xpc != NULL) {
|
||||
set_expand_context(p->xpc);
|
||||
char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
|
||||
if (cmd_compl != NULL) {
|
||||
return xstrdup(cmd_compl);
|
||||
}
|
||||
if (p == NULL || p->xpc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
set_expand_context(p->xpc);
|
||||
char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
|
||||
if (cmd_compl != NULL) {
|
||||
return xstrdup(cmd_compl);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -481,7 +481,7 @@ void foldCheckClose(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// can only be "all" right now
|
||||
// 'foldclose' can only be "all" right now
|
||||
checkupdate(curwin);
|
||||
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
|
||||
(int)curwin->w_p_fdl)) {
|
||||
|
@ -1549,35 +1549,38 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
|
||||
if (got_int) {
|
||||
return false;
|
||||
}
|
||||
if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0)) {
|
||||
const char *ts = buf;
|
||||
if (type == LIST_INT) {
|
||||
snprintf((char *)buf, sizeof(buf), "%d", iarg - 1);
|
||||
} else if (type == LIST_STRING) {
|
||||
ts = sarg;
|
||||
} else { // type == LIST_ATTR
|
||||
buf[0] = NUL;
|
||||
for (int i = 0; hl_attr_table[i] != 0; i++) {
|
||||
if (iarg & hl_attr_table[i]) {
|
||||
if (buf[0] != NUL) {
|
||||
xstrlcat(buf, ",", 100);
|
||||
}
|
||||
xstrlcat(buf, hl_name_table[i], 100);
|
||||
iarg &= ~hl_attr_table[i]; // don't want "inverse"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(void)syn_list_header(didh, vim_strsize((char *)ts) + (int)strlen(name) + 1, id, false);
|
||||
didh = true;
|
||||
if (!got_int) {
|
||||
if (*name != NUL) {
|
||||
msg_puts_attr(name, HL_ATTR(HLF_D));
|
||||
msg_puts_attr("=", HL_ATTR(HLF_D));
|
||||
if (type == LIST_STRING ? (sarg == NULL) : (iarg == 0)) {
|
||||
return didh;
|
||||
}
|
||||
|
||||
const char *ts = buf;
|
||||
if (type == LIST_INT) {
|
||||
snprintf((char *)buf, sizeof(buf), "%d", iarg - 1);
|
||||
} else if (type == LIST_STRING) {
|
||||
ts = sarg;
|
||||
} else { // type == LIST_ATTR
|
||||
buf[0] = NUL;
|
||||
for (int i = 0; hl_attr_table[i] != 0; i++) {
|
||||
if (iarg & hl_attr_table[i]) {
|
||||
if (buf[0] != NUL) {
|
||||
xstrlcat(buf, ",", 100);
|
||||
}
|
||||
xstrlcat(buf, hl_name_table[i], 100);
|
||||
iarg &= ~hl_attr_table[i]; // don't want "inverse"
|
||||
}
|
||||
msg_outtrans((char *)ts);
|
||||
}
|
||||
}
|
||||
|
||||
(void)syn_list_header(didh, vim_strsize((char *)ts) + (int)strlen(name) + 1, id, false);
|
||||
didh = true;
|
||||
if (!got_int) {
|
||||
if (*name != NUL) {
|
||||
msg_puts_attr(name, HL_ATTR(HLF_D));
|
||||
msg_puts_attr("=", HL_ATTR(HLF_D));
|
||||
}
|
||||
msg_outtrans((char *)ts);
|
||||
}
|
||||
return didh;
|
||||
}
|
||||
|
||||
@ -2125,36 +2128,44 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
|
||||
include_link = 2;
|
||||
include_default = 1;
|
||||
|
||||
if (*arg == NUL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// (part of) subcommand already typed
|
||||
if (*arg != NUL) {
|
||||
const char *p = (const char *)skiptowhite(arg);
|
||||
if (*p != NUL) { // Past "default" or group name.
|
||||
include_default = 0;
|
||||
if (strncmp("default", arg, (unsigned)(p - arg)) == 0) {
|
||||
arg = (const char *)skipwhite(p);
|
||||
xp->xp_pattern = (char *)arg;
|
||||
p = (const char *)skiptowhite(arg);
|
||||
}
|
||||
if (*p != NUL) { // past group name
|
||||
include_link = 0;
|
||||
if (arg[1] == 'i' && arg[0] == 'N') {
|
||||
highlight_list();
|
||||
}
|
||||
if (strncmp("link", arg, (unsigned)(p - arg)) == 0
|
||||
|| strncmp("clear", arg, (unsigned)(p - arg)) == 0) {
|
||||
xp->xp_pattern = skipwhite(p);
|
||||
p = (const char *)skiptowhite(xp->xp_pattern);
|
||||
if (*p != NUL) { // Past first group name.
|
||||
xp->xp_pattern = skipwhite(p);
|
||||
p = (const char *)skiptowhite(xp->xp_pattern);
|
||||
}
|
||||
}
|
||||
if (*p != NUL) { // Past group name(s).
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
}
|
||||
}
|
||||
const char *p = (const char *)skiptowhite(arg);
|
||||
if (*p == NUL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// past "default" or group name
|
||||
include_default = 0;
|
||||
if (strncmp("default", arg, (unsigned)(p - arg)) == 0) {
|
||||
arg = (const char *)skipwhite(p);
|
||||
xp->xp_pattern = (char *)arg;
|
||||
p = (const char *)skiptowhite(arg);
|
||||
}
|
||||
if (*p == NUL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// past group name
|
||||
include_link = 0;
|
||||
if (arg[1] == 'i' && arg[0] == 'N') {
|
||||
highlight_list();
|
||||
}
|
||||
if (strncmp("link", arg, (unsigned)(p - arg)) == 0
|
||||
|| strncmp("clear", arg, (unsigned)(p - arg)) == 0) {
|
||||
xp->xp_pattern = skipwhite(p);
|
||||
p = (const char *)skiptowhite(xp->xp_pattern);
|
||||
if (*p != NUL) { // past first group name
|
||||
xp->xp_pattern = skipwhite(p);
|
||||
p = (const char *)skiptowhite(xp->xp_pattern);
|
||||
}
|
||||
}
|
||||
if (*p != NUL) { // past group name(s)
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
/// List highlighting matches in a nice way.
|
||||
|
@ -356,6 +356,7 @@ bool cin_islabel(void) // XXX
|
||||
if (cin_isscopedecl((char_u *)s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!cin_islabel_skip(&s)) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user