Skip to content

Commit

Permalink
fix: properly detect 1.37.0 (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Sep 6, 2023
1 parent d60350a commit 2a45179
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ function configToWorkspaceSettings(
const workspaceSettings = Object.create(null);
for (const key of workspaceSettingsKeys) {
workspaceSettings[key] = config.get(key);
// Deno LSP versions < 1.37.0 require `deno.enable` to be non-null.
// TODO(nayeemrmn): Deno LSP versions < 1.37.0 require `deno.enable` to be
// non-null. Eventually remove this.
if (
semver.lt(extensionContext.serverInfo?.version ?? "1.0.0", "1.37.0") &&
semver.lt(extensionContext.serverInfo?.version ?? "1.0.0", "1.37.0-rc") &&
key == "enable"
) {
workspaceSettings[key] ??= false;
Expand Down Expand Up @@ -153,6 +154,8 @@ function handleConfigurationChange(event: vscode.ConfigurationChangeEvent) {

// restart when certain config changes
if (
event.affectsConfiguration("deno.enable") ||
event.affectsConfiguration("deno.enablePaths") ||
event.affectsConfiguration("deno.path") ||
event.affectsConfiguration("deno.maxTsServerMemory")
) {
Expand Down Expand Up @@ -312,6 +315,12 @@ export async function activate(
handleDocumentOpen(...vscode.workspace.textDocuments);

await commands.startLanguageServer(context, extensionContext)();
// TODO(nayeemrmn): Deno LSP versions < 1.37.0 has different compat logic.
// We restart here if it's detected. Eventually remove this.
if (!semver.lt(extensionContext.serverInfo!.version, "1.37.0-rc")) {
extensionContext.workspaceSettings = getWorkspaceSettings();
await commands.startLanguageServer(context, extensionContext)();
}

// Register any commands.
const registerCommand = createRegisterCommand(context);
Expand Down

0 comments on commit 2a45179

Please sign in to comment.