From 064fdad98c6eed5f42b72eeeb3efe458fefb377d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 15 Jan 2023 06:40:49 +0800 Subject: vim-patch:8.2.4570: no command line completion for :profile and :profdel Problem: No command line completion for :profile and :profdel. Solution: Implement completion. (Yegappan Lakshmanan, closes vim/vim#9955) https://github.com/vim/vim/commit/1fdf84e033f8c4eead3b4ccebb1969cfbc7d10db Co-authored-by: Yegappan Lakshmanan --- src/nvim/cmdexpand.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/nvim/cmdexpand.c') diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 9d00851336..ca19d6de95 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1659,8 +1659,9 @@ static const char *set_context_in_lang_cmd(expand_T *xp, const char *arg) } static enum { - EXP_BREAKPT_ADD, // expand ":breakadd" sub-commands - EXP_BREAKPT_DEL, // expand ":breakdel" sub-commands + EXP_BREAKPT_ADD, ///< expand ":breakadd" sub-commands + EXP_BREAKPT_DEL, ///< expand ":breakdel" sub-commands + EXP_PROFDEL, ///< expand ":profdel" sub-commands } breakpt_expand_what; /// Set the completion context for the :breakadd command. Always returns NULL. @@ -1671,8 +1672,10 @@ static const char *set_context_in_breakadd_cmd(expand_T *xp, const char *arg, cm if (cmdidx == CMD_breakadd) { breakpt_expand_what = EXP_BREAKPT_ADD; - } else { + } else if (cmdidx == CMD_breakdel) { breakpt_expand_what = EXP_BREAKPT_DEL; + } else { + breakpt_expand_what = EXP_PROFDEL; } const char *p = skipwhite(arg); @@ -1681,8 +1684,7 @@ static const char *set_context_in_breakadd_cmd(expand_T *xp, const char *arg, cm } const char *subcmd_start = p; - if (strncmp("file ", p, 5) == 0 - || strncmp("func ", p, 5) == 0) { + if (strncmp("file ", p, 5) == 0 || strncmp("func ", p, 5) == 0) { // :breakadd file [lnum] // :breakadd func [lnum] p += 4; @@ -2067,6 +2069,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa break; case CMD_breakadd: + case CMD_profdel: case CMD_breakdel: return set_context_in_breakadd_cmd(xp, arg, cmdidx); @@ -2424,12 +2427,19 @@ static char *get_breakadd_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) char *opts[] = { "expr", "file", "func", "here" }; if (idx >= 0 && idx <= 3) { + // breakadd {expr, file, func, here} if (breakpt_expand_what == EXP_BREAKPT_ADD) { return opts[idx]; - } else { + } else if (breakpt_expand_what == EXP_BREAKPT_DEL) { + // breakdel {func, file, here} if (idx <= 2) { return opts[idx + 1]; } + } else { + // profdel {func, file} + if (idx <= 1) { + return opts[idx + 1]; + } } } return NULL; -- cgit