Skip to content

Commit 3321645

Browse files
devvaannshabose
authored andcommitted
fix: save both active and previewed file on live preview save
1 parent 09989af commit 3321645

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,22 @@ define(function (require, exports, module) {
12671267
_showFolderSelectionDialog(null);
12681268
}
12691269

1270+
/**
1271+
* this function is responsible to save the active file (and previewed file, both might be same though)
1272+
* when ctrl/cmd + s is pressed in the live preview
1273+
*/
1274+
function _handleLivePreviewSave() {
1275+
// this saves the active file
1276+
CommandManager.execute(Commands.FILE_SAVE);
1277+
1278+
// we also save the previewed file, (active file might be same as previewed or different)
1279+
const currLiveDoc = LiveDevMultiBrowser.getCurrentLiveDoc();
1280+
if (currLiveDoc && currLiveDoc.editor) {
1281+
const previewedDoc = currLiveDoc.editor.document;
1282+
CommandManager.execute(Commands.FILE_SAVE, { doc: previewedDoc });
1283+
}
1284+
}
1285+
12701286
/**
12711287
* This is the main function that is exported.
12721288
* it will be called by LiveDevProtocol when it receives a message from RemoteFunctions.js
@@ -1293,7 +1309,7 @@ define(function (require, exports, module) {
12931309
function handleLivePreviewEditOperation(message) {
12941310
// handle save current document in live preview (ctrl/cmd + s)
12951311
if (message.saveCurrentDocument) {
1296-
CommandManager.execute(Commands.FILE_SAVE);
1312+
_handleLivePreviewSave();
12971313
return;
12981314
}
12991315

src/LiveDevelopment/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ define(function main(require, exports, module) {
465465
config.highlight = PreferencesManager.getViewState("livedevHighlight");
466466

467467
function setLivePreviewEditFeaturesActive(enabled) {
468-
// TODO: @abose here add kernal mode trust check
469468
isProUser = enabled;
470469
config.isProUser = enabled;
471470
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {

0 commit comments

Comments
 (0)