To: vim_dev@googlegroups.com Subject: Patch 7.4.1554 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1554 Problem: Completion for :colorscheme does not use 'packpath'. Solution: Make it work, add a test. (Hirohito Higashi) Files: src/ex_getln.c, src/testdir/test_packadd.vim *** ../vim-7.4.1553/src/ex_getln.c 2016-03-05 21:21:09.087720248 +0100 --- src/ex_getln.c 2016-03-13 13:20:31.566758882 +0100 *************** *** 111,117 **** static int expand_showtail(expand_T *xp); #ifdef FEAT_CMDL_COMPL static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg); ! static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname[]); static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file); # ifdef FEAT_CMDHIST static char_u *get_history_arg(expand_T *xp, int idx); --- 111,117 ---- static int expand_showtail(expand_T *xp); #ifdef FEAT_CMDL_COMPL static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg); ! static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, char *dirname[]); static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file); # ifdef FEAT_CMDHIST static char_u *get_history_arg(expand_T *xp, int idx); *************** *** 4628,4649 **** if (xp->xp_context == EXPAND_COLORS) { char *directories[] = {"colors", NULL}; ! return ExpandRTDir(pat, num_file, file, directories); } if (xp->xp_context == EXPAND_COMPILER) { char *directories[] = {"compiler", NULL}; ! return ExpandRTDir(pat, num_file, file, directories); } if (xp->xp_context == EXPAND_OWNSYNTAX) { char *directories[] = {"syntax", NULL}; ! return ExpandRTDir(pat, num_file, file, directories); } if (xp->xp_context == EXPAND_FILETYPE) { char *directories[] = {"syntax", "indent", "ftplugin", NULL}; ! return ExpandRTDir(pat, num_file, file, directories); } # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) if (xp->xp_context == EXPAND_USER_LIST) --- 4628,4650 ---- if (xp->xp_context == EXPAND_COLORS) { char *directories[] = {"colors", NULL}; ! return ExpandRTDir(pat, DIP_START + DIP_OPT, num_file, file, ! directories); } if (xp->xp_context == EXPAND_COMPILER) { char *directories[] = {"compiler", NULL}; ! return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_OWNSYNTAX) { char *directories[] = {"syntax", NULL}; ! return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_FILETYPE) { char *directories[] = {"syntax", "indent", "ftplugin", NULL}; ! return ExpandRTDir(pat, 0, num_file, file, directories); } # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) if (xp->xp_context == EXPAND_USER_LIST) *************** *** 5119,5131 **** #endif /* ! * Expand color scheme, compiler or filetype names: ! * 'runtimepath'/{dirnames}/{pat}.vim * "dirnames" is an array with one or more directory names. */ static int ExpandRTDir( char_u *pat, int *num_file, char_u ***file, char *dirnames[]) --- 5120,5138 ---- #endif /* ! * Expand color scheme, compiler or filetype names. ! * Search from 'runtimepath': ! * 'runtimepath'/{dirnames}/{pat}.vim ! * When "flags" has DIP_START: search also from 'start' of 'packpath': ! * 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim ! * When "flags" has DIP_OPT: search also from 'opt' of 'packpath': ! * 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim * "dirnames" is an array with one or more directory names. */ static int ExpandRTDir( char_u *pat, + int flags, int *num_file, char_u ***file, char *dirnames[]) *************** *** 5155,5160 **** --- 5162,5197 ---- vim_free(s); } + if (flags & DIP_START) { + for (i = 0; dirnames[i] != NULL; ++i) + { + s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 22)); + if (s == NULL) + { + ga_clear_strings(&ga); + return FAIL; + } + sprintf((char *)s, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); + globpath(p_pp, s, &ga, 0); + vim_free(s); + } + } + + if (flags & DIP_OPT) { + for (i = 0; dirnames[i] != NULL; ++i) + { + s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 20)); + if (s == NULL) + { + ga_clear_strings(&ga); + return FAIL; + } + sprintf((char *)s, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); + globpath(p_pp, s, &ga, 0); + vim_free(s); + } + } + for (i = 0; i < ga.ga_len; ++i) { match = ((char_u **)ga.ga_data)[i]; *** ../vim-7.4.1553/src/testdir/test_packadd.vim 2016-03-12 22:47:10.552935212 +0100 --- src/testdir/test_packadd.vim 2016-03-13 13:20:31.570758841 +0100 *************** *** 135,140 **** --- 135,163 ---- call assert_equal(1, g:found_three) endfunc + func Test_colorscheme_completion() + let colordirrun = &packpath . '/runtime/colors' + let colordirstart = &packpath . '/pack/mine/start/foo/colors' + let colordiropt = &packpath . '/pack/mine/opt/bar/colors' + call mkdir(colordirrun, 'p') + call mkdir(colordirstart, 'p') + call mkdir(colordiropt, 'p') + call writefile(['let g:found_one = 1'], colordirrun . '/one.vim') + call writefile(['let g:found_two = 1'], colordirstart . '/two.vim') + call writefile(['let g:found_three = 1'], colordiropt . '/three.vim') + exe 'set rtp=' . &packpath . '/runtime' + + let li=[] + call feedkeys(":colorscheme " . repeat("\", 1) . "')\call add(li, '\", 't') + call feedkeys(":colorscheme " . repeat("\", 2) . "')\call add(li, '\", 't') + call feedkeys(":colorscheme " . repeat("\", 3) . "')\call add(li, '\", 't') + call feedkeys(":colorscheme " . repeat("\", 4) . "')\call add(li, '\", 'tx') + call assert_equal("colorscheme one", li[0]) + call assert_equal("colorscheme three", li[1]) + call assert_equal("colorscheme two", li[2]) + call assert_equal("colorscheme ", li[3]) + endfunc + func Test_runtime() let rundir = &packpath . '/runtime/extra' let startdir = &packpath . '/pack/mine/start/foo/extra' *** ../vim-7.4.1553/src/version.c 2016-03-12 22:47:10.552935212 +0100 --- src/version.c 2016-03-13 13:22:49.149326654 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1554, /**/ -- Due knot trussed yore spell chequer two fined awl miss steaks. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///