Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from 1 commit
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
15 changes: 13 additions & 2 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,12 +1438,21 @@ define(function (require, exports, module) {

return result.promise();
}


/** @type {boolean} prevents reentrancy of browserReload() */
var isReloading = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: prefix with _ to indicate private variable in this module and move this variable declaration next to other module variables. I know you only need this for the browserReload function, but we would like to have some best practices to group all variables in one section rather than scattering in the module.


/**
* Does a full reload of the browser window
* @param {string} href The url to reload into the window
*/
function browserReload(href) {
if (isReloading) {
return;
}

isReloading = true;

return CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true }).done(function () {
// Give everyone a chance to save their state - but don't let any problems block
// us from quitting
Expand All @@ -1452,7 +1461,7 @@ define(function (require, exports, module) {
} catch (ex) {
console.error(ex);
}

// Disable the cache to make reloads work
_disableCache().always(function () {
// Remove all menus to assure every part of Brackets is reloaded
Expand All @@ -1462,6 +1471,8 @@ define(function (require, exports, module) {

window.location.href = href;
});
}).fail(function () {
isReloading = false;
});
}

Expand Down