Ingo Karkat
abb4d74033
patch 9.1.2138: win_execute() and 'autochdir' can corrupt buffer name
...
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 : #19343
Co-authored-by: zeertzjq <zeertzjq@outlook.com >
Signed-off-by: Ingo Karkat <swdev@ingo-karkat.de >
Signed-off-by: Christian Brabandt <cb@256bit.org >
2026-02-07 10:41:32 +00:00
..
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2026-02-02 10:15:04 +00:00
2026-01-08 21:39:15 +00:00
2026-01-31 16:13:39 +00:00
2026-02-06 10:19:55 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2022-07-30 12:03:16 +01:00
2020-01-21 22:13:42 +01:00
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2024-08-17 15:14:43 +02:00
2024-08-17 15:14:43 +02:00
2026-01-19 18:07:28 +00:00
2024-08-20 19:57:00 +02:00
2024-08-20 19:57:00 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2020-05-31 14:25:22 +02:00
2020-05-31 14:25:22 +02:00
2024-08-15 21:39:33 +02:00
2024-08-15 21:39:33 +02:00
2025-11-09 19:23:50 +00:00
2025-12-07 19:12:33 +01:00
2025-11-09 19:23:50 +00:00
2025-08-06 12:44:36 +02:00
2026-01-18 20:50:11 +00:00
2026-02-06 09:44:56 +00:00
2026-01-11 18:45:42 +00:00
2021-06-27 15:18:56 +02:00
2022-02-26 12:25:45 +00:00
2026-01-25 18:17:40 +00:00
2025-08-10 10:28:16 +02:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-01 16:15:39 +00:00
2026-02-06 14:44:18 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-11 18:23:20 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-07 21:33:28 +00:00
2025-11-27 21:28:05 +00:00
2025-06-27 21:10:35 +02:00
2026-01-26 19:40:37 +00:00
2025-03-28 19:11:11 +01:00
2020-05-26 21:20:45 +02:00
2024-01-14 19:24:05 +01:00
2026-02-04 16:21:40 +00:00
2026-01-31 16:13:39 +00:00
2025-12-09 13:27:00 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-28 21:58:28 +00:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2020-01-14 19:29:13 +01:00
2025-08-10 10:28:16 +02:00
2025-11-09 19:23:50 +00:00
2024-01-02 16:51:11 +01:00
2025-08-10 10:28:16 +02:00
2025-05-19 19:34:44 +02:00
2026-01-31 16:13:39 +00:00
2025-10-06 17:56:20 +00:00
2026-01-08 19:35:38 +00:00
2025-12-17 23:24:57 +01:00
2026-02-01 14:57:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 18:05:43 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 15:23:07 +00:00
2025-11-09 19:23:50 +00:00
2026-01-31 16:13:39 +00:00
2026-01-31 16:13:39 +00:00
2025-11-09 19:23:50 +00:00
2026-02-06 09:44:56 +00:00
2026-01-31 16:13:39 +00:00
2026-01-31 16:13:39 +00:00
2026-02-06 14:55:12 +00:00
2024-05-11 11:16:21 +02:00
2025-10-12 15:31:37 +00:00
2025-11-09 19:23:50 +00:00
2025-12-02 20:42:53 +00:00
2025-12-26 16:01:31 +00:00
2026-01-07 21:33:28 +00:00
2025-11-09 19:23:50 +00:00
2025-12-20 15:24:57 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-15 21:52:32 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-26 20:12:28 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-28 20:37:16 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-13 18:23:54 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-11 21:13:35 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-02-07 10:41:32 +00:00
2026-01-31 16:13:39 +00:00
2026-01-25 18:05:43 +00:00
2023-11-04 09:57:09 +01:00
2026-01-25 15:52:46 +00:00
2025-11-11 16:47:24 +00:00
2020-07-26 17:00:44 +02:00
2020-07-26 17:00:44 +02:00
2024-11-28 21:45:39 +01:00
2024-11-28 21:45:39 +01:00
2020-07-26 17:00:44 +02:00
2020-07-26 17:00:44 +02:00
2025-08-20 20:23:29 +02:00
2025-08-20 20:23:29 +02:00
2026-01-19 18:07:28 +00:00
2020-07-26 17:00:44 +02:00
2020-07-26 17:00:44 +02:00
2025-10-07 19:19:43 +00:00
2025-10-07 19:19:43 +00:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2023-12-29 16:30:40 +01:00
2023-12-29 16:30:40 +01:00
2025-08-18 21:40:40 +02:00
2025-08-18 21:40:40 +02:00
2018-07-15 20:20:18 +02:00
2018-07-15 20:20:18 +02:00
2024-08-17 15:14:43 +02:00
2024-08-17 15:14:43 +02:00
2026-01-19 18:07:28 +00:00
2024-08-20 19:57:00 +02:00
2024-08-20 19:57:00 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2020-05-31 14:25:22 +02:00
2020-05-31 14:25:22 +02:00
2024-08-15 21:39:33 +02:00
2024-08-15 21:39:33 +02:00
2018-07-15 20:20:18 +02:00
2018-07-15 20:20:18 +02:00
2025-06-29 17:51:33 +02:00
2025-06-30 20:28:46 +02:00
2025-06-24 21:17:25 +02:00
2025-06-24 21:17:25 +02:00
2026-01-19 18:07:28 +00:00
2025-07-09 19:43:51 +02:00
2025-07-09 19:43:51 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2020-05-31 14:25:22 +02:00
2020-05-31 14:25:22 +02:00
2025-06-23 19:52:42 +02:00
2025-06-23 19:52:42 +02:00
2025-11-09 19:23:50 +00:00
2025-11-25 22:04:58 +00:00
2025-12-03 19:22:13 +00:00
2025-11-09 19:23:50 +00:00
2023-10-06 19:51:13 +02:00
2023-10-06 19:51:13 +02:00
2024-09-17 19:12:03 +02:00
2024-09-17 19:12:03 +02:00
2026-01-19 18:07:28 +00:00
2023-10-06 19:51:13 +02:00
2023-10-06 19:51:13 +02:00
2024-09-17 19:03:16 +02:00
2024-09-17 19:03:16 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2024-09-15 20:03:05 +02:00
2024-09-15 20:03:05 +02:00