forked from aniani/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 #9955)
This commit is contained in:
		
				
					committed by
					
						 Bram Moolenaar
						Bram Moolenaar
					
				
			
			
				
	
			
			
			
						parent
						
							977525fea6
						
					
				
				
					commit
					1fdf84e033
				
			| @@ -1606,7 +1606,8 @@ set_context_in_lang_cmd(expand_T *xp, char_u *arg) | |||||||
| static enum | static enum | ||||||
| { | { | ||||||
|     EXP_BREAKPT_ADD,	// expand ":breakadd" sub-commands |     EXP_BREAKPT_ADD,	// expand ":breakadd" sub-commands | ||||||
|     EXP_BREAKPT_DEL	// expand ":breakdel" sub-commands |     EXP_BREAKPT_DEL,	// expand ":breakdel" sub-commands | ||||||
|  |     EXP_PROFDEL		// expand ":profdel" sub-commands | ||||||
| } breakpt_expand_what; | } breakpt_expand_what; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -1623,16 +1624,17 @@ set_context_in_breakadd_cmd(expand_T *xp, char_u *arg, cmdidx_T cmdidx) | |||||||
|  |  | ||||||
|     if (cmdidx == CMD_breakadd) |     if (cmdidx == CMD_breakadd) | ||||||
| 	breakpt_expand_what = EXP_BREAKPT_ADD; | 	breakpt_expand_what = EXP_BREAKPT_ADD; | ||||||
|     else |     else if (cmdidx == CMD_breakdel) | ||||||
| 	breakpt_expand_what = EXP_BREAKPT_DEL; | 	breakpt_expand_what = EXP_BREAKPT_DEL; | ||||||
|  |     else | ||||||
|  | 	breakpt_expand_what = EXP_PROFDEL; | ||||||
|  |  | ||||||
|     p = skipwhite(arg); |     p = skipwhite(arg); | ||||||
|     if (*p == NUL) |     if (*p == NUL) | ||||||
| 	return NULL; | 	return NULL; | ||||||
|     subcmd_start = p; |     subcmd_start = p; | ||||||
|  |  | ||||||
|     if (STRNCMP("file ", p, 5) == 0 || |     if (STRNCMP("file ", p, 5) == 0 || STRNCMP("func ", p, 5) == 0) | ||||||
| 	    STRNCMP("func ", p, 5) == 0) |  | ||||||
|     { |     { | ||||||
| 	// :breakadd file [lnum] <filename> | 	// :breakadd file [lnum] <filename> | ||||||
| 	// :breakadd func [lnum] <funcname> | 	// :breakadd func [lnum] <funcname> | ||||||
| @@ -2025,6 +2027,7 @@ set_context_by_cmdname( | |||||||
|  |  | ||||||
| #ifdef FEAT_EVAL | #ifdef FEAT_EVAL | ||||||
| 	case CMD_breakadd: | 	case CMD_breakadd: | ||||||
|  | 	case CMD_profdel: | ||||||
| 	case CMD_breakdel: | 	case CMD_breakdel: | ||||||
| 	    return set_context_in_breakadd_cmd(xp, arg, cmdidx); | 	    return set_context_in_breakadd_cmd(xp, arg, cmdidx); | ||||||
| #endif | #endif | ||||||
| @@ -2432,11 +2435,19 @@ get_breakadd_arg(expand_T *xp UNUSED, int idx) | |||||||
|  |  | ||||||
|     if (idx >=0 && idx <= 3) |     if (idx >=0 && idx <= 3) | ||||||
|     { |     { | ||||||
|  | 	// breakadd {expr, file, func, here} | ||||||
| 	if (breakpt_expand_what == EXP_BREAKPT_ADD) | 	if (breakpt_expand_what == EXP_BREAKPT_ADD) | ||||||
| 	    return (char_u *)opts[idx]; | 	    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 | 	else | ||||||
| 	{ | 	{ | ||||||
| 	    if (idx <= 2) | 	    // profdel {func, file} | ||||||
|  | 	    if (idx <= 1) | ||||||
| 		return (char_u *)opts[idx + 1]; | 		return (char_u *)opts[idx + 1]; | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -376,7 +376,6 @@ get_profile_name(expand_T *xp UNUSED, int idx) | |||||||
|     { |     { | ||||||
|     case PEXP_SUBCMD: |     case PEXP_SUBCMD: | ||||||
| 	return (char_u *)pexpand_cmds[idx]; | 	return (char_u *)pexpand_cmds[idx]; | ||||||
|     // case PEXP_FUNC: TODO |  | ||||||
|     default: |     default: | ||||||
| 	return NULL; | 	return NULL; | ||||||
|     } |     } | ||||||
| @@ -399,14 +398,20 @@ set_context_in_profile_cmd(expand_T *xp, char_u *arg) | |||||||
|     if (*end_subcmd == NUL) |     if (*end_subcmd == NUL) | ||||||
| 	return; | 	return; | ||||||
|  |  | ||||||
|     if (end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0) |     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_context = EXPAND_FILES; | ||||||
| 	xp->xp_pattern = skipwhite(end_subcmd); | 	xp->xp_pattern = skipwhite(end_subcmd); | ||||||
| 	return; | 	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; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // TODO: expand function names after "func" |  | ||||||
|     xp->xp_context = EXPAND_NOTHING; |     xp->xp_context = EXPAND_NOTHING; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3158,7 +3158,6 @@ func Test_cmdline_complete_breakdel() | |||||||
|   call assert_equal("\"breakdel   here   Xtest", @:) |   call assert_equal("\"breakdel   here   Xtest", @:) | ||||||
|   call feedkeys(":breakdel here \<Tab>\<C-B>\"\<CR>", 'tx') |   call feedkeys(":breakdel here \<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|   call assert_equal("\"breakdel here ", @:) |   call assert_equal("\"breakdel here ", @:) | ||||||
|  |  | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " vim: shiftwidth=2 sts=2 expandtab | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -434,6 +434,47 @@ func Test_profile_completion() | |||||||
|  |  | ||||||
|   call feedkeys(":profile start test_prof\<C-A>\<C-B>\"\<CR>", 'tx') |   call feedkeys(":profile start test_prof\<C-A>\<C-B>\"\<CR>", 'tx') | ||||||
|   call assert_match('^"profile start.* test_profile\.vim', @:) |   call assert_match('^"profile start.* test_profile\.vim', @:) | ||||||
|  |  | ||||||
|  |   call feedkeys(":profile file test_prof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_match('"profile file test_profile\.vim', @:) | ||||||
|  |   call feedkeys(":profile file  test_prof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_match('"profile file  test_profile\.vim', @:) | ||||||
|  |   call feedkeys(":profile file test_prof \<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_match('"profile file test_prof ', @:) | ||||||
|  |   call feedkeys(":profile file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_match('"profile file X1B2C3', @:) | ||||||
|  |  | ||||||
|  |   func Xprof_test() | ||||||
|  |   endfunc | ||||||
|  |   call feedkeys(":profile func Xprof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profile func Xprof_test', @:) | ||||||
|  |   call feedkeys(":profile   func   Xprof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profile   func   Xprof_test', @:) | ||||||
|  |   call feedkeys(":profile func Xprof \<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profile func Xprof ', @:) | ||||||
|  |   call feedkeys(":profile func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profile func X1B2C3', @:) | ||||||
|  |  | ||||||
|  |   call feedkeys(":profdel \<C-A>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel file func', @:) | ||||||
|  |   call feedkeys(":profdel  fu\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel  func', @:) | ||||||
|  |   call feedkeys(":profdel he\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel he', @:) | ||||||
|  |   call feedkeys(":profdel here \<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel here ', @:) | ||||||
|  |   call feedkeys(":profdel file test_prof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel file test_profile.vim', @:) | ||||||
|  |   call feedkeys(":profdel file  X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel file  X1B2C3', @:) | ||||||
|  |   call feedkeys(":profdel func Xprof\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel func Xprof_test', @:) | ||||||
|  |   call feedkeys(":profdel func Xprof_test  \<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel func Xprof_test  ', @:) | ||||||
|  |   call feedkeys(":profdel func  X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"profdel func  X1B2C3', @:) | ||||||
|  |  | ||||||
|  |   delfunc Xprof_test | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_profile_errors() | func Test_profile_errors() | ||||||
|   | |||||||
| @@ -750,6 +750,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     4570, | ||||||
| /**/ | /**/ | ||||||
|     4569, |     4569, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user