helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.76k stars 2.41k forks source link

`:w` breaks symlink chains #11408

Open nestor-custodio opened 1 month ago

nestor-custodio commented 1 month ago

Summary

When editing a file opened via a chain of symlinks, a :w will write into the file the opened symlink points to, not the actual data source. This breaks the symlink chain, leading to file changes which are essentially orphaned from backup processes, source control, etc.

Reproduction Steps

Asciinema recording available here.

I tried this:

  1. With a symlink sequence of a🡐b🡐c🡐d🡐e ...
  2. Editing "a" writes to "a", as expected.
  3. Editing "b" writes to "a", as expected.
  4. Editing "e" writes to "d", breaking the symlink chain.

I expected this to happen:

Editing "a", "b", "c", "d", or "e" all yield the same end result: "a" is updated.


Instead, this happened:

Editing "e" replaced "d", meaning "d" and "e" no longer reflect the same data as "a", "b", and "c". There are now two versions of this file.

Helix log

(The above actions write no new lines into the Helix log.)

Platform

Linux (Ubuntu 24.04, no DE)

Terminal Emulator

(run in text mode; no terminal emulator)

Installation Method

releases page

Helix Version

helix 24.7 (079f5442)

nestor-custodio commented 1 month ago

Worth noting: although a symlink chain 5 files deep is an extremely unlikely and artificial example, I wanted enough files in the chain to show where exactly the break happens.

A more realistic scenario would be a 3 file chain (still unusual, but this does happen) where the last file in the chain is edited (i.e.: "a🡐b🡐c" becomes "a, b🡐c"), breaking the link between the first and second. This is how I actually came across the issue just now.

kirawi commented 1 month ago

@pascalkuthe We could try to implement canonicalization like I had suggested in Matrix a while ago, or follow Vim here and do copy backups for symlinks.