Skip to content

Commit 7ee4deb

Browse files
committed
fix(lsp): show clear error when Terminal is not installed
1 parent 533c1ac commit 7ee4deb

32 files changed

+84
-35
lines changed

src/cm/lsp/serverLauncher.ts

Lines changed: 22 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 {
@@ -24,6 +25,11 @@ const STATUS_DECLINED: InstallStatus = "declined";
2425
const STATUS_FAILED: InstallStatus = "failed";
2526

2627
const AXS_BINARY = "$PREFIX/axs";
28+
const TERMINAL_REQUIRED_MESSAGE = strings.terminal_required_message_for_lsp;
29+
30+
interface LspError extends Error {
31+
code?: string;
32+
}
2733

2834
function getExecutor(): Executor {
2935
const executor = (globalThis as unknown as { Executor?: Executor }).Executor;
@@ -564,10 +570,6 @@ async function waitForWebSocket(
564570
);
565571
}
566572

567-
interface LspError extends Error {
568-
code?: string;
569-
}
570-
571573
export interface EnsureServerResult {
572574
uuid: string | null;
573575
/** Port discovered from port file (for auto-port discovery) */
@@ -598,6 +600,22 @@ export async function ensureServerRunning(
598600
// Failed to check, proceed with normal startup
599601
}
600602

603+
const terminal = (
604+
globalThis as unknown as {
605+
Terminal?: { isInstalled?: () => Promise<boolean> | boolean };
606+
}
607+
).Terminal;
608+
let isTerminalInstalled = false;
609+
try {
610+
isTerminalInstalled = Boolean(await terminal?.isInstalled?.());
611+
} catch {}
612+
if (!isTerminalInstalled) {
613+
alert(strings.error, TERMINAL_REQUIRED_MESSAGE);
614+
const unavailable: LspError = new Error(TERMINAL_REQUIRED_MESSAGE);
615+
unavailable.code = "LSP_SERVER_UNAVAILABLE";
616+
throw unavailable;
617+
}
618+
601619
const installed = await ensureInstalled(server);
602620
if (!installed) {
603621
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)