Skip to content

Commit 0c6676e

Browse files
authored
fix(editor): preserve active files position after restart (Acode-Foundation#2721)
1 parent 3ee2609 commit 0c6676e

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

src/lib/editorManager.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ async function EditorManager($header, $body) {
247247
const primaryPane = createPaneShell($container);
248248
paneLayoutRoot = createPaneNode(primaryPane);
249249
$paneRoot.append(paneLayoutRoot.element);
250+
applyOpenFileListLayout();
250251
const problemButton = SideButton({
251252
text: strings.problems,
252253
icon: "warningreport_problem",
@@ -3941,8 +3942,8 @@ async function EditorManager($header, $body) {
39413942
}
39423943

39433944
function syncOpenFileList() {
3945+
applyOpenFileListLayout();
39443946
if (isPaneTabLayout()) {
3945-
$paneRoot.classList.remove("hide-pane-tabs");
39463947
panes.forEach((pane) => {
39473948
const preserveCurrentTabOrder = !!pane.tabList.querySelector(
39483949
'[data-editor-tab-dragging="true"]',
@@ -3958,7 +3959,6 @@ async function EditorManager($header, $body) {
39583959
return;
39593960
}
39603961

3961-
$paneRoot.classList.add("hide-pane-tabs");
39623962
if (!$openFileList || $openFileList === $globalOpenFileList) {
39633963
initFileTabContainer();
39643964
}
@@ -4180,6 +4180,26 @@ async function EditorManager($header, $body) {
41804180
);
41814181
}
41824182

4183+
function applyOpenFileListLayout(
4184+
openFileListPos = appSettings.value.openFileListPos,
4185+
) {
4186+
const showPaneTabs =
4187+
openFileListPos === appSettings.OPEN_FILE_LIST_POS_HEADER ||
4188+
openFileListPos === appSettings.OPEN_FILE_LIST_POS_BOTTOM;
4189+
4190+
$paneRoot.classList.toggle("hide-pane-tabs", !showPaneTabs);
4191+
if (openFileListPos === appSettings.OPEN_FILE_LIST_POS_BOTTOM) {
4192+
$paneRoot.dataset.tabsPosition = "bottom";
4193+
} else if (openFileListPos === appSettings.OPEN_FILE_LIST_POS_HEADER) {
4194+
// Header mode is rendered as the pane's top tab bar.
4195+
$paneRoot.dataset.tabsPosition = "top";
4196+
} else {
4197+
// Sidebar mode has no pane tab placement.
4198+
delete $paneRoot.dataset.tabsPosition;
4199+
}
4200+
root.setAttribute("open-file-list-pos", openFileListPos);
4201+
}
4202+
41834203
/**
41844204
* Sets up the editor with various configurations and event listeners.
41854205
* @returns {Promise<void>} A promise that resolves once the editor is set up.
@@ -4977,10 +4997,6 @@ async function EditorManager($header, $body) {
49774997
const { openFileListPos } = appSettings.value;
49784998
if (isPaneTabLayout()) {
49794999
$openFileList = $globalOpenFileList;
4980-
$paneRoot.dataset.tabsPosition =
4981-
openFileListPos === appSettings.OPEN_FILE_LIST_POS_BOTTOM
4982-
? "bottom"
4983-
: "top";
49845000
root.classList.remove("top-bar");
49855001
syncOpenFileList();
49865002
} else {
@@ -5000,7 +5016,6 @@ async function EditorManager($header, $body) {
50005016
syncOpenFileList();
50015017
}
50025018

5003-
root.setAttribute("open-file-list-pos", openFileListPos);
50045019
manager.emit("int-open-file-list", openFileListPos);
50055020
}
50065021

0 commit comments

Comments
 (0)