Skip to content

Commit 9759eee

Browse files
devvaannshabose
authored andcommitted
fix: prevent tab bar operations when disabled
1 parent 5e16ccd commit 9759eee

File tree

1 file changed

+26
-2
lines changed
  • src/extensionsIntegrated/TabBar

1 file changed

+26
-2
lines changed

src/extensionsIntegrated/TabBar/main.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,23 @@ define(function (require, exports, module) {
5252
let $tabBar = null;
5353
let $tabBar2 = null;
5454

55+
/**
56+
* this function checks if the TabBar is currently enabled or not (no. of tabs is 0 means tab bar is disabled)
57+
* @returns {boolean} true if TabBar is enabled and should be active
58+
*/
59+
function isTabBarActive() {
60+
return Preference.tabBarEnabled && Preference.tabBarNumberOfTabs !== 0;
61+
}
62+
5563
/**
5664
* This function is responsible to take all the files from the working set and gets the working sets ready
5765
* This is placed here instead of helper.js because it modifies the working sets
5866
*/
5967
function getAllFilesFromWorkingSet() {
68+
if (!isTabBarActive()) {
69+
return;
70+
}
71+
6072
Global.firstPaneWorkingSet = [];
6173
Global.secondPaneWorkingSet = [];
6274

@@ -204,7 +216,7 @@ define(function (require, exports, module) {
204216
* Creates the tab bar and adds it to the DOM
205217
*/
206218
function createTabBar() {
207-
if (!Preference.tabBarEnabled || Preference.tabBarNumberOfTabs === 0) {
219+
if (!isTabBarActive()) {
208220
cleanupTabBar();
209221
return;
210222
}
@@ -237,6 +249,10 @@ define(function (require, exports, module) {
237249
* It is called when the working set changes. So instead of creating a new tab bar, we just update the existing one
238250
*/
239251
function updateTabs() {
252+
if (!isTabBarActive()) {
253+
return;
254+
}
255+
240256
// Get all files from the working set. refer to `global.js`
241257
getAllFilesFromWorkingSet();
242258

@@ -553,6 +569,10 @@ define(function (require, exports, module) {
553569
* @param {String} commandId - the command id, to make sure we check it do the operation only on file save
554570
*/
555571
function onFileSave(event, commandId) {
572+
if (!isTabBarActive()) {
573+
return;
574+
}
575+
556576
if (commandId === Commands.FILE_SAVE || commandId === Commands.FILE_SAVE_ALL) {
557577
const activePane = MainViewManager.getActivePaneId();
558578
const currentFile = MainViewManager.getCurrentlyViewedFile(activePane);
@@ -632,6 +652,10 @@ define(function (require, exports, module) {
632652

633653
// File dirty flag change handling
634654
DocumentManager.on("dirtyFlagChange", function (event, doc) {
655+
if (!isTabBarActive()) {
656+
return;
657+
}
658+
635659
const filePath = doc.file.fullPath;
636660

637661
// Update UI
@@ -678,7 +702,7 @@ define(function (require, exports, module) {
678702
// Update menu checkmark
679703
CommandManager.get(Commands.TOGGLE_TABBAR).setChecked(prefs.showTabBar);
680704

681-
if (Preference.tabBarEnabled && Preference.tabBarNumberOfTabs !== 0) {
705+
if (isTabBarActive()) {
682706
createTabBar();
683707
} else {
684708
cleanupTabBar();

0 commit comments

Comments
 (0)