patch 9.1.0654: completion does not respect completeslash with fuzzy Commit: https://github.com/vim/vim/commit/b9de1a057f9a0b6de6f64a9c1b2078c7069cdd7d Author: glepnir <glephun...@gmail.com> Date: Fri Aug 2 19:14:38 2024 +0200
patch 9.1.0654: completion does not respect completeslash with fuzzy Problem: completion does not respect completeslash with fuzzy (egesip) Solution: Change path separator on Windows, depending on 'completeslash' option value (glepnir) fixes: #15392 closes: #15418 Signed-off-by: glepnir <glephun...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/insexpand.c b/src/insexpand.c index 3a168848f..9a8d0faac 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -3552,9 +3552,34 @@ get_next_filename_completion(void) size_t path_with_wildcard_len; char_u *path_with_wildcard; +#ifdef BACKSLASH_IN_FILENAME + char pathsep = (curbuf->b_p_csl[0] == 's') ? + '/' : (curbuf->b_p_csl[0] == 'b') ? '\' : PATHSEP; +#else + char pathsep = PATHSEP; +#endif + if (in_fuzzy) { - last_sep = vim_strrchr(leader, PATHSEP); +#ifdef BACKSLASH_IN_FILENAME + if (curbuf->b_p_csl[0] == 's') + { + for (i = 0; i < leader_len; i++) + { + if (leader[i] == '\') + leader[i] = '/'; + } + } + else if (curbuf->b_p_csl[0] == 'b') + { + for (i = 0; i < leader_len; i++) + { + if (leader[i] == '/') + leader[i] = '\'; + } + } +#endif + last_sep = vim_strrchr(leader, pathsep); if (last_sep == NULL) { // No path separator or separator is the last character, diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index cf688ac6a..becd0d8d0 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2668,6 +2668,38 @@ func Test_complete_fuzzy_match() unlet g:word endfunc +func Test_complete_fuzzy_with_completeslash() + CheckMSWindows + + call writefile([''], 'fobar', 'D') + let orig_shellslash = &shellslash + set cpt& + new + set completeopt+=fuzzy + set noshellslash + + " Test with completeslash unset + set completeslash= + call setline(1, ['.ob']) + call feedkeys("A\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('.obar', getline('.')) + + " Test with completeslash=backslash + set completeslash=backslash + call feedkeys("S.\fob\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('.obar', getline('.')) + + " Test with completeslash=slash + set completeslash=slash + call feedkeys("S.\fob\<C-X>\<C-F>\<Esc>0", 'tx!') + call assert_equal('./fobar', getline('.')) + + " Reset and clean up + let &shellslash = orig_shellslash + set completeslash= + %bw! +endfunc + " Check that tie breaking is stable for completeopt+=fuzzy (which should " behave the same on different platforms). func Test_complete_fuzzy_match_tie() diff --git a/src/version.c b/src/version.c index b9fdfcd23..1ff7fdc62 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 654, /**/ 653, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1sZw6N-00AbpB-Pi%40256bit.org.