Skip to content

Commit d13b448

Browse files
committed
feat: show the pin icon for pinned files in tab bar
1 parent f5a48c0 commit d13b448

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

src/extensionsIntegrated/TabBar/main.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ define(function (require, exports, module) {
143143

144144
const isDirty = Helper._isFileModified(FileSystem.getFileForPath(entry.path));
145145
const isPlaceholder = entry.isPlaceholder === true;
146+
const isPinned = MainViewManager.isPathPinned(paneId, entry.path);
146147

147148
let gitStatus = ""; // this will be shown in the tooltip when a tab is hovered
148149
let gitStatusClass = ""; // for styling
@@ -173,12 +174,15 @@ define(function (require, exports, module) {
173174
${isActive ? "active" : ""}
174175
${isDirty ? "dirty" : ""}
175176
${isPlaceholder ? "placeholder" : ""}
177+
${isPinned ? "pinned" : ""}
176178
${gitStatusClass}"
177179
data-path="${entry.path}"
178180
title="${Phoenix.app.getDisplayPath(entry.path)}${gitStatus ? " (" + gitStatus + ")" : ""}">
179181
<div class="tab-icon"></div>
180182
<div class="tab-name"></div>
181-
<div class="tab-close"><i class="fa-solid fa-times"></i></div>
183+
${isPinned ?
184+
'<div class="tab-pin"><i class="fa-solid fa-thumbtack"></i></div>' :
185+
'<div class="tab-close"><i class="fa-solid fa-times"></i></div>'}
182186
</div>`
183187
);
184188

@@ -514,6 +518,14 @@ define(function (require, exports, module) {
514518

515519
CommandManager.execute(Commands.FILE_CLOSE, { file: fileObj, paneId: paneId }); // close the file
516520
}
521+
522+
// check if the clicked element is the pin icon, if yes then we need to unpin it
523+
if ($(event.target).hasClass("fa-thumbtack") || $(event.target).closest(".tab-pin").length) {
524+
event.preventDefault();
525+
event.stopPropagation();
526+
527+
CommandManager.execute(Commands.FILE_UNPIN, { file: fileObj, paneId: paneId });
528+
}
517529
});
518530

519531
// add listener for tab close button to show the tooltip along with the keybinding
@@ -655,7 +667,9 @@ define(function (require, exports, module) {
655667
"workingSetAddList",
656668
"workingSetRemoveList",
657669
"workingSetUpdate",
658-
"_workingSetDisableAutoSort"
670+
"_workingSetDisableAutoSort",
671+
"workingSetPinned",
672+
"workingSetUnpinned"
659673
];
660674
MainViewManager.off(events.join(" "), updateTabs);
661675
MainViewManager.on(events.join(" "), updateTabs);

src/styles/Extn-TabBar.less

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,36 @@
254254
background-color: rgba(255, 255, 255, 0.1);
255255
}
256256

257+
.tab-pin {
258+
font-size: 0.75rem;
259+
padding: 0.1rem 0.4rem;
260+
margin-left: 0.25rem;
261+
color: #666;
262+
transition: all 0.2s ease;
263+
border-radius: 0.2rem;
264+
}
265+
266+
.dark .tab-pin {
267+
color: #CCC;
268+
}
269+
270+
.tab-pin:hover {
271+
cursor: pointer;
272+
background-color: rgba(0, 0, 0, 0.1);
273+
}
274+
275+
.dark .tab-pin:hover {
276+
background-color: rgba(255, 255, 255, 0.1);
277+
}
278+
279+
.tab.pinned {
280+
background-color: rgba(0, 100, 200, 0.05);
281+
}
282+
283+
.dark .tab.pinned {
284+
background-color: rgba(100, 150, 255, 0.1);
285+
}
286+
257287
.tab.placeholder .tab-name {
258288
font-style: italic;
259289
color: #999;

0 commit comments

Comments
 (0)