Skip to content

Commit 58cf3df

Browse files
committed
Adds checks to prevent double registering a server
1 parent 065b052 commit 58cf3df

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lsp/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as path from 'path';
44
import * as vscode from 'vscode';
55
import { spawnSync } from 'child_process';
6-
import { commands, window, workspace, TextDocument, WorkspaceFolder } from 'vscode';
6+
import { commands, window, workspace, TextDocument } from 'vscode';
77
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
88
import {
99
EXTENSION_ID,
@@ -107,8 +107,9 @@ export class FortlsClient {
107107

108108
// If the document is part of a standalone file and not part of a workspace
109109
if (!folder) {
110-
this.logger.logInfo('Initialising Language Server for file: ' + document.uri.fsPath);
111110
const fileRoot: string = path.dirname(document.uri.fsPath);
111+
if (clients.has(fileRoot)) return; // already registered
112+
this.logger.logInfo('Initialising Language Server for file: ' + document.uri.fsPath);
112113
// Options to control the language client
113114
const clientOptions: LanguageClientOptions = {
114115
documentSelector: FortranDocumentSelector(fileRoot),
@@ -128,7 +129,7 @@ export class FortlsClient {
128129
// The document is part of a workspace folder
129130
if (!clients.has(folder.uri.toString())) {
130131
folder = getOuterMostWorkspaceFolder(folder);
131-
if (clients.has(folder.uri.toString())) return;
132+
if (clients.has(folder.uri.toString())) return; // already registered
132133
this.logger.logInfo('Initialising Language Server for workspace: ' + folder.uri.fsPath);
133134
// Options to control the language client
134135
const clientOptions: LanguageClientOptions = {

0 commit comments

Comments
 (0)