Skip to content

Commit 17fb1a7

Browse files
committed
Only emit priority warning once
1 parent 8f7669e commit 17fb1a7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/jupyterlab-lsp/src/manager.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class LanguageServerManager implements ILanguageServerManager {
2323
private _retries: number;
2424
private _retriesInterval: number;
2525
private _configuration: TLanguageServerConfigurations;
26+
private _warningsEmitted = new Set<string>();
2627
private console: ILSPLogConsole;
2728

2829
constructor(options: ILanguageServerManager.IOptions) {
@@ -52,12 +53,19 @@ export class LanguageServerManager implements ILanguageServerManager {
5253
this._configuration = configuration;
5354
}
5455

56+
protected warnOnce(arg: string) {
57+
if (!this._warningsEmitted.has(arg)) {
58+
this._warningsEmitted.add(arg);
59+
this.console.warn(arg);
60+
}
61+
}
62+
5563
protected _comparePriorities(a: TLanguageServerId, b: TLanguageServerId) {
5664
const DEFAULT_PRIORITY = 50;
5765
const a_priority = this._configuration[a]?.priority ?? DEFAULT_PRIORITY;
5866
const b_priority = this._configuration[b]?.priority ?? DEFAULT_PRIORITY;
5967
if (a_priority == b_priority) {
60-
this.console.warn(
68+
this.warnOnce(
6169
`Two matching servers: ${a} and ${b} have the same priority; choose which one to use by changing the priority in Advanced Settings Editor`
6270
);
6371
return a.localeCompare(b);

0 commit comments

Comments
 (0)