To: vim_dev@googlegroups.com Subject: Patch 8.2.4570 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4570 Problem: No command line completion for :profile and :profdel. Solution: Implement completion. (Yegappan Lakshmanan, closes #9955) Files: src/cmdexpand.c, src/profiler.c, src/testdir/test_cmdline.vim, src/testdir/test_profile.vim *** ../vim-8.2.4569/src/cmdexpand.c 2022-03-14 19:24:41.867926390 +0000 --- src/cmdexpand.c 2022-03-15 10:47:42.332248148 +0000 *************** *** 1606,1612 **** static enum { EXP_BREAKPT_ADD, // expand ":breakadd" sub-commands ! EXP_BREAKPT_DEL // expand ":breakdel" sub-commands } breakpt_expand_what; /* --- 1606,1613 ---- static enum { EXP_BREAKPT_ADD, // expand ":breakadd" sub-commands ! EXP_BREAKPT_DEL, // expand ":breakdel" sub-commands ! EXP_PROFDEL // expand ":profdel" sub-commands } breakpt_expand_what; /* *************** *** 1623,1638 **** if (cmdidx == CMD_breakadd) breakpt_expand_what = EXP_BREAKPT_ADD; ! else breakpt_expand_what = EXP_BREAKPT_DEL; p = skipwhite(arg); if (*p == NUL) return NULL; subcmd_start = p; ! if (STRNCMP("file ", p, 5) == 0 || ! STRNCMP("func ", p, 5) == 0) { // :breakadd file [lnum] // :breakadd func [lnum] --- 1624,1640 ---- if (cmdidx == CMD_breakadd) breakpt_expand_what = EXP_BREAKPT_ADD; ! else if (cmdidx == CMD_breakdel) breakpt_expand_what = EXP_BREAKPT_DEL; + else + breakpt_expand_what = EXP_PROFDEL; p = skipwhite(arg); if (*p == NUL) return NULL; subcmd_start = p; ! if (STRNCMP("file ", p, 5) == 0 || STRNCMP("func ", p, 5) == 0) { // :breakadd file [lnum] // :breakadd func [lnum] *************** *** 2025,2030 **** --- 2027,2033 ---- #ifdef FEAT_EVAL case CMD_breakadd: + case CMD_profdel: case CMD_breakdel: return set_context_in_breakadd_cmd(xp, arg, cmdidx); #endif *************** *** 2432,2444 **** if (idx >=0 && idx <= 3) { if (breakpt_expand_what == EXP_BREAKPT_ADD) return (char_u *)opts[idx]; ! else { if (idx <= 2) return (char_u *)opts[idx + 1]; } } return NULL; } --- 2435,2455 ---- if (idx >=0 && idx <= 3) { + // breakadd {expr, file, func, here} if (breakpt_expand_what == EXP_BREAKPT_ADD) return (char_u *)opts[idx]; ! else if (breakpt_expand_what == EXP_BREAKPT_DEL) { + // breakdel {func, file, here} if (idx <= 2) return (char_u *)opts[idx + 1]; } + else + { + // profdel {func, file} + if (idx <= 1) + return (char_u *)opts[idx + 1]; + } } return NULL; } *** ../vim-8.2.4569/src/profiler.c 2022-01-05 16:08:59.524426437 +0000 --- src/profiler.c 2022-03-15 10:47:42.332248148 +0000 *************** *** 376,382 **** { case PEXP_SUBCMD: return (char_u *)pexpand_cmds[idx]; - // case PEXP_FUNC: TODO default: return NULL; } --- 376,381 ---- *************** *** 399,412 **** if (*end_subcmd == NUL) return; ! if (end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0) { xp->xp_context = EXPAND_FILES; xp->xp_pattern = skipwhite(end_subcmd); return; } - // TODO: expand function names after "func" xp->xp_context = EXPAND_NOTHING; } --- 398,417 ---- if (*end_subcmd == NUL) return; ! if ((end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0) ! || (end_subcmd - arg == 4 && STRNCMP(arg, "file", 4) == 0)) { xp->xp_context = EXPAND_FILES; xp->xp_pattern = skipwhite(end_subcmd); return; } + else if (end_subcmd - arg == 4 && STRNCMP(arg, "func", 4) == 0) + { + xp->xp_context = EXPAND_USER_FUNC; + xp->xp_pattern = skipwhite(end_subcmd); + return; + } xp->xp_context = EXPAND_NOTHING; } *** ../vim-8.2.4569/src/testdir/test_cmdline.vim 2022-03-14 19:24:41.867926390 +0000 --- src/testdir/test_cmdline.vim 2022-03-15 10:47:42.332248148 +0000 *************** *** 3158,3164 **** call assert_equal("\"breakdel here Xtest", @:) call feedkeys(":breakdel here \\\"\", 'tx') call assert_equal("\"breakdel here ", @:) - endfunc " vim: shiftwidth=2 sts=2 expandtab --- 3158,3163 ---- *** ../vim-8.2.4569/src/testdir/test_profile.vim 2022-01-29 21:45:30.485921485 +0000 --- src/testdir/test_profile.vim 2022-03-15 10:47:42.332248148 +0000 *************** *** 434,439 **** --- 434,480 ---- call feedkeys(":profile start test_prof\\\"\", 'tx') call assert_match('^"profile start.* test_profile\.vim', @:) + + call feedkeys(":profile file test_prof\\\"\", 'tx') + call assert_match('"profile file test_profile\.vim', @:) + call feedkeys(":profile file test_prof\\\"\", 'tx') + call assert_match('"profile file test_profile\.vim', @:) + call feedkeys(":profile file test_prof \\\"\", 'tx') + call assert_match('"profile file test_prof ', @:) + call feedkeys(":profile file X1B2C3\\\"\", 'tx') + call assert_match('"profile file X1B2C3', @:) + + func Xprof_test() + endfunc + call feedkeys(":profile func Xprof\\\"\", 'tx') + call assert_equal('"profile func Xprof_test', @:) + call feedkeys(":profile func Xprof\\\"\", 'tx') + call assert_equal('"profile func Xprof_test', @:) + call feedkeys(":profile func Xprof \\\"\", 'tx') + call assert_equal('"profile func Xprof ', @:) + call feedkeys(":profile func X1B2C3\\\"\", 'tx') + call assert_equal('"profile func X1B2C3', @:) + + call feedkeys(":profdel \\\"\", 'tx') + call assert_equal('"profdel file func', @:) + call feedkeys(":profdel fu\\\"\", 'tx') + call assert_equal('"profdel func', @:) + call feedkeys(":profdel he\\\"\", 'tx') + call assert_equal('"profdel he', @:) + call feedkeys(":profdel here \\\"\", 'tx') + call assert_equal('"profdel here ', @:) + call feedkeys(":profdel file test_prof\\\"\", 'tx') + call assert_equal('"profdel file test_profile.vim', @:) + call feedkeys(":profdel file X1B2C3\\\"\", 'tx') + call assert_equal('"profdel file X1B2C3', @:) + call feedkeys(":profdel func Xprof\\\"\", 'tx') + call assert_equal('"profdel func Xprof_test', @:) + call feedkeys(":profdel func Xprof_test \\\"\", 'tx') + call assert_equal('"profdel func Xprof_test ', @:) + call feedkeys(":profdel func X1B2C3\\\"\", 'tx') + call assert_equal('"profdel func X1B2C3', @:) + + delfunc Xprof_test endfunc func Test_profile_errors() *** ../vim-8.2.4569/src/version.c 2022-03-15 10:22:35.067373154 +0000 --- src/version.c 2022-03-15 10:50:12.819872759 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4570, /**/ -- XML is a nice language for computers. Not for humans. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///