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>
This commit is contained in:
glepnir
2025-07-03 20:41:23 +02:00
committed by Christian Brabandt
parent 0d50d6089d
commit 4ade668fb6
8 changed files with 82 additions and 6 deletions

View File

@ -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 @@ A jump table for the options with a short description can be found at |Q_op|.
*'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 @@ A jump table for the options with a short description can be found at |Q_op|.
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|

View File

@ -6795,6 +6795,7 @@ cpo-x options.txt /*cpo-x*
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*

View File

@ -41643,6 +41643,8 @@ Options: ~
- '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'