Skip to content
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

Commands to update paths without closing open files #6541

Open
LeonXSG opened this issue Nov 30, 2024 · 5 comments
Open

Commands to update paths without closing open files #6541

LeonXSG opened this issue Nov 30, 2024 · 5 comments

Comments

@LeonXSG
Copy link

LeonXSG commented Nov 30, 2024

Problem description

After renaming or moving files or folders outside of sublime text, those files while open in sublime text are marked as deleted in sublime text. They can't be updated without closing the file in sublime text and reopening it, closing the file removes all editing history.

Preferred solution

Create a shortcut command to open file browser to locate file and a shortcut command to open overlay and paste new file path, without having to close and reopen file to avoid losing editing history. What I'm requesting is that for the user to be able to update the file path, the new file or folder selected does not have to be the same as the file being updated, but when loaded it will use the latest data of the newest file while preserving all of the edits previously made in the old file through Sublime Text using the same file tab.

Alternatives

A plugin to do the same thing.

Additional Information

The issues mentioned in other posts were focused on creating auto detection and tracking, that is not what I'm looking for.

@deathaxe
Copy link
Collaborator

What would be the difference to just call "Save as..." and select the renamed file to store content to?

@LeonXSG
Copy link
Author

LeonXSG commented Nov 30, 2024

What would be the difference to just call "Save as..." and select the renamed file to store content to?

If you made changes to the file outside of sublime text you'd overwrite those changes.

@keith-hall
Copy link
Collaborator

Alternatives

A plugin to do the same thing.

I don't see anything stopping you from making a command to do a view.retarget(new_path). Even a file picker is in the API these days

@LeonXSG
Copy link
Author

LeonXSG commented Nov 30, 2024

Alternatives

A plugin to do the same thing.

I don't see anything stopping you from making a command to do a view.retarget(new_path). Even a file picker is in the API these days

I don't know how to do that, that's a learning curve.

@deathaxe
Copy link
Collaborator

deathaxe commented Dec 1, 2024

Keeping a view linked with its file, even if it is moved/renamed on disk, is what is requested by #846. It would mean to just call view.retarget() internally/automatically for each view a file movement notification is received for - the same way as "FileManager" package renames a file on disk via os.rename() and then calls view.retarget() to update open views.

If you made changes to the file outside of sublime text you'd overwrite those changes.

view.retarget() would only retain or add the "dirty" state in case view's content differs from new file's content on disk.

So the options after calling it are to:

  1. save retargeted view and also overwrite possible changes made to the external file
    (Same as "Save as..."
  2. close the view and loose local modifications
    (same as current "Close deleted tabs" or simply close a tab without saving)
  3. reset view to load content from disk and loose possibly made changes in view.

Expectation however seems to be able to do a 3-way-diff to merge possible unsaved changes made in view with possible changes made to file during external move operation.

Sounds interesting, required controls (SM's merge tool) are already available, but I doubt sublimeqh will cannibalize Sublime Merge by integrating a diff or 3-way-merge tool into Sublime Text - even though I'd find it a worthful addition or replacement for sluggish Side-By-Side compare package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants