mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
vim-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: vim/vim#15392
closes: vim/vim#15418
b9de1a057f
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
parent
0b1751f7f8
commit
760e62345d
@ -3166,8 +3166,30 @@ static void get_next_filename_completion(void)
|
|||||||
size_t leader_len = strlen(leader);
|
size_t leader_len = strlen(leader);
|
||||||
bool in_fuzzy = ((get_cot_flags() & COT_FUZZY) != 0 && leader_len > 0);
|
bool in_fuzzy = ((get_cot_flags() & COT_FUZZY) != 0 && leader_len > 0);
|
||||||
|
|
||||||
|
#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) {
|
if (in_fuzzy) {
|
||||||
char *last_sep = strrchr(leader, PATHSEP);
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
|
if (curbuf->b_p_csl[0] == 's') {
|
||||||
|
for (size_t i = 0; i < leader_len; i++) {
|
||||||
|
if (leader[i] == '\\') {
|
||||||
|
leader[i] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (curbuf->b_p_csl[0] == 'b') {
|
||||||
|
for (size_t i = 0; i < leader_len; i++) {
|
||||||
|
if (leader[i] == '/') {
|
||||||
|
leader[i] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
char *last_sep = strrchr(leader, pathsep);
|
||||||
if (last_sep == NULL) {
|
if (last_sep == NULL) {
|
||||||
// No path separator or separator is the last character,
|
// No path separator or separator is the last character,
|
||||||
// fuzzy match the whole leader
|
// fuzzy match the whole leader
|
||||||
|
@ -2753,6 +2753,38 @@ func Test_complete_fuzzy_match()
|
|||||||
unlet g:word
|
unlet g:word
|
||||||
endfunc
|
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, ['.\fob'])
|
||||||
|
call feedkeys("A\<C-X>\<C-F>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal('.\fobar', getline('.'))
|
||||||
|
|
||||||
|
" Test with completeslash=backslash
|
||||||
|
set completeslash=backslash
|
||||||
|
call feedkeys("S.\\fob\<C-X>\<C-F>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal('.\fobar', 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
|
" Check that tie breaking is stable for completeopt+=fuzzy (which should
|
||||||
" behave the same on different platforms).
|
" behave the same on different platforms).
|
||||||
func Test_complete_fuzzy_match_tie()
|
func Test_complete_fuzzy_match_tie()
|
||||||
|
Loading…
Reference in New Issue
Block a user