Skip to content
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
4 changes: 2 additions & 2 deletions src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,12 @@ define(function (require, exports, module) {
logger.leaveTrail("UI Menu Click: " + menuItem._command.getID());
MainViewManager.focusActivePane();
if (menuItem._command._options.eventSource) {
menuItem._command.execute({
CommandManager.execute(menuItem._command.getID(), {
eventSource: CommandManager.SOURCE_UI_MENU_CLICK,
sourceType: self.id
});
} else {
menuItem._command.execute();
CommandManager.execute(menuItem._command.getID());
}
});

Expand Down
42 changes: 42 additions & 0 deletions src/extensionsIntegrated/TabBar/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,44 @@ define(function (require, exports, module) {
// the event fires too frequently when switching editors, leading to unexpected behavior
const debounceUpdateTabs = _.debounce(updateTabs, 2);

/**
* This function is responsible to add the placeholder tab to the working set (if user press save on it)
* @param {Event} event
* @param {String} commandId - the command id, to make sure we check it do the operation only on file save
*/
function onFileSave(event, commandId) {
if (commandId === Commands.FILE_SAVE || commandId === Commands.FILE_SAVE_ALL) {
const activePane = MainViewManager.getActivePaneId();
const currentFile = MainViewManager.getCurrentlyViewedFile(activePane);

if (currentFile) {
const filePath = currentFile.fullPath;

// check if this file is currently shown as a placeholder in any pane
const isFirstPanePlaceholder =
MainViewManager.getCurrentlyViewedFile("first-pane") &&
MainViewManager.getCurrentlyViewedFile("first-pane").fullPath === filePath &&
!Global.firstPaneWorkingSet.some((entry) => entry.path === filePath);

const isSecondPanePlaceholder =
MainViewManager.getCurrentlyViewedFile("second-pane") &&
MainViewManager.getCurrentlyViewedFile("second-pane").fullPath === filePath &&
!Global.secondPaneWorkingSet.some((entry) => entry.path === filePath);

// if it's a placeholder tab, we add it to the working set
if (isFirstPanePlaceholder) {
const fileObj = FileSystem.getFileForPath(filePath);
MainViewManager.addToWorkingSet("first-pane", fileObj);
}

if (isSecondPanePlaceholder) {
const fileObj = FileSystem.getFileForPath(filePath);
MainViewManager.addToWorkingSet("second-pane", fileObj);
}
}
}
}

/**
* Registers the event handlers
*/
Expand Down Expand Up @@ -588,6 +626,10 @@ define(function (require, exports, module) {
// main-plugin-panel[0] = live preview panel
new ResizeObserver(updateTabs).observe($("#main-plugin-panel")[0]);

// listen for file save commands, needed to add placeholder tab to the working set
CommandManager.off("beforeExecuteCommand", onFileSave);
CommandManager.on("beforeExecuteCommand", onFileSave);

// File dirty flag change handling
DocumentManager.on("dirtyFlagChange", function (event, doc) {
const filePath = doc.file.fullPath;
Expand Down
Loading