Sublime Forum

Reload/Revert files after pull to prevent undo (Ctrl + Z)

#1

Hi,

I have a little issue when we Pull files using SourceTree.

Example:

  • I got an open file names example.php with the text “Text 1” in it.
  • One of our developer edit this file in his PC and add another line to it of “Text 2”.
  • I sow that I got updated to Pull so I Pull them using SourceTree when the file is still opened on my PC.
  • Sublime detect that the file has been modified and Refresh it automatically to me (that is good).
  • Now I like to add another line to the file of “Text 3” but I made Undo (CTRL + Z) before I added it.
  • At this moment Sublime remember the history and even the file refreshed it will remove the “Text 2” line from it, so when I will Push my changes the file will include only “Text 1” and “Text 3”.

When you are working on big files this issue is really bad.

What I need is that Sublime will remove the History when it reload modified files, so my CTRL + Z will no works in those cases.

I know I can Revert or Close & Open the file but it is not a good solution because if one of our developers will forgot it we will still have this issue, and I like to prevent it.

Thanks.

1 Like

#2

This happens as reloading the file is recognized as an ordinary modification just like editing the file.

Actively pulling a file (knowing it has changed) and doing an undo as a first action after returning to the editor sounds some kind of stupid.

I would be very unhappy to loose history after reloading an external file or saving it. From my point of view it would even break the intended way of editing documents. You can close ST without loosing unsaved changes and continue later seamlessly, even if the file changed in the meanwhile. You can undo/redo as if you never left.

So from my point of view it is a feature not an issue.

Carelessly undoing/redoing/editing things will always break a file.

2 Likes

#3

You really think this is what we do?

We are working X developer together, I don’t need to close my files every time I Push, it is not professional.
I can work on a file, then Push and work again, sometimes you work and you made a changes in more then
one area on the file, then you found another solution, so you Copy the code, Undo to your start point and Past
the change. In this case you can by mistake remove some changes, and if you made a huge push you can also
don’t see the removed changes (if they are small). In programming small things can made huge bugs.

As you say’s, Sublime decide that “reloading the file is recognized as an ordinary modification just like editing the file”.
just you forgot to say that Sublime decide that, and if they like other programs to come ahead and lead they can stay
with this decide.

When I reloading a file in a lot of programs its cancel the history, may-be they are smart, may-be you.
The customers will spoke.

Have a grate day.

0 Likes

#4

I love this Sublime Text feature. But for your case, you look into write a package which detects when the file is reloaded from the file system, and to this for you. It will close the file, and open it again. Cleaning the undo history.

0 Likes

#5

Yeap, sound good

0 Likes