comparison src/cmdexpand.c @ 32846:757409cf4e8a v9.0.1735

patch 9.0.1735: Rename completion specific findex var Commit: https://github.com/vim/vim/commit/e9ef347c137aca6c2592beb19da45a8aece65e11 Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Aug 17 23:57:05 2023 +0200 patch 9.0.1735: Rename completion specific findex var Problem: Rename completion specific findex var Solution: Move "findex" static variable to xp_selected in expand_T closes: #12548 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Fri, 18 Aug 2023 00:15:04 +0200
parents e98fc0c439aa
children 306f51627f50
comparison
equal deleted inserted replaced
32845:e8eca84950e1 32846:757409cf4e8a
689 vim_free(buf); 689 vim_free(buf);
690 } 690 }
691 691
692 /* 692 /*
693 * Get the next or prev cmdline completion match. The index of the match is set 693 * Get the next or prev cmdline completion match. The index of the match is set
694 * in "p_findex" 694 * in "xp->xp_selected"
695 */ 695 */
696 static char_u * 696 static char_u *
697 get_next_or_prev_match( 697 get_next_or_prev_match(
698 int mode, 698 int mode,
699 expand_T *xp, 699 expand_T *xp,
700 int *p_findex,
701 char_u *orig_save) 700 char_u *orig_save)
702 { 701 {
703 int findex = *p_findex; 702 int findex = xp->xp_selected;
704 int ht; 703 int ht;
705 704
706 if (xp->xp_numfiles <= 0) 705 if (xp->xp_numfiles <= 0)
707 return NULL; 706 return NULL;
708 707
776 cmdline_pum_display(); 775 cmdline_pum_display();
777 } 776 }
778 else if (p_wmnu) 777 else if (p_wmnu)
779 win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, 778 win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
780 findex, cmd_showtail); 779 findex, cmd_showtail);
781 *p_findex = findex; 780 xp->xp_selected = findex;
782 781
783 if (findex == -1) 782 if (findex == -1)
784 return vim_strsave(orig_save); 783 return vim_strsave(orig_save);
785 784
786 return vim_strsave(xp->xp_files[findex]); 785 return vim_strsave(xp->xp_files[findex]);
955 char_u *orig, // allocated copy of original of expanded string 954 char_u *orig, // allocated copy of original of expanded string
956 int options, 955 int options,
957 int mode) 956 int mode)
958 { 957 {
959 char_u *ss = NULL; 958 char_u *ss = NULL;
960 static int findex; // TODO: Move into expand_T
961 static char_u *orig_save = NULL; // kept value of orig 959 static char_u *orig_save = NULL; // kept value of orig
962 int orig_saved = FALSE; 960 int orig_saved = FALSE;
963 int i; 961 int i;
964 long_u len; 962 long_u len;
965 963
966 // first handle the case of using an old match 964 // first handle the case of using an old match
967 if (mode == WILD_NEXT || mode == WILD_PREV 965 if (mode == WILD_NEXT || mode == WILD_PREV
968 || mode == WILD_PAGEUP || mode == WILD_PAGEDOWN) 966 || mode == WILD_PAGEUP || mode == WILD_PAGEDOWN)
969 return get_next_or_prev_match(mode, xp, &findex, orig_save); 967 return get_next_or_prev_match(mode, xp, orig_save);
970 968
971 if (mode == WILD_CANCEL) 969 if (mode == WILD_CANCEL)
972 ss = vim_strsave(orig_save ? orig_save : (char_u *)""); 970 ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
973 else if (mode == WILD_APPLY) 971 else if (mode == WILD_APPLY)
974 ss = vim_strsave(findex == -1 972 ss = vim_strsave(xp->xp_selected == -1
975 ? (orig_save ? orig_save : (char_u *)"") 973 ? (orig_save ? orig_save : (char_u *)"")
976 : xp->xp_files[findex]); 974 : xp->xp_files[xp->xp_selected]);
977 975
978 // free old names 976 // free old names
979 if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) 977 if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
980 { 978 {
981 FreeWild(xp->xp_numfiles, xp->xp_files); 979 FreeWild(xp->xp_numfiles, xp->xp_files);
984 982
985 // The entries from xp_files may be used in the PUM, remove it. 983 // The entries from xp_files may be used in the PUM, remove it.
986 if (compl_match_array != NULL) 984 if (compl_match_array != NULL)
987 cmdline_pum_remove(); 985 cmdline_pum_remove();
988 } 986 }
989 // TODO: Remove condition if "findex" is part of expand_T ? 987 xp->xp_selected = 0;
990 if (mode != WILD_EXPAND_FREE && mode != WILD_ALL && mode != WILD_ALL_KEEP)
991 findex = 0;
992 988
993 if (mode == WILD_FREE) // only release file name 989 if (mode == WILD_FREE) // only release file name
994 return NULL; 990 return NULL;
995 991
996 if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) 992 if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL)
1004 1000
1005 // Find longest common part 1001 // Find longest common part
1006 if (mode == WILD_LONGEST && xp->xp_numfiles > 0) 1002 if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
1007 { 1003 {
1008 ss = find_longest_match(xp, options); 1004 ss = find_longest_match(xp, options);
1009 findex = -1; // next p_wc gets first one 1005 xp->xp_selected = -1; // next p_wc gets first one
1010 } 1006 }
1011 1007
1012 // Concatenate all matching names. Unless interrupted, this can be slow 1008 // Concatenate all matching names. Unless interrupted, this can be slow
1013 // and the result probably won't be used. 1009 // and the result probably won't be used.
1014 if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) 1010 if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int)