Skip to content

Commit a338012

Browse files
authored
fix(lsp): show clear error when Terminal is not installed (Acode-Foundation#1900)
1 parent 533c1ac commit a338012

32 files changed

+91
-35
lines changed

src/cm/lsp/serverLauncher.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import lspStatusBar from "components/lspStatusBar";
22
import toast from "components/toast";
3+
import alert from "dialogs/alert";
34
import confirm from "dialogs/confirm";
45
import loader from "dialogs/loader";
56
import type {
@@ -25,6 +26,17 @@ const STATUS_FAILED: InstallStatus = "failed";
2526

2627
const AXS_BINARY = "$PREFIX/axs";
2728

29+
function getTerminalRequiredMessage(): string {
30+
return (
31+
strings?.terminal_required_message_for_lsp ??
32+
"Terminal not installed. Please install Terminal first to use LSP servers."
33+
);
34+
}
35+
36+
interface LspError extends Error {
37+
code?: string;
38+
}
39+
2840
function getExecutor(): Executor {
2941
const executor = (globalThis as unknown as { Executor?: Executor }).Executor;
3042
if (!executor) {
@@ -564,10 +576,6 @@ async function waitForWebSocket(
564576
);
565577
}
566578

567-
interface LspError extends Error {
568-
code?: string;
569-
}
570-
571579
export interface EnsureServerResult {
572580
uuid: string | null;
573581
/** Port discovered from port file (for auto-port discovery) */
@@ -598,6 +606,23 @@ export async function ensureServerRunning(
598606
// Failed to check, proceed with normal startup
599607
}
600608

609+
const terminal = (
610+
globalThis as unknown as {
611+
Terminal?: { isInstalled?: () => Promise<boolean> | boolean };
612+
}
613+
).Terminal;
614+
let isTerminalInstalled = false;
615+
try {
616+
isTerminalInstalled = Boolean(await terminal?.isInstalled?.());
617+
} catch {}
618+
if (!isTerminalInstalled) {
619+
const message = getTerminalRequiredMessage();
620+
alert(strings?.error, message);
621+
const unavailable: LspError = new Error(message);
622+
unavailable.code = "LSP_SERVER_UNAVAILABLE";
623+
throw unavailable;
624+
}
625+
601626
const installed = await ensureInstalled(server);
602627
if (!installed) {
603628
const unavailable: LspError = new Error(

src/lang/ar-ye.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,5 +502,6 @@
502502
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
503503
"add to home screen": "Add to home screen",
504504
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
505-
"save file before home shortcut": "Save the file before adding it to the home screen."
505+
"save file before home shortcut": "Save the file before adding it to the home screen.",
506+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
506507
}

src/lang/be-by.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,6 @@
504504
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
505505
"add to home screen": "Add to home screen",
506506
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
507-
"save file before home shortcut": "Save the file before adding it to the home screen."
507+
"save file before home shortcut": "Save the file before adding it to the home screen.",
508+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
508509
}

src/lang/bn-bd.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/cs-cz.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/de-de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/en-us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/es-sv.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/fr-fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,6 @@
503503
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
504504
"add to home screen": "Add to home screen",
505505
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
506-
"save file before home shortcut": "Save the file before adding it to the home screen."
506+
"save file before home shortcut": "Save the file before adding it to the home screen.",
507+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
507508
}

src/lang/he-il.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,6 @@
504504
"shortcut request sent": "Shortcut request opened. Tap Add to finish.",
505505
"add to home screen": "Add to home screen",
506506
"pin shortcuts not supported": "Home screen shortcuts are not supported on this device.",
507-
"save file before home shortcut": "Save the file before adding it to the home screen."
507+
"save file before home shortcut": "Save the file before adding it to the home screen.",
508+
"terminal_required_message_for_lsp": "Terminal not installed. Please install Terminal first to use LSP servers."
508509
}

0 commit comments

Comments
 (0)