Skip to content

Commit 5c15f1f

Browse files
committed
feat: active file in non-active pane is now highlighted too
1 parent 351e62f commit 5c15f1f

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

src/extensionsIntegrated/TabBar/main.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,29 @@ define(function (require, exports, module) {
123123
return;
124124
}
125125

126-
// set up all the necessary properties
127-
const activeEditor = EditorManager.getActiveEditor();
128-
const activePath = activeEditor ? activeEditor.document.file.fullPath : null;
126+
// get the current active file for this specific pane
127+
const activeFileInPane = MainViewManager.getCurrentlyViewedFile(paneId);
128+
const activePathInPane = activeFileInPane ? activeFileInPane.fullPath : null;
129129

130+
// Check if this file is active in its pane
131+
const isActive = (entry.path === activePathInPane);
132+
133+
// Current active pane (used to determine whether to add the blue underline)
130134
const currentActivePane = MainViewManager.getActivePaneId();
131-
// if the file is the currently active file
132-
// also verify that the tab belongs to the active pane
133-
const isActive = (entry.path === activePath && paneId === currentActivePane);
134-
const isDirty = Helper._isFileModified(FileSystem.getFileForPath(entry.path)); // if the file is dirty
135+
const isPaneActive = (paneId === currentActivePane);
136+
137+
const isDirty = Helper._isFileModified(FileSystem.getFileForPath(entry.path));
135138

136-
// Create the tab element with the structure we need
137-
// tab name is written as a separate div because it may include directory info which we style differently
139+
// create tab with active class
138140
const $tab = $(
139-
`<div class="tab ${isActive ? 'active' : ''} ${isDirty ? 'dirty' : ''}"
140-
data-path="${entry.path}"
141-
title="${entry.path}">
142-
<div class="tab-icon"></div>
143-
<div class="tab-name"></div>
144-
<div class="tab-close"><i class="fa-solid fa-times"></i></div>
145-
</div>`);
141+
`<div class="tab
142+
${isActive ? 'active' : ''}
143+
${isDirty ? 'dirty' : ''}" data-path="${entry.path}" title="${entry.path}">
144+
<div class="tab-icon"></div>
145+
<div class="tab-name"></div>
146+
<div class="tab-close"><i class="fa-solid fa-times"></i></div>
147+
</div>`
148+
);
146149

147150
// Add the file icon
148151
const $icon = Helper._getFileIcon(entry);
@@ -163,6 +166,13 @@ define(function (require, exports, module) {
163166
$tabName.text(entry.name);
164167
}
165168

169+
// only add the underline class if this is both active AND in the active pane
170+
if (isActive && !isPaneActive) {
171+
// if it's active but in a non-active pane, we add a special class
172+
// to style differently in CSS to indicate that it's active but not in the active pane
173+
$tab.addClass('active-in-inactive-pane');
174+
}
175+
166176
return $tab;
167177
}
168178

src/styles/Extn-TabBar.less

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,32 @@
169169
background-color: #75BEFF;
170170
}
171171

172+
.tab.active-in-inactive-pane {
173+
background-color: #fff;
174+
}
175+
176+
.dark .tab.active-in-inactive-pane {
177+
background-color: #3D3D3D;
178+
}
179+
180+
.tab.active-in-inactive-pane::after {
181+
display: none;
182+
}
183+
184+
.tab.active-in-inactive-pane::before {
185+
content: "";
186+
position: absolute;
187+
bottom: 0;
188+
left: 0;
189+
right: 0;
190+
height: 0.12rem;
191+
background-color: #b4b2b2;
192+
}
193+
194+
.dark .tab.active-in-inactive-pane::before {
195+
background-color: #666;
196+
}
197+
172198
.tab.dirty::before {
173199
content: "";
174200
color: #888;

0 commit comments

Comments
 (0)