Skip to content

Commit

Permalink
LS: Restart LSP client instead of window reload (#6312)
Browse files Browse the repository at this point in the history
  • Loading branch information
Draggu authored Aug 30, 2024
1 parent f9f2823 commit 4193149
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions vscode-cairo/src/cairols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,29 @@ export async function setupLanguageServer(ctx: Context): Promise<lc.LanguageClie
client.onNotification(
new lc.NotificationType<string>("cairo/corelib-version-mismatch"),
async (errorMessage) => {
const reloadWindow = "Reload window";
const restart = "Restart CairoLS";
const cleanScarbCache = "Clean Scarb cache and reload";

const selectedValue = await vscode.window.showErrorMessage(
errorMessage,
reloadWindow,
restart,
cleanScarbCache,
);

const restartLS = async () => {
const client = weakClient.deref();
if (client) {
await client.restart();
}
};

switch (selectedValue) {
case reloadWindow:
await vscode.commands.executeCommand("workbench.action.reloadWindow");
case restart:
await restartLS();
break;
case cleanScarbCache:
await scarb?.cacheClean(ctx);
await vscode.commands.executeCommand("workbench.action.reloadWindow");
await restartLS();
break;
}
},
Expand Down

0 comments on commit 4193149

Please sign in to comment.