-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect when file on disk is moved/removed and warn about it #846
Comments
possible duplicate of #73 |
[Except on MacOS, it should seamlessly behave as other applications do : https://github.com//issues/2391 ] |
Not sure about it. Ideally ST would detect renamed files via file system notifications and adjust its catalog and retarget views without any notification needed. No matter wheter a file was renamed/moved or deleted. The only indication ST shows is that it can't find the file anymore and asks to save it again. I guess that's what this issue complains about. |
This issue was raised several times in the history of Sublime and never addressed for many years; see for example this post. Sublime should create an NSURL (see Apple doc page) representation of the opened file. It should be fairly straightforward to find out the new location once Sublime detects that the file has been deleted/moved/renamed (e.g., see this post). Is there any chance that this will be included in one of the next versions of Sublime? Alternatively, it would be truly great if someone with experience in coding Sublime plugins provided such a solution. One can in principle interface with NSObject and cocoa using Python package pyobjc. |
Note Sublime Text being a cross-platform editor, so "just" relying on some Apple APIs is not sufficient. That said, it should already be possible to re-target views to new file locations, as ST uses OS's filesystem notifications to track external changes/movements/deletions/... . The challange however might be how to handle situations in which external file is moved and modified, while unsaved changes exist in a view with users expecting to not loose either one. |
Thanks for the feedback and your thoughts!
However, it may take some time and skill to implement such file handling in Sublime, so to take advantage of MacOS features. One should probably avoid trying to hack a solution, as it would probably not be very robust.
|
Current behaviour when a file that is opened in sublime is moved on disk is that the buffer is marked as having changes to be saved, and when closing sublime warns about saving the file. This is different from when a file is moved or removed (e.g. when changing git branches or whatever) and it is misleading that sublime warns about file not being saved. It should instead warn that the file was moved or removed.
The text was updated successfully, but these errors were encountered: