Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/cm/commandRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ function registerCoreCommands() {
return true;
},
});
addCommand({
name: "togglePinnedTab",
description: "Pin or unpin current tab",
readOnly: true,
requiresView: false,
run() {
acode.exec("toggle-pin-tab");
return true;
},
});
addCommand({
name: "newFile",
description: "Create new file",
Expand Down
39 changes: 30 additions & 9 deletions src/components/terminal/terminalManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class TerminalManager {
sessions.push({
pid: entry,
name: `Terminal ${entry}`,
pinned: false,
});
changed = true;
continue;
Expand All @@ -88,12 +89,13 @@ class TerminalManager {
typeof entry.name === "string" && entry.name.trim()
? entry.name.trim()
: `Terminal ${pid}`;
const pinned = entry.pinned === true;

if (entry.pid !== pid || entry.name !== name) {
if (entry.pid !== pid || entry.name !== name || entry.pinned !== pinned) {
changed = true;
}

sessions.push({ pid, name });
sessions.push({ pid, name, pinned });
}

for (const session of sessions) {
Expand All @@ -109,6 +111,7 @@ class TerminalManager {
typeof session.name === "string" && session.name.trim()
? session.name.trim()
: `Terminal ${pid}`,
pinned: session.pinned === true,
});
}

Expand Down Expand Up @@ -174,7 +177,7 @@ class TerminalManager {
}
}

async persistTerminalSession(pid, name) {
async persistTerminalSession(pid, name, pinned = false) {
if (!pid) return;

const pidStr = String(pid);
Expand All @@ -185,6 +188,7 @@ class TerminalManager {
const sessionData = {
pid: pidStr,
name: name || `Terminal ${pidStr}`,
pinned: pinned === true,
};

if (existingIndex >= 0) {
Expand Down Expand Up @@ -228,6 +232,7 @@ class TerminalManager {
const instance = await this.createServerTerminal({
pid: session.pid,
name: session.name,
pinned: session.pinned === true,
reconnecting: true,
render: false,
});
Expand Down Expand Up @@ -266,7 +271,8 @@ class TerminalManager {
*/
async createTerminal(options = {}) {
try {
const { render, serverMode, reconnecting, ...terminalOptions } = options;
const { render, serverMode, reconnecting, pinned, ...terminalOptions } =
options;
const shouldRender = render !== false;
const isServerMode = serverMode !== false;
const isReconnecting = reconnecting === true;
Expand Down Expand Up @@ -317,6 +323,7 @@ class TerminalManager {
type: "terminal",
content: terminalContainer,
tabIcon: "licons terminal",
pinned,
render: shouldRender,
});

Expand Down Expand Up @@ -363,6 +370,7 @@ class TerminalManager {
await this.persistTerminalSession(
terminalComponent.pid,
terminalName,
terminalFile.pinned,
);
}
resolve(instance);
Expand All @@ -382,7 +390,7 @@ class TerminalManager {
try {
// Force remove the tab without confirmation
terminalFile._skipTerminalCloseConfirm = true;
terminalFile.remove(true);
terminalFile.remove(true, { ignorePinned: true });
} catch (removeError) {
console.error("Error removing terminal tab:", removeError);
}
Expand Down Expand Up @@ -613,10 +621,22 @@ class TerminalManager {
terminalFile.onclose = () => {
this.closeTerminal(terminalId);
};
terminalFile.onpinstatechange = (pinned) => {
if (!terminalComponent.serverMode || !terminalComponent.pid) return;
void this.persistTerminalSession(
terminalComponent.pid,
terminalFile.filename,
pinned,
);
};

terminalFile._skipTerminalCloseConfirm = false;
const originalRemove = terminalFile.remove.bind(terminalFile);
terminalFile.remove = async (force = false) => {
terminalFile.remove = async (force = false, options = {}) => {
if (terminalFile.pinned && !options?.ignorePinned) {
return originalRemove(force, options);
}

if (
!terminalFile._skipTerminalCloseConfirm &&
this.shouldConfirmTerminalClose()
Expand All @@ -627,7 +647,7 @@ class TerminalManager {
}

terminalFile._skipTerminalCloseConfirm = false;
return originalRemove(force);
return originalRemove(force, options);
};

// Enhanced resize handling with debouncing
Expand Down Expand Up @@ -717,6 +737,7 @@ class TerminalManager {
await this.persistTerminalSession(
terminalComponent.pid,
formattedTitle,
terminalFile.pinned,
);
}

Expand Down Expand Up @@ -744,7 +765,7 @@ class TerminalManager {

this.closeTerminal(terminalId);
terminalFile._skipTerminalCloseConfirm = true;
terminalFile.remove(true);
terminalFile.remove(true, { ignorePinned: true });
toast(message);
};

Expand Down Expand Up @@ -823,7 +844,7 @@ class TerminalManager {
if (removeTab && terminal.file) {
try {
terminal.file._skipTerminalCloseConfirm = true;
terminal.file.remove(true);
terminal.file.remove(true, { ignorePinned: true });
} catch (removeError) {
console.error("Error removing terminal tab:", removeError);
}
Expand Down
20 changes: 20 additions & 0 deletions src/handlers/editorFileTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ function getClientPos(e) {
* @param {HTMLElement} $parent
*/
function updateFileList($parent) {
const pinnedCount = editorManager.files.filter((file) => file.pinned).length;
const children = [...$parent.children];
const newFileList = [];
for (let el of children) {
Expand All @@ -295,6 +296,25 @@ function updateFileList($parent) {
}

editorManager.files = newFileList;

const draggedFile = newFileList.find((file) => file.tab === $tab);
if (draggedFile) {
const draggedIndex = newFileList.indexOf(draggedFile);
let nextPinnedState;

if (!draggedFile.pinned && draggedIndex < pinnedCount) {
nextPinnedState = true;
} else if (draggedFile.pinned && draggedIndex >= pinnedCount) {
nextPinnedState = false;
}

if (nextPinnedState !== undefined) {
draggedFile.setPinnedState(nextPinnedState, { reorder: false });
if (typeof editorManager.normalizePinnedTabOrder === "function") {
editorManager.normalizePinnedTabOrder(editorManager.files);
}
}
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/lang/ar-ye.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,5 +699,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/be-by.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/bn-bd.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/de-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/es-sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/fr-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/he-il.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/hi-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/hu-hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Rendeljen formázót minden nyelvhez. További lehetőségek feloldásához telepítsen formázó bővítményeket.",
"settings-note-lsp-settings": "A nyelvi kiszolgálók automatikus kiegészítést, diagnosztikát, felugró részleteket és egyebeket nyújtanak. Itt telepíthet, frissíthet vagy definiálhat egyéni kiszolgálókat. A felügyelt telepítők a terminál/proot környezetben futnak.",
"search result label singular": "találat",
"search result label plural": "találat"
"search result label plural": "találat",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/id-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,9 @@
"settings-note-formatter-settings": "Tetapkan pemformat untuk setiap bahasa. Pasang plugin pemformat untuk membuka lebih banyak opsi.",
"settings-note-lsp-settings": "Server bahasa menambahkan fitur pelengkapan otomatis, diagnostik, detail saat kursor diarahkan ke teks, dan banyak lagi. Anda dapat memasang, memperbarui, atau menentukan server khusus di sini. Penginstal terkelola berjalan di dalam lingkungan terminal/proot.",
"search result label singular": "hasil",
"search result label plural": "hasil"
"search result label plural": "hasil",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/ir-fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/it-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/ja-jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/ko-kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/ml-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
6 changes: 5 additions & 1 deletion src/lang/mm-unicode.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,9 @@
"settings-note-formatter-settings": "Assign a formatter to each language. Install formatter plugins to unlock more options.",
"settings-note-lsp-settings": "Language servers add autocomplete, diagnostics, hover details, and more. You can install, update, or define custom servers here. Managed installers run inside the terminal/proot environment.",
"search result label singular": "result",
"search result label plural": "results"
"search result label plural": "results",
"pin tab": "Pin tab",
"unpin tab": "Unpin tab",
"pinned tab": "Pinned tab",
"unpin tab before closing": "Unpin the tab before closing it."
}
Loading