Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down