File tree Expand file tree Collapse file tree 3 files changed +11
-18
lines changed Expand file tree Collapse file tree 3 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,10 @@ export default class Biome {
185
185
* Starts the Biome instance.
186
186
*/
187
187
public async start ( ) {
188
+ if ( this . _session && this . state !== "error" ) {
189
+ return ; // Avoid starting the same session multiple times.
190
+ }
191
+
188
192
this . listenForLockfilesChanges ( ) ;
189
193
this . listenForConfigChanges ( ) ;
190
194
@@ -213,12 +217,6 @@ export default class Biome {
213
217
this . singleFileFolder ,
214
218
) ;
215
219
216
- if ( ! this . _session ) {
217
- this . state = "error" ;
218
- this . logger . error ( "Unable to create the Biome session." ) ;
219
- return ;
220
- }
221
-
222
220
try {
223
221
await this . _session ?. start ( ) ;
224
222
this . logger . info ( "✅ Biome is ready." ) ;
Original file line number Diff line number Diff line change @@ -110,7 +110,8 @@ export default class Extension {
110
110
* Creates the extension from the context
111
111
*/
112
112
public static create ( context : ExtensionContext ) : Extension {
113
- return Extension . instance ?? new Extension ( context ) ;
113
+ Extension . instance ??= new Extension ( context ) ;
114
+ return Extension . instance ;
114
115
}
115
116
116
117
/**
@@ -293,7 +294,10 @@ export default class Extension {
293
294
private async createGlobalInstance ( ) : Promise < void > {
294
295
const createGlobalInstanceIfNotExists = async ( ) => {
295
296
if ( ! this . biomes . get ( "global" ) ) {
296
- this . biomes . set ( "global" , Biome . createGlobalInstance ( this ) ) ;
297
+ const biome = Biome . createGlobalInstance ( this ) ;
298
+ biome . start ( ) ;
299
+
300
+ this . biomes . set ( "global" , biome ) ;
297
301
}
298
302
} ;
299
303
@@ -343,8 +347,7 @@ export default class Extension {
343
347
window . onDidChangeActiveTextEditor (
344
348
debounce ( async ( editor ?: TextEditor ) => {
345
349
await createGlobalInstanceIfNeeded ( editor ) ;
346
- await this . biomes . get ( "global" ) ?. start ( ) ;
347
- } , 0 ) ,
350
+ } , 10 ) ,
348
351
) ;
349
352
}
350
353
Original file line number Diff line number Diff line change @@ -72,14 +72,6 @@ export default class Session {
72
72
this . client = undefined ;
73
73
}
74
74
75
- /**
76
- * Restarts the LSP session.
77
- */
78
- public async restart ( ) {
79
- await this . stop ( ) ;
80
- await this . start ( ) ;
81
- }
82
-
83
75
/**
84
76
* Creates a new language client for the session.
85
77
*/
You can’t perform that action at this time.
0 commit comments