Sublime Forum

How to preserve edit history after tab closed

#1

In VSCode or some other IDEs, when you’re in a workspace and you close a tab, the edit history is preserved, so when you open the same tab back up you can still do, say, undo last edit. Is this option possible with ST4?

0 Likes

#2

Sounds like there’s some 3rd party plugins that could do this but native support has been added according to this?

0 Likes

#3

Undo history is stored in sessions/workspaces. We don’t keep undo history or unsaved changes for closed files.

0 Likes

#4

But it’s not just unsaved files. If I close the tab, seems like I’m not able to retrieve the change history regardless of whether it was saved or not?

0 Likes

#5

My apologies, that was an incorrect statement. How can I keep the unsaved change history as well?

0 Likes

#6

You can keep unsaved changes/undo history by using projects & workspaces.

0 Likes

#7

I think I am using that. I open the dir via “sublime ./my_project”

0 Likes

#8

You’d need to save the project/workspace. These things are under the Project menu. See also https://www.sublimetext.com/docs/projects.html

0 Likes

#9

I must be doing something wrong cuz I saved it as both a workspace and a project but a file’s change history still disappears when I close then reopen it…?

0 Likes

#10

As I said undo history or unsaved changes aren’t kept for closed files. They are kept for files opened in a project/workspace. Closing a workspace will save unsaved changes and undo history in the workspace file.

0 Likes

#11

This is what I did:

  1. open my project workspace (saved as both workspace and project)
  2. click open a main.rs file
  3. add some random comment somewhere
  4. save it
  5. close the main.rs file/tab
  6. click open the main.rs file again

At this point the undo button is grey and I can’t undo the random comment I added.

0 Likes

#12

If you close the workspace by closing the window or using Project > Close Project the undo history will be kept along with unsaved changes. Undo history and unsaved changes aren’t kept for closed files.

0 Likes

#13

welp this is what I meant in the original post. Sry it was confusing. Is there a way to keep the change history for closed files?

0 Likes

#14

There isn’t, using workspaces is the alternative. Plugins also can’t provide such a feature.

0 Likes

#15

Could this be a feature request? Looks like I’m not the only one hoping for this. Other editors have it?

0 Likes

#16

You can submit feature requests on github. In Sublime Text use the Help > Report a Bug menu item.

0 Likes