diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2020-11-28 16:10:04 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2020-11-28 16:10:04 +1300 |
commit | 456fe634d42b009fed3e8b65fb2e82d2738eef29 (patch) | |
tree | ff9a99387233eaaa93f96ef9e17d8b2e47e7b36e | |
parent | Merge branch 'hotfix/v1.0.2' into develop (diff) | |
download | vim-spellfile-local-456fe634d42b009fed3e8b65fb2e82d2738eef29.tar.gz vim-spellfile-local-456fe634d42b009fed3e8b65fb2e82d2738eef29.zip |
Refactor filename escape filter for Windows
-rw-r--r-- | autoload/spellfile_local.vim | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/autoload/spellfile_local.vim b/autoload/spellfile_local.vim index 1ae937b..a7f7a7d 100644 --- a/autoload/spellfile_local.vim +++ b/autoload/spellfile_local.vim @@ -90,15 +90,12 @@ function! spellfile_local#() abort endfunction " Escape a path for use as a valid option file name; replace any characters -" not in 'isfname' with percent symbols +" that won't work nicely as filenames with percent signs function! s:Filename(parts) abort - let filename = '' - for char in split(join(a:parts, '.'), '\zs') - let filename .= (char !=# '_' && char !=# '/' && char =~# '^\f$') - \ ? char - \ : '%' - endfor - return filename + let pat = has('win32') || has('win64') + \ ? '\c[^[:filename:]]\|[\\/:*?"<>|]' + \ : '\c[^[:filename:]]\|[_/]' + return substitute(join(a:parts, '.'), pat, '%', 'g') endfunction " Join a list of strings into a comma-separated option |