Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Warn user on external changes to saved files #12181

Open
arctwelve opened this issue Jan 31, 2016 · 7 comments
Open

Warn user on external changes to saved files #12181

arctwelve opened this issue Jan 31, 2016 · 7 comments

Comments

@arctwelve
Copy link

Brackets currently warns the user if an unsaved file is altered by an external program or process, but doesn't do the same if the file is in a saved state in Brackets. Any external change, even a touch on a saved file will be automatically and silently applied. This is a serious problem as it causes the file history to be lost without warning.

The loss of history, however, should be considered normal if a file is externally altered and the external change warning is accepted (i.e., the user clicks "Reload from Disk").

What happens to the history is open. Different editors treat externally changed history differently. TextPad clears the history if a saved file is altered externally and loaded from disk at the warning prompt, where as SublimeText appends the altered external version to the SublimeText history. SublimeText, like Brackets, also doesn't warn the user, but the history works as expected: the external changes become part of the undo history.

The problem is that the user doesn't even have a choice, and may not even be aware a saved file has been externally altered, and that the undo history is lost.

@petetnt
Copy link
Collaborator

petetnt commented Jan 31, 2016

The relevant bits of code for this (do correct me if I am wrong):

if (fileTime !== doc.diskTimestamp.getTime()) {

@petetnt
Copy link
Collaborator

petetnt commented Jan 31, 2016

I think the check should be something like

  if (doc.isDirty) {
    editConflicts.push({doc: doc, fileTime: fileTime});
  } else if (doc.hasHistory) else {
    // either 
    // a) Do the changes but merge the history objects
    // b) Pop up the edit conflict window when the doc is opened, essentially simplifying this to 
    // if (doc.isDirty || doc.hasHistory) else { }
  } else {
    toReload.push(doc);
  }

My extension brackets-persistent-history does the option a) of the above, but only between closing Brackets or switching projects: if there has been outside changes when the file is reopened, CTRL+Z reverts the file to the last state before the external changes.

@arctwelve
Copy link
Author

Screenshot from TextPad showing the best case for allowing the user to choose. Important feature, properly implemented.

feature

@baoang
Copy link

baoang commented Feb 25, 2016

Dreamweaver is smarter in detecting file modification by third party editors even before it was acquired by Adobe

@abose
Copy link
Contributor

abose commented Feb 25, 2016

If I remember correctly, Dreamweaver was acquired by adobe 11 years before.

@baoang
Copy link

baoang commented Feb 25, 2016

I am not very sure about the year. When I first met with Dreamweaver, that's the MS Front-page era, and Dreamweaver, Fireworks, and Flash were called The Three Musketeers in Web Design domain.

@thanazer
Copy link

I'm newbie to opensource and would like to contribute to this issue. Can I pick it up?

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

No branches or pull requests

5 participants