Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
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
24 changes: 15 additions & 9 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,19 @@ define(function LiveDevelopment(require, exports, module) {
return loadAgents();
}

/** reload the live preview */
function reload() {
// Unload and reload agents before reloading the page
// Some agents (e.g. DOMAgent and RemoteAgent) require us to
// navigate to the page first before loading can complete.
// To accomodate this, we load all agents (in reconnect())
// and navigate in parallel.
reconnect();

// Reload HTML page
Inspector.Page.reload();
}

/**
* Close the connection and the associated window asynchronously
* @return {jQuery.Promise} Resolves once the connection is closed
Expand Down Expand Up @@ -1368,15 +1381,7 @@ define(function LiveDevelopment(require, exports, module) {
wasRequested = agents.network && agents.network.wasURLRequested(documentUrl);

if (wasRequested) {
// Unload and reload agents before reloading the page
// Some agents (e.g. DOMAgent and RemoteAgent) require us to
// navigate to the page first before loading can complete.
// To accomodate this, we load all agents (in reconnect())
// and navigate in parallel.
reconnect();

// Reload HTML page
Inspector.Page.reload();
reload();
}
}

Expand Down Expand Up @@ -1447,6 +1452,7 @@ define(function LiveDevelopment(require, exports, module) {
exports.open = open;
exports.close = close;
exports.reconnect = reconnect;
exports.reload = reload;
exports.enableAgent = enableAgent;
exports.disableAgent = disableAgent;
exports.getLiveDocForPath = getLiveDocForPath;
Expand Down
8 changes: 8 additions & 0 deletions src/LiveDevelopment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ define(function main(require, exports, module) {
window.report = function report(params) { window.params = params; console.info(params); };
}

/** force reload the live preview */
function _handleReloadLivePreviewCommand() {
if (LiveDevelopment.status >= LiveDevelopment.STATUS_ACTIVE) {
LiveDevelopment.reload();
}
}

/** Initialize LiveDevelopment */
AppInit.appReady(function () {
params.parse();
Expand Down Expand Up @@ -275,6 +282,7 @@ define(function main(require, exports, module) {
// init commands
CommandManager.register(Strings.CMD_LIVE_FILE_PREVIEW, Commands.FILE_LIVE_FILE_PREVIEW, _handleGoLiveCommand);
CommandManager.register(Strings.CMD_LIVE_HIGHLIGHT, Commands.FILE_LIVE_HIGHLIGHT, _handlePreviewHighlightCommand);
CommandManager.register(Strings.CMD_RELOAD_LIVE_PREVIEW, Commands.FILE_RELOAD_LIVE_PREVIEW, _handleReloadLivePreviewCommand);
CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(false);

// Export public functions
Expand Down
5 changes: 5 additions & 0 deletions src/base-config/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"file.liveFilePreview": [
"Ctrl-Alt-P"
],
"file.reloadLivePreview": [
{
"key": "Ctrl-Shift-R"
}
],
"file.previewHighlight": [
"Ctrl-Shift-C"
],
Expand Down
1 change: 1 addition & 0 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ define(function (require, exports, module) {
exports.FILE_ADD_TO_WORKING_SET = "file.addToWorkingSet"; // DocumentCommandHandlers.js handleFileAddToWorkingSet()
exports.FILE_OPEN_DROPPED_FILES = "file.openDroppedFiles"; // DragAndDrop.js openDroppedFiles()
exports.FILE_LIVE_FILE_PREVIEW = "file.liveFilePreview"; // LiveDevelopment/main.js _handleGoLiveCommand()
exports.FILE_RELOAD_LIVE_PREVIEW = "file.reloadLivePreview"; // LiveDevelopment/main.js _handleGoLiveCommand()
exports.FILE_LIVE_HIGHLIGHT = "file.previewHighlight"; // LiveDevelopment/main.js _handlePreviewHighlightCommand()
exports.FILE_PROJECT_SETTINGS = "file.projectSettings"; // ProjectManager.js _projectSettings()
exports.FILE_RENAME = "file.rename"; // DocumentCommandHandlers.js handleFileRename()
Expand Down
4 changes: 0 additions & 4 deletions src/extensions/default/DebugCommands/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
"reloadWithoutUserExts": [
{
"key": "Shift-F5"
},
{
"key": "Cmd-Shift-R",
"platform": "mac"
}
]
}
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ define({
"CMD_FILE_SAVE_ALL" : "Save All",
"CMD_FILE_SAVE_AS" : "Save As\u2026",
"CMD_LIVE_FILE_PREVIEW" : "Live Preview",
"CMD_RELOAD_LIVE_PREVIEW" : "Force Reload Live Preview",
"CMD_PROJECT_SETTINGS" : "Project Settings\u2026",
"CMD_FILE_RENAME" : "Rename",
"CMD_FILE_DELETE" : "Delete",
Expand Down