Skip to content

Commit 068c060

Browse files
committed
runtime(rustfmt): not correctly escaping directory names
Problem: runtime(rustfmt): not correctly escaping directory names Solution: Use fnamescape() (Michał Majchrowicz) Signed-off-by: Christian Brabandt <[email protected]>
1 parent 91900b9 commit 068c060

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

runtime/autoload/rustfmt.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change:
44
" 2025 Oct 27 by Vim project: don't use rustfmt as 'formatprg' by default
55
" 2026 Jan 25 by Vim project: don't hide rustfmt errors, restore default var
6-
"
6+
" 2026 Mar 30 by Vim project: use fnameescape for :chdir commands
77
"
88
" Adapted from https://github.com/fatih/vim-go
99
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
@@ -135,7 +135,7 @@ function! s:RunRustfmt(command, tmpname, from_writepre)
135135
" chdir to the directory of the file
136136
let l:has_lcd = haslocaldir()
137137
let l:prev_cd = getcwd()
138-
execute 'lchdir! '.expand('%:h')
138+
execute 'lchdir! ' . fnameescape(expand('%:h'))
139139

140140
let l:buffer = getline(1, '$')
141141
if exists("*systemlist")
@@ -215,6 +215,7 @@ function! s:RunRustfmt(command, tmpname, from_writepre)
215215
endif
216216

217217
" Restore the current directory if needed
218+
let l:prev_cd = fnameescape(l:prev_cd)
218219
if a:tmpname ==# ''
219220
if l:has_lcd
220221
execute 'lchdir! '.l:prev_cd

0 commit comments

Comments
 (0)