patch 9.1.1507: symlinks are resolved on :cd commands
Problem: File paths change from symlink to target path after :cd command
when editing files through symbolic links
Solution: Add "~" flag to 'cpoptions' to control symlink resolution.
When not included (default), symlinks are resolved maintaining
backward compatibility. When included, symlinks are preserved
providing the improved behavior. (glepnir)
related: neovim/neovim#15695
closes: #17628
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index b3c5697..cf064e1 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 9.1. Last change: 2025 Jul 01
+*options.txt* For Vim version 9.1. Last change: 2025 Jul 03
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2390,7 +2390,7 @@
*'cpoptions'* *'cpo'* *cpo*
'cpoptions' 'cpo' string (Vim default: "aABceFsz",
- Vi default: all flags, except "#{|&/\."
+ Vi default: all flags, except "#{|&/\.~"
|$VIM_POSIX|: all flags)
global
A sequence of single character flags. When a character is present
@@ -2680,6 +2680,13 @@
character, the cursor won't move. When not included,
the cursor would skip over it and jump to the
following occurrence.
+ *cpo-~*
+ ~ When included, don't resolve symbolic links when
+ changing directory with |:cd|, |:lcd|, or |:tcd|.
+ This preserves the symbolic link path in buffer names
+ and when displaying the current directory. When
+ excluded (default), symbolic links are resolved to
+ their target paths.
POSIX flags. These are not included in the Vi default value, except
when $VIM_POSIX was set on startup. |posix|
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 71a9616..6b363db 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6795,6 +6795,7 @@
cpo-y options.txt /*cpo-y*
cpo-z options.txt /*cpo-z*
cpo-{ options.txt /*cpo-{*
+cpo-~ options.txt /*cpo-~*
cpp.vim syntax.txt /*cpp.vim*
crash-recovery recover.txt /*crash-recovery*
creating-menus gui.txt /*creating-menus*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index fcd3b9f..75d1401 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41643,6 +41643,8 @@
- 'completeopt' is now a |global-local| option.
- add 'cpoptions' flag "z" |cpo-z|, to disable some (traditional) vi
behaviour/inconsistency (see |d-special| and |cw|).
+- add 'cpoptions' flag "~" |cpo-~| to disable resolving symlinks on |:cd|
+ commands
- new option values for 'fillchars':
"trunc" - configure truncation indicator, 'pummaxwidth'
"truncrl" - like "trunc" but in 'rl' mode, 'pummaxwidth'