Skip to content

Commit a9e0725

Browse files
committed
address the reviews
1 parent e702764 commit a9e0725

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/handlers/editorFileTab.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,11 @@ function updateFileList($parent) {
310310

311311
if (nextPinnedState !== undefined) {
312312
draggedFile.setPinnedState(nextPinnedState, { reorder: false });
313+
if (typeof editorManager.normalizePinnedTabOrder === "function") {
314+
editorManager.normalizePinnedTabOrder(editorManager.files);
315+
}
313316
}
314317
}
315-
316-
if (typeof editorManager.normalizePinnedTabOrder === "function") {
317-
editorManager.normalizePinnedTabOrder(editorManager.files);
318-
}
319318
}
320319

321320
/**

src/lib/editorFile.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ export default class EditorFile {
777777
}
778778

779779
setPinnedState(value, options = {}) {
780-
const { reorder = true, emit = true } = options;
780+
const { reorder = false, emit = true } = options;
781781
value = !!value;
782782
if (this.#pinned === value) return value;
783783

@@ -1529,7 +1529,10 @@ export default class EditorFile {
15291529

15301530
return tag("span", {
15311531
className: "licons pin",
1532-
title: strings["pinned tab"] || "Pinned tab",
1532+
title: strings["unpin tab"] || "Unpin tab",
1533+
dataset: {
1534+
action: "toggle-pin",
1535+
},
15331536
});
15341537
}
15351538

@@ -1581,6 +1584,10 @@ function tabOnclick(e) {
15811584
this.remove();
15821585
return;
15831586
}
1587+
if (action === "toggle-pin") {
1588+
this.togglePinned();
1589+
return;
1590+
}
15841591
this.makeActive();
15851592
}
15861593

src/lib/editorManager.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,16 +1792,7 @@ async function EditorManager($header, $body) {
17921792
}
17931793

17941794
function moveFileByPinnedState(file) {
1795-
const currentIndex = manager.files.indexOf(file);
1796-
if (currentIndex === -1) return;
1797-
1798-
const targetIndex = file.pinned ? 0 : getPinnedInsertIndex(file);
1799-
if (currentIndex !== targetIndex) {
1800-
manager.files.splice(currentIndex, 1);
1801-
manager.files.splice(targetIndex, 0, file);
1802-
}
1803-
1804-
syncOpenFileList();
1795+
if (!manager.files.includes(file)) return;
18051796
if (manager.activeFile?.id === file.id) {
18061797
file.tab.scrollIntoView();
18071798
}

0 commit comments

Comments
 (0)