You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a directory tree contains symlinks that cause a file to appear at multiple paths, vscode will allow each path to be open in a separate editor and edited independently. This can lead to very confusing situations where two different sets of changes have been made in different windows and only one can be saved.
Steps to Reproduce:
In an empty directory, do:
mkdir foo
ln -s foo bar
touch foo/file.txt
code .
Using the file explorer or quick-open, open both foo/file.txt and bar/file.txt.
Make changes in both editors. Notice they don't sync.
Try to save both editors. The second one will complain that the file has changed on disk.
Does this issue occur when all extensions are disabled?: Yes
Expected results:
In step 2, vscode should recognize that both paths point to the same file, and should only open one or the other.
Impact:
I have a code tree that uses symlinks. Several times, I have been burned by this, having accidentally made modifications to the same file under two different aliases. Fortunately, vscode lets me know that there is a problem (rather than just overwriting), but I've found it extremely difficult to merge the changes correctly. (Arguably it would be less difficult if vscode presented a 3-way diff rather than a 2-way diff, but it would be better to avoid the situation entirely...)
I have tried to mitigate the problem by using "files.exclude" to hide all but one alias. However, I've found that extensions which open editor windows (e.g. implementing "jump to definition" or whatnot) are inconsistent about which version of the path they choose to open.
Possible fixes:
On Unix systems, it's possible to recognize when two files are the same by using the stat(2) system call on each and comparing the st_dev and st_ino values (device and inode numbers). Under Node.js these can be accessed using fs.stat() as stats.dev and stats.ino. If editor tabs were keyed by device and inode numbers rather than file path, it would be impossible to open the same file in multiple tabs.
Another solution is to expand all symlinks before opening a file, to derive its canonical path. This solution is theoretically ugly and less robust, but may be easier to implement in practice. Also, it's worth noting that some extensions (such as the git extension) do not work properly when the file is opened under a path other than the canonical one, so canonicalizing paths may be preferable to sidestep such bugs (though, arguably such extensions should be fixed directly).
The text was updated successfully, but these errors were encountered:
When a directory tree contains symlinks that cause a file to appear at multiple paths, vscode will allow each path to be open in a separate editor and edited independently. This can lead to very confusing situations where two different sets of changes have been made in different windows and only one can be saved.
Steps to Reproduce:
Does this issue occur when all extensions are disabled?: Yes
Expected results:
In step 2, vscode should recognize that both paths point to the same file, and should only open one or the other.
Impact:
I have a code tree that uses symlinks. Several times, I have been burned by this, having accidentally made modifications to the same file under two different aliases. Fortunately, vscode lets me know that there is a problem (rather than just overwriting), but I've found it extremely difficult to merge the changes correctly. (Arguably it would be less difficult if vscode presented a 3-way diff rather than a 2-way diff, but it would be better to avoid the situation entirely...)
I have tried to mitigate the problem by using "files.exclude" to hide all but one alias. However, I've found that extensions which open editor windows (e.g. implementing "jump to definition" or whatnot) are inconsistent about which version of the path they choose to open.
Possible fixes:
On Unix systems, it's possible to recognize when two files are the same by using the
stat(2)
system call on each and comparing thest_dev
andst_ino
values (device and inode numbers). Under Node.js these can be accessed usingfs.stat()
asstats.dev
andstats.ino
. If editor tabs were keyed by device and inode numbers rather than file path, it would be impossible to open the same file in multiple tabs.Another solution is to expand all symlinks before opening a file, to derive its canonical path. This solution is theoretically ugly and less robust, but may be easier to implement in practice. Also, it's worth noting that some extensions (such as the git extension) do not work properly when the file is opened under a path other than the canonical one, so canonicalizing paths may be preferable to sidestep such bugs (though, arguably such extensions should be fixed directly).
The text was updated successfully, but these errors were encountered: