1
0
mirror of https://github.com/adobe/brackets.git synced 2024-11-20 18:02:54 +01:00

Merge pull request #13964 from adobe/petetnt/fix-onbeforeunload

Don't prompt before unload while in SpecRunner
This commit is contained in:
Prashanth Nethi 2017-12-08 11:10:57 +05:30 committed by GitHub
commit 18dd43112e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1718,19 +1718,23 @@ define(function (require, exports, module) {
/** Reload Without Extensions commnad handler **/
var handleReloadWithoutExts = _.partial(handleReload, true);
/**
* Attach a beforeunload handler to notify user about unsaved changes and URL redirection in CEF.
/**
* Attach a beforeunload handler to notify user about unsaved changes and URL redirection in CEF.
* Prevents data loss in scenario reported under #13708
**/
window.onbeforeunload = function(e) {
if (window.location.pathname.indexOf('SpecRunner') > -1) {
return;
}
var openDocs = DocumentManager.getAllOpenDocuments();
// Detect any unsaved changes
openDocs = openDocs.filter(function(doc) {
return doc && doc.isDirty;
});
// Ensure we are not in normal app-quit or reload workflow
if (!_isReloading && !_windowGoingAway) {
if (openDocs.length > 0) {
@ -1740,7 +1744,7 @@ define(function (require, exports, module) {
}
}
};
/** Do some initialization when the DOM is ready **/
AppInit.htmlReady(function () {
// If in Reload Without User Extensions mode, update UI and log console message