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

Commit 8f8d231

Browse files
committed
Merge pull request #6846 from lkcampbell/fix-6452
Fix for issue #6452: Prevent reload commands from being repeated too quickly
2 parents 25be547 + 2643d7c commit 8f8d231

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/document/DocumentCommandHandlers.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ define(function (require, exports, module) {
8181
/** @type {Number} index to use for next, new Untitled document */
8282
var _nextUntitledIndexToUse = 1;
8383

84+
/** @type {boolean} prevents reentrancy of browserReload() */
85+
var _isReloading = false;
86+
8487
/** Unique token used to indicate user-driven cancellation of Save As (as opposed to file IO error) */
8588
var USER_CANCELED = { userCanceled: true };
8689

@@ -1438,12 +1441,18 @@ define(function (require, exports, module) {
14381441

14391442
return result.promise();
14401443
}
1441-
1444+
14421445
/**
14431446
* Does a full reload of the browser window
14441447
* @param {string} href The url to reload into the window
14451448
*/
14461449
function browserReload(href) {
1450+
if (_isReloading) {
1451+
return;
1452+
}
1453+
1454+
_isReloading = true;
1455+
14471456
return CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true }).done(function () {
14481457
// Give everyone a chance to save their state - but don't let any problems block
14491458
// us from quitting
@@ -1452,7 +1461,7 @@ define(function (require, exports, module) {
14521461
} catch (ex) {
14531462
console.error(ex);
14541463
}
1455-
1464+
14561465
// Disable the cache to make reloads work
14571466
_disableCache().always(function () {
14581467
// Remove all menus to assure every part of Brackets is reloaded
@@ -1462,6 +1471,8 @@ define(function (require, exports, module) {
14621471

14631472
window.location.href = href;
14641473
});
1474+
}).fail(function () {
1475+
_isReloading = false;
14651476
});
14661477
}
14671478

0 commit comments

Comments
 (0)