aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/executable_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2026-02-08 07:04:36 +0800
committerGitHub <noreply@github.com>2026-02-08 07:04:36 +0800
commited8fbd2e2992cb264cb62585098a1c7acc5c4585 (patch)
tree15217ba56d04afac69c928bb9f88daaaddb0f578 /test/functional/vimscript/executable_spec.lua
parent72eb9fe87ce9c224ec6118ae92100ee2f1093a9b (diff)
downloadrneovim-ed8fbd2e2992cb264cb62585098a1c7acc5c4585.tar.gz
rneovim-ed8fbd2e2992cb264cb62585098a1c7acc5c4585.tar.bz2
rneovim-ed8fbd2e2992cb264cb62585098a1c7acc5c4585.zip
vim-patch:9.1.2138: win_execute() and 'autochdir' can corrupt buffer name (#37767)
Problem: With 'autochdir' win_execute() can corrupt the buffer name, causing :write to use wrong path. Solution: Save and restore b_fname when 'autochdir' is active (Ingo Karkat). This is caused by a bad interaction of the 'autochdir' behavior, overriding of the current directory via :lchdir, and the temporary window switching done by win_execute(), manifesting when e.g. a custom completion inspects other buffers: 1. In the initial state after the :lcd .. we have curbuf->b_fname = "Xsubdir/file". 2. do_autochdir() is invoked, temporarily undoing the :lcd .., changing back into the Xsubdir/ subdirectory. 3. win_execute() switches windows, triggering win_enter_ext() → win_fix_current_dir() → shorten_fnames(TRUE) 4. shorten_fnames() processes *all* buffers 5. shorten_buf_fname() makes the filename relative to the current (wrong) directory; b_fname becomes "file" instead of "Xsubdir/file" 6. Directory restoration correctly restores working directory via mch_chdir() (skipping a second do_autochdir() invocation because apply_acd is FALSE), but b_fname remains corrupted, with the "Xsubdir/" part missing. 7. expand("%:p") (and commands like :write) continue to use the corrupted filename, resolving to a wrong path that's missing the "Xsubdir/" part. To fix the problem the short filename is saved if its in effect (i.e. pointed to by curbuf->b_fname) and 'autochdir' happened. It's then restored in case of a local cwd override. The conditions limit this workaround to when 'autochdir' is active *and* overridden by a :lchdir. closes: vim/vim#19343 https://github.com/vim/vim/commit/abb4d740338e667991656e3ca575e623aba7bd2a Co-authored-by: Ingo Karkat <swdev@ingo-karkat.de>
Diffstat (limited to 'test/functional/vimscript/executable_spec.lua')
0 files changed, 0 insertions, 0 deletions