3
3
import * as path from 'path' ;
4
4
import * as vscode from 'vscode' ;
5
5
import { spawnSync } from 'child_process' ;
6
- import { commands , window , workspace , TextDocument , WorkspaceFolder } from 'vscode' ;
6
+ import { commands , window , workspace , TextDocument } from 'vscode' ;
7
7
import { LanguageClient , LanguageClientOptions , ServerOptions } from 'vscode-languageclient/node' ;
8
8
import {
9
9
EXTENSION_ID ,
@@ -107,8 +107,9 @@ export class FortlsClient {
107
107
108
108
// If the document is part of a standalone file and not part of a workspace
109
109
if ( ! folder ) {
110
- this . logger . logInfo ( 'Initialising Language Server for file: ' + document . uri . fsPath ) ;
111
110
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 ) ;
112
113
// Options to control the language client
113
114
const clientOptions : LanguageClientOptions = {
114
115
documentSelector : FortranDocumentSelector ( fileRoot ) ,
@@ -128,7 +129,7 @@ export class FortlsClient {
128
129
// The document is part of a workspace folder
129
130
if ( ! clients . has ( folder . uri . toString ( ) ) ) {
130
131
folder = getOuterMostWorkspaceFolder ( folder ) ;
131
- if ( clients . has ( folder . uri . toString ( ) ) ) return ;
132
+ if ( clients . has ( folder . uri . toString ( ) ) ) return ; // already registered
132
133
this . logger . logInfo ( 'Initialising Language Server for workspace: ' + folder . uri . fsPath ) ;
133
134
// Options to control the language client
134
135
const clientOptions : LanguageClientOptions = {
0 commit comments