Mercurial > vim
comparison src/ex_getln.c @ 3961:b1536bbbda10 v7.3.736
updated for version 7.3.736
Problem: File name completion in input() escapes white space. (Frederic
Hardy)
Solution: Do not escape white space. (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 28 Nov 2012 16:49:58 +0100 |
parents | ba9c9d0c4ff4 |
children | edd0bc1f26bd |
comparison
equal
deleted
inserted
replaced
3960:f268667a05d8 | 3961:b1536bbbda10 |
---|---|
100 static void cmdline_del __ARGS((int from)); | 100 static void cmdline_del __ARGS((int from)); |
101 #endif | 101 #endif |
102 static void redrawcmdprompt __ARGS((void)); | 102 static void redrawcmdprompt __ARGS((void)); |
103 static void cursorcmd __ARGS((void)); | 103 static void cursorcmd __ARGS((void)); |
104 static int ccheck_abbr __ARGS((int)); | 104 static int ccheck_abbr __ARGS((int)); |
105 static int nextwild __ARGS((expand_T *xp, int type, int options)); | 105 static int nextwild __ARGS((expand_T *xp, int type, int options, int escape)); |
106 static void escape_fname __ARGS((char_u **pp)); | 106 static void escape_fname __ARGS((char_u **pp)); |
107 static int showmatches __ARGS((expand_T *xp, int wildmenu)); | 107 static int showmatches __ARGS((expand_T *xp, int wildmenu)); |
108 static void set_expand_context __ARGS((expand_T *xp)); | 108 static void set_expand_context __ARGS((expand_T *xp)); |
109 static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***, int)); | 109 static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***, int)); |
110 static int expand_showtail __ARGS((expand_T *xp)); | 110 static int expand_showtail __ARGS((expand_T *xp)); |
808 (void)showmatches(&xpc, FALSE); | 808 (void)showmatches(&xpc, FALSE); |
809 redrawcmd(); | 809 redrawcmd(); |
810 did_wild_list = TRUE; | 810 did_wild_list = TRUE; |
811 } | 811 } |
812 if (wim_flags[wim_index] & WIM_LONGEST) | 812 if (wim_flags[wim_index] & WIM_LONGEST) |
813 res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP); | 813 res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP, |
814 firstc != '@'); | |
814 else if (wim_flags[wim_index] & WIM_FULL) | 815 else if (wim_flags[wim_index] & WIM_FULL) |
815 res = nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP); | 816 res = nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP, |
817 firstc != '@'); | |
816 else | 818 else |
817 res = OK; /* don't insert 'wildchar' now */ | 819 res = OK; /* don't insert 'wildchar' now */ |
818 } | 820 } |
819 else /* typed p_wc first time */ | 821 else /* typed p_wc first time */ |
820 { | 822 { |
821 wim_index = 0; | 823 wim_index = 0; |
822 j = ccline.cmdpos; | 824 j = ccline.cmdpos; |
823 /* if 'wildmode' first contains "longest", get longest | 825 /* if 'wildmode' first contains "longest", get longest |
824 * common part */ | 826 * common part */ |
825 if (wim_flags[0] & WIM_LONGEST) | 827 if (wim_flags[0] & WIM_LONGEST) |
826 res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP); | 828 res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP, |
829 firstc != '@'); | |
827 else | 830 else |
828 res = nextwild(&xpc, WILD_EXPAND_KEEP, WILD_NO_BEEP); | 831 res = nextwild(&xpc, WILD_EXPAND_KEEP, WILD_NO_BEEP, |
832 firstc != '@'); | |
829 | 833 |
830 /* if interrupted while completing, behave like it failed */ | 834 /* if interrupted while completing, behave like it failed */ |
831 if (got_int) | 835 if (got_int) |
832 { | 836 { |
833 (void)vpeekc(); /* remove <C-C> from input stream */ | 837 (void)vpeekc(); /* remove <C-C> from input stream */ |
858 { | 862 { |
859 #ifdef FEAT_WILDMENU | 863 #ifdef FEAT_WILDMENU |
860 int p_wmnu_save = p_wmnu; | 864 int p_wmnu_save = p_wmnu; |
861 p_wmnu = 0; | 865 p_wmnu = 0; |
862 #endif | 866 #endif |
863 nextwild(&xpc, WILD_PREV, 0); /* remove match */ | 867 /* remove match */ |
868 nextwild(&xpc, WILD_PREV, 0, firstc != '@'); | |
864 #ifdef FEAT_WILDMENU | 869 #ifdef FEAT_WILDMENU |
865 p_wmnu = p_wmnu_save; | 870 p_wmnu = p_wmnu_save; |
866 #endif | 871 #endif |
867 } | 872 } |
868 #ifdef FEAT_WILDMENU | 873 #ifdef FEAT_WILDMENU |
872 (void)showmatches(&xpc, FALSE); | 877 (void)showmatches(&xpc, FALSE); |
873 #endif | 878 #endif |
874 redrawcmd(); | 879 redrawcmd(); |
875 did_wild_list = TRUE; | 880 did_wild_list = TRUE; |
876 if (wim_flags[wim_index] & WIM_LONGEST) | 881 if (wim_flags[wim_index] & WIM_LONGEST) |
877 nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP); | 882 nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP, |
883 firstc != '@'); | |
878 else if (wim_flags[wim_index] & WIM_FULL) | 884 else if (wim_flags[wim_index] & WIM_FULL) |
879 nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP); | 885 nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP, |
886 firstc != '@'); | |
880 } | 887 } |
881 else | 888 else |
882 vim_beep(); | 889 vim_beep(); |
883 } | 890 } |
884 #ifdef FEAT_WILDMENU | 891 #ifdef FEAT_WILDMENU |
897 gotesc = FALSE; | 904 gotesc = FALSE; |
898 | 905 |
899 /* <S-Tab> goes to last match, in a clumsy way */ | 906 /* <S-Tab> goes to last match, in a clumsy way */ |
900 if (c == K_S_TAB && KeyTyped) | 907 if (c == K_S_TAB && KeyTyped) |
901 { | 908 { |
902 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0) == OK | 909 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK |
903 && nextwild(&xpc, WILD_PREV, 0) == OK | 910 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK |
904 && nextwild(&xpc, WILD_PREV, 0) == OK) | 911 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK) |
905 goto cmdline_changed; | 912 goto cmdline_changed; |
906 } | 913 } |
907 | 914 |
908 if (c == NUL || c == K_ZERO) /* NUL is stored as NL */ | 915 if (c == NUL || c == K_ZERO) /* NUL is stored as NL */ |
909 c = NL; | 916 c = NL; |
1416 ccline.cmdpos = ccline.cmdlen; | 1423 ccline.cmdpos = ccline.cmdlen; |
1417 set_cmdspos_cursor(); | 1424 set_cmdspos_cursor(); |
1418 goto cmdline_not_changed; | 1425 goto cmdline_not_changed; |
1419 | 1426 |
1420 case Ctrl_A: /* all matches */ | 1427 case Ctrl_A: /* all matches */ |
1421 if (nextwild(&xpc, WILD_ALL, 0) == FAIL) | 1428 if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL) |
1422 break; | 1429 break; |
1423 goto cmdline_changed; | 1430 goto cmdline_changed; |
1424 | 1431 |
1425 case Ctrl_L: | 1432 case Ctrl_L: |
1426 #ifdef FEAT_SEARCH_EXTRA | 1433 #ifdef FEAT_SEARCH_EXTRA |
1452 goto cmdline_not_changed; | 1459 goto cmdline_not_changed; |
1453 } | 1460 } |
1454 #endif | 1461 #endif |
1455 | 1462 |
1456 /* completion: longest common part */ | 1463 /* completion: longest common part */ |
1457 if (nextwild(&xpc, WILD_LONGEST, 0) == FAIL) | 1464 if (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL) |
1458 break; | 1465 break; |
1459 goto cmdline_changed; | 1466 goto cmdline_changed; |
1460 | 1467 |
1461 case Ctrl_N: /* next match */ | 1468 case Ctrl_N: /* next match */ |
1462 case Ctrl_P: /* previous match */ | 1469 case Ctrl_P: /* previous match */ |
1463 if (xpc.xp_numfiles > 0) | 1470 if (xpc.xp_numfiles > 0) |
1464 { | 1471 { |
1465 if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0) | 1472 if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, |
1466 == FAIL) | 1473 0, firstc != '@') == FAIL) |
1467 break; | 1474 break; |
1468 goto cmdline_changed; | 1475 goto cmdline_changed; |
1469 } | 1476 } |
1470 | 1477 |
1471 #ifdef FEAT_CMDHIST | 1478 #ifdef FEAT_CMDHIST |
3336 * completion of anything, return OK if it is (even if there are no matches). | 3343 * completion of anything, return OK if it is (even if there are no matches). |
3337 * For the caller, this means that the character is just passed through like a | 3344 * For the caller, this means that the character is just passed through like a |
3338 * normal character (instead of being expanded). This allows :s/^I^D etc. | 3345 * normal character (instead of being expanded). This allows :s/^I^D etc. |
3339 */ | 3346 */ |
3340 static int | 3347 static int |
3341 nextwild(xp, type, options) | 3348 nextwild(xp, type, options, escape) |
3342 expand_T *xp; | 3349 expand_T *xp; |
3343 int type; | 3350 int type; |
3344 int options; /* extra options for ExpandOne() */ | 3351 int options; /* extra options for ExpandOne() */ |
3352 int escape; /* if TRUE, escape the returned matches */ | |
3345 { | 3353 { |
3346 int i, j; | 3354 int i, j; |
3347 char_u *p1; | 3355 char_u *p1; |
3348 char_u *p2; | 3356 char_u *p2; |
3349 int difflen; | 3357 int difflen; |
3388 xp->xp_context)) == NULL) | 3396 xp->xp_context)) == NULL) |
3389 p2 = NULL; | 3397 p2 = NULL; |
3390 else | 3398 else |
3391 { | 3399 { |
3392 int use_options = options | | 3400 int use_options = options | |
3393 WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE; | 3401 WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT; |
3402 if (escape) | |
3403 use_options |= WILD_ESCAPE; | |
3394 | 3404 |
3395 if (p_wic) | 3405 if (p_wic) |
3396 use_options += WILD_ICASE; | 3406 use_options += WILD_ICASE; |
3397 p2 = ExpandOne(xp, p1, | 3407 p2 = ExpandOne(xp, p1, |
3398 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len), | 3408 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len), |