@adecore/lsp 0.44.2 → 0.44.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/session.js CHANGED
@@ -317,7 +317,8 @@ export class LspSession {
317
317
  if (!this.supports('workspace/diagnostic')) {
318
318
  return Promise.reject(new LspError('Server does not support workspace diagnostics', ErrorCodes.MethodNotFound));
319
319
  }
320
- return this.request('workspace/diagnostic', { identifier, previousResultIds: [...previousResultIds] }, options);
320
+ // The server may hold the request until something changes, so only the caller's own deadline ends it.
321
+ return this.request('workspace/diagnostic', { identifier, previousResultIds: [...previousResultIds] }, { timeoutMs: 0, ...options });
321
322
  }
322
323
  /* The text of a document of a scheme the server owns, such as a decompiled class, which is shown read-only. */
323
324
  textDocumentContent(uri, options) {
@@ -337,14 +338,26 @@ export class LspSession {
337
338
  }
338
339
  /* Adds and removes folders of the workspace, and tells a server that asked to hear about it. */
339
340
  async changeWorkspaceFolders(event) {
340
- const removed = new Set(event.removed.map((folder) => fileUriKey(folder.uri)));
341
- const kept = (this.folders ?? []).filter((folder) => !removed.has(fileUriKey(folder.uri)));
341
+ const asked = new Set(event.removed.map((folder) => fileUriKey(folder.uri)));
342
+ const current = this.folders ?? [];
343
+ const removed = current.filter((folder) => asked.has(fileUriKey(folder.uri)));
344
+ const kept = current.filter((folder) => !asked.has(fileUriKey(folder.uri)));
342
345
  const known = new Set(kept.map((folder) => fileUriKey(folder.uri)));
343
- this.folders = [...kept, ...event.added.filter((folder) => !known.has(fileUriKey(folder.uri)))];
346
+ const added = [];
347
+ for (const folder of event.added) {
348
+ if (!known.has(fileUriKey(folder.uri))) {
349
+ known.add(fileUriKey(folder.uri));
350
+ added.push(folder);
351
+ }
352
+ }
353
+ this.folders = [...kept, ...added];
354
+ if (removed.length === 0 && added.length === 0) {
355
+ return;
356
+ }
344
357
  const notifications = this.serverCapabilities.workspace?.workspaceFolders?.changeNotifications;
345
358
  const registered = [...this.registrations.values()].some((registration) => registration.method === 'workspace/didChangeWorkspaceFolders');
346
359
  if (this.phase === 'ready' && (notifications === true || typeof notifications === 'string' || registered)) {
347
- await this.notify('workspace/didChangeWorkspaceFolders', { event: { added: [...event.added], removed: [...event.removed] } });
360
+ await this.notify('workspace/didChangeWorkspaceFolders', { event: { added, removed } });
348
361
  }
349
362
  }
350
363
  /* Whether the server synchronizes notebooks of this type and scheme; the `notebook*` methods do nothing for one it does not. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/lsp",
3
- "version": "0.44.2",
3
+ "version": "0.44.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/session.ts CHANGED
@@ -484,7 +484,8 @@ export class LspSession {
484
484
  if (!this.supports('workspace/diagnostic')) {
485
485
  return Promise.reject(new LspError('Server does not support workspace diagnostics', ErrorCodes.MethodNotFound));
486
486
  }
487
- return this.request('workspace/diagnostic', { identifier, previousResultIds: [...previousResultIds] }, options);
487
+ // The server may hold the request until something changes, so only the caller's own deadline ends it.
488
+ return this.request('workspace/diagnostic', { identifier, previousResultIds: [...previousResultIds] }, { timeoutMs: 0, ...options });
488
489
  }
489
490
 
490
491
  /* The text of a document of a scheme the server owns, such as a decompiled class, which is shown read-only. */
@@ -508,14 +509,26 @@ export class LspSession {
508
509
 
509
510
  /* Adds and removes folders of the workspace, and tells a server that asked to hear about it. */
510
511
  async changeWorkspaceFolders(event: WorkspaceFoldersChangeEvent): Promise<void> {
511
- const removed = new Set(event.removed.map((folder) => fileUriKey(folder.uri)));
512
- const kept = (this.folders ?? []).filter((folder) => !removed.has(fileUriKey(folder.uri)));
512
+ const asked = new Set(event.removed.map((folder) => fileUriKey(folder.uri)));
513
+ const current = this.folders ?? [];
514
+ const removed = current.filter((folder) => asked.has(fileUriKey(folder.uri)));
515
+ const kept = current.filter((folder) => !asked.has(fileUriKey(folder.uri)));
513
516
  const known = new Set(kept.map((folder) => fileUriKey(folder.uri)));
514
- this.folders = [...kept, ...event.added.filter((folder) => !known.has(fileUriKey(folder.uri)))];
517
+ const added: WorkspaceFolder[] = [];
518
+ for (const folder of event.added) {
519
+ if (!known.has(fileUriKey(folder.uri))) {
520
+ known.add(fileUriKey(folder.uri));
521
+ added.push(folder);
522
+ }
523
+ }
524
+ this.folders = [...kept, ...added];
525
+ if (removed.length === 0 && added.length === 0) {
526
+ return;
527
+ }
515
528
  const notifications = this.serverCapabilities.workspace?.workspaceFolders?.changeNotifications;
516
529
  const registered = [...this.registrations.values()].some((registration) => registration.method === 'workspace/didChangeWorkspaceFolders');
517
530
  if (this.phase === 'ready' && (notifications === true || typeof notifications === 'string' || registered)) {
518
- await this.notify('workspace/didChangeWorkspaceFolders', { event: { added: [...event.added], removed: [...event.removed] } });
531
+ await this.notify('workspace/didChangeWorkspaceFolders', { event: { added, removed } });
519
532
  }
520
533
  }
521
534