@theia/core 1.75.0 → 1.76.0-next.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.
@@ -1,7 +1,14 @@
1
1
  import { CancellationToken, Disposable, Event } from '../common';
2
2
  import URI from '../common/uri';
3
3
  export interface DecorationsProvider {
4
- readonly onDidChange: Event<URI[]>;
4
+ /**
5
+ * Signals that decorations changed for the given resources. Firing `undefined` is a
6
+ * flush event: all previously provided decorations may have changed, cached data is
7
+ * dropped and re-fetched on demand. The last known decorations keep being served
8
+ * until the re-fetch of their resource settles, so that displayed decorations do
9
+ * not blink out while the round trip is in flight.
10
+ */
11
+ readonly onDidChange: Event<URI[] | undefined>;
5
12
  provideDecorations(uri: URI, token: CancellationToken): Decoration | Promise<Decoration | undefined> | undefined;
6
13
  }
7
14
  export interface Decoration {
@@ -16,6 +23,16 @@ export interface ResourceDecorationChangeEvent {
16
23
  }
17
24
  export declare const DecorationsService: unique symbol;
18
25
  export interface DecorationsService {
26
+ /**
27
+ * Fired when decorations changed. The payload maps the string representation of the
28
+ * affected resource URIs to their new decoration. Removals are never part of the
29
+ * payload: resources whose decoration was removed are simply absent, and an empty
30
+ * map signals that an unspecified set of decorations changed (e.g. a provider fired
31
+ * a flush event). Clients must therefore track the resources they display and
32
+ * re-query them on every event rather than react to the payload keys alone. Change
33
+ * notifications caused by asynchronously resolving decoration requests are batched:
34
+ * many resolutions result in a single event.
35
+ */
19
36
  readonly onDidChangeDecorations: Event<Map<string, Decoration>>;
20
37
  registerDecorationsProvider(provider: DecorationsProvider): Disposable;
21
38
  getDecoration(uri: URI, includeChildren: boolean): Decoration[];
@@ -23,9 +40,20 @@ export interface DecorationsService {
23
40
  export declare class DecorationsServiceImpl implements DecorationsService {
24
41
  private readonly data;
25
42
  private readonly onDidChangeDecorationsEmitter;
43
+ /**
44
+ * Accumulates decoration changes until the batched {@link onDidChangeDecorations}
45
+ * event fires. `undefined` values mark removed decorations.
46
+ */
47
+ private readonly pendingChanges;
48
+ private pendingFlush;
26
49
  readonly onDidChangeDecorations: Event<Map<string, Decoration>>;
50
+ /** Coalesces all changes of the same tick into a single event. */
51
+ protected readonly fireSoon: import("lodash").DebouncedFunc<() => void>;
27
52
  dispose(): void;
28
53
  registerDecorationsProvider(provider: DecorationsProvider): Disposable;
29
54
  getDecoration(uri: URI, includeChildren: boolean): Decoration[];
55
+ protected notifyDecorationChange(uri: URI, decoration: Decoration | undefined): void;
56
+ protected notifyFlush(): void;
57
+ protected fireChangeEvent(): void;
30
58
  }
31
59
  //# sourceMappingURL=decorations-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorations-service.d.ts","sourceRoot":"","sources":["../../src/browser/decorations-service.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAA2B,UAAU,EAAW,KAAK,EAAE,MAAM,WAAW,CAAC;AAEnG,OAAO,GAAG,MAAM,eAAe,CAAC;AAQhC,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACnC,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CACpH;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,6BAA6B;IAC1C,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;CACtC;AACD,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D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ise_util_1 = require("../common/promise-util");
22
22
  const common_1 = require("../common");
23
23
  const ternary_search_tree_1 = require("../common/ternary-search-tree");
24
+ const debounce = require("lodash.debounce");
24
25
  exports.DecorationsService = Symbol('DecorationsService');
25
26
  class DecorationDataRequest {
26
- constructor(source, thenable) {
27
+ constructor(source, thenable,
28
+ /**
29
+ * Last settled decoration from before this request started. It is served while
30
+ * the request is in flight and used to detect removals when it resolves.
31
+ */
32
+ previous) {
27
33
  this.source = source;
28
34
  this.thenable = thenable;
35
+ this.previous = previous;
29
36
  }
30
37
  }
38
+ /**
39
+ * A decoration that a flush event marked as possibly outdated. It is served until its
40
+ * resource is queried again, which triggers the re-fetch.
41
+ */
42
+ class StaleDecoration {
43
+ constructor(value) {
44
+ this.value = value;
45
+ }
46
+ }
47
+ /**
48
+ * The decoration an entry last settled on: the resolved decoration itself, the
49
+ * pre-request value of an in-flight request, or the flushed value of a stale entry.
50
+ */
51
+ function lastKnownDecoration(entry) {
52
+ if (entry instanceof DecorationDataRequest) {
53
+ return entry.previous;
54
+ }
55
+ if (entry instanceof StaleDecoration) {
56
+ return entry.value;
57
+ }
58
+ return entry ?? undefined;
59
+ }
31
60
  class DecorationProviderWrapper {
32
- constructor(provider, onDidChangeDecorationsEmitter) {
61
+ constructor(provider,
62
+ /** Reports a changed decoration, or `undefined` when the decoration was removed. */
63
+ notifyDecorationChange,
64
+ /** Reports that all decorations of this provider may have changed. */
65
+ notifyFlush) {
33
66
  this.provider = provider;
34
- this.onDidChangeDecorationsEmitter = onDidChangeDecorationsEmitter;
35
- this.decorations = new Map();
67
+ this.notifyDecorationChange = notifyDecorationChange;
68
+ this.notifyFlush = notifyFlush;
36
69
  this.data = ternary_search_tree_1.TernarySearchTree.forUris(true);
37
- this.disposable = this.provider.onDidChange(async (uris) => {
38
- this.decorations.clear();
70
+ this.disposable = this.provider.onDidChange(uris => {
39
71
  if (!uris) {
40
- this.data.clear();
72
+ this.flush();
41
73
  }
42
74
  else {
75
+ // selective changes -> re-fetch the given resources
43
76
  for (const uri of uris) {
44
77
  this.fetchData(uri);
45
- const decoration = await provider.provideDecorations(uri, common_1.CancellationToken.None);
46
- if (decoration) {
47
- this.decorations.set(uri.toString(), decoration);
48
- }
49
78
  }
50
79
  }
51
- this.onDidChangeDecorationsEmitter.fire(this.decorations);
52
80
  });
53
81
  }
54
82
  dispose() {
55
83
  this.disposable.dispose();
56
84
  this.data.clear();
57
85
  }
58
- knowsAbout(uri) {
59
- return !!this.data.get(uri) || Boolean(this.data.findSuperstr(uri));
86
+ /**
87
+ * Handles a flush event: all cached data is dropped to be re-fetched on demand.
88
+ * Previously fetched decorations are kept as {@link StaleDecoration stale} values
89
+ * that are served until the re-fetch of their resource settles, so that displayed
90
+ * decorations do not blink out while the round trip is in flight.
91
+ */
92
+ flush() {
93
+ const stale = [];
94
+ this.data.forEach((value, key) => {
95
+ if (value instanceof DecorationDataRequest) {
96
+ value.source.cancel();
97
+ }
98
+ const decoration = lastKnownDecoration(value);
99
+ if (decoration) {
100
+ stale.push([key, new StaleDecoration(decoration)]);
101
+ }
102
+ });
103
+ this.data.clear();
104
+ for (const [key, value] of stale) {
105
+ this.data.set(key, value);
106
+ }
107
+ this.notifyFlush();
60
108
  }
61
109
  getOrRetrieve(uri, includeChildren, callback) {
62
110
  let item = this.data.get(uri);
63
- if (item === undefined) {
64
- // unknown -> trigger request
111
+ if (item === undefined || item instanceof StaleDecoration) {
112
+ // unknown or stale -> trigger request
65
113
  item = this.fetchData(uri);
66
114
  }
67
- if (item && !(item instanceof DecorationDataRequest)) {
68
- // found something (which isn't pending anymore)
69
- callback(item, false);
115
+ // the result, or the last known decoration while a request is in flight
116
+ const decoration = lastKnownDecoration(item);
117
+ if (decoration) {
118
+ callback(decoration, false);
70
119
  }
71
120
  if (includeChildren) {
72
- // (resolved) children
121
+ // (last known decorations of) children
73
122
  const iter = this.data.findSuperstr(uri);
74
123
  if (iter) {
75
124
  let next = iter.next();
76
125
  while (!next.done) {
77
- const value = next.value;
78
- if (value && !(value instanceof DecorationDataRequest)) {
126
+ const value = lastKnownDecoration(next.value);
127
+ if (value) {
79
128
  callback(value, true);
80
129
  }
81
130
  next = iter.next();
@@ -84,36 +133,45 @@ class DecorationProviderWrapper {
84
133
  }
85
134
  }
86
135
  fetchData(uri) {
87
- // check for pending request and cancel it
88
- const pendingRequest = this.data.get(uri);
89
- if (pendingRequest instanceof DecorationDataRequest) {
90
- pendingRequest.source.cancel();
136
+ // check for pending request and cancel it, keeping the last settled value
137
+ const existing = this.data.get(uri);
138
+ const previous = lastKnownDecoration(existing);
139
+ if (existing instanceof DecorationDataRequest) {
140
+ existing.source.cancel();
91
141
  this.data.delete(uri);
92
142
  }
93
143
  const source = new common_1.CancellationTokenSource();
94
144
  const dataOrThenable = this.provider.provideDecorations(uri, source.token);
95
145
  if (!(0, promise_util_1.isThenable)(dataOrThenable)) {
96
146
  // sync -> we have a result now
97
- return this.keepItem(uri, dataOrThenable);
147
+ return this.keepItem(uri, dataOrThenable, previous);
98
148
  }
99
149
  else {
100
150
  // async -> we have a result soon
101
151
  const request = new DecorationDataRequest(source, Promise.resolve(dataOrThenable).then(data => {
102
152
  if (this.data.get(uri) === request) {
103
- this.keepItem(uri, data);
153
+ this.keepItem(uri, data, request.previous);
104
154
  }
105
155
  }).catch(err => {
106
156
  if (!(err instanceof Error && err.name === 'Canceled' && err.message === 'Canceled') && this.data.get(uri) === request) {
107
157
  this.data.delete(uri);
108
158
  }
109
- }));
159
+ }), previous);
110
160
  this.data.set(uri, request);
111
- return undefined;
161
+ return request;
112
162
  }
113
163
  }
114
- keepItem(uri, data) {
115
- const deco = data ? data : undefined;
164
+ keepItem(uri, data, previous) {
165
+ // eslint-disable-next-line no-null/no-null
166
+ const deco = data ? data : null;
116
167
  this.data.set(uri, deco);
168
+ if (deco || previous) {
169
+ // only notify when something actually changed: a decoration appeared or
170
+ // changed, or a previously known decoration was removed. Resources resolving
171
+ // to "no decoration" from an unknown or pending state stay silent so that
172
+ // on-demand queries of undecorated resources cause no render churn.
173
+ this.notifyDecorationChange(uri, deco ?? undefined);
174
+ }
117
175
  return deco;
118
176
  }
119
177
  }
@@ -121,20 +179,29 @@ let DecorationsServiceImpl = class DecorationsServiceImpl {
121
179
  constructor() {
122
180
  this.data = [];
123
181
  this.onDidChangeDecorationsEmitter = new common_1.Emitter();
182
+ /**
183
+ * Accumulates decoration changes until the batched {@link onDidChangeDecorations}
184
+ * event fires. `undefined` values mark removed decorations.
185
+ */
186
+ this.pendingChanges = new Map();
187
+ this.pendingFlush = false;
124
188
  this.onDidChangeDecorations = this.onDidChangeDecorationsEmitter.event;
189
+ /** Coalesces all changes of the same tick into a single event. */
190
+ this.fireSoon = debounce(() => this.fireChangeEvent(), 0);
125
191
  }
126
192
  dispose() {
193
+ this.fireSoon.cancel();
127
194
  this.onDidChangeDecorationsEmitter.dispose();
128
195
  }
129
196
  registerDecorationsProvider(provider) {
130
- const wrapper = new DecorationProviderWrapper(provider, this.onDidChangeDecorationsEmitter);
197
+ const wrapper = new DecorationProviderWrapper(provider, (uri, decoration) => this.notifyDecorationChange(uri, decoration), () => this.notifyFlush());
131
198
  this.data.push(wrapper);
132
199
  return common_1.Disposable.create(() => {
133
- // fire event that says 'yes' for any resource
134
- // known to this provider. then dispose and remove it.
200
+ // dispose and remove the provider, then signal that
201
+ // any of its previously provided decorations may be gone.
135
202
  this.data.splice(this.data.indexOf(wrapper), 1);
136
- this.onDidChangeDecorationsEmitter.fire(new Map());
137
203
  wrapper.dispose();
204
+ this.notifyFlush();
138
205
  });
139
206
  }
140
207
  getDecoration(uri, includeChildren) {
@@ -150,6 +217,27 @@ let DecorationsServiceImpl = class DecorationsServiceImpl {
150
217
  }
151
218
  return data;
152
219
  }
220
+ notifyDecorationChange(uri, decoration) {
221
+ this.pendingChanges.set(uri.toString(), decoration);
222
+ this.fireSoon();
223
+ }
224
+ notifyFlush() {
225
+ this.pendingFlush = true;
226
+ this.fireSoon();
227
+ }
228
+ fireChangeEvent() {
229
+ const event = new Map();
230
+ if (!this.pendingFlush) {
231
+ for (const [uri, decoration] of this.pendingChanges) {
232
+ if (decoration) {
233
+ event.set(uri, decoration);
234
+ }
235
+ }
236
+ }
237
+ this.pendingFlush = false;
238
+ this.pendingChanges.clear();
239
+ this.onDidChangeDecorationsEmitter.fire(event);
240
+ }
153
241
  };
154
242
  exports.DecorationsServiceImpl = DecorationsServiceImpl;
155
243
  exports.DecorationsServiceImpl = DecorationsServiceImpl = tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"decorations-service.js","sourceRoot":"","sources":["../../src/browser/decorations-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,yCAAuC;AACvC,yDAAoD;AACpD,sCAAmG;AACnG,uEAAkE;AAyBrD,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAU/D,MAAM,qBAAqB;IACvB,YACa,MAA+B,EAC/B,QAAuB;QADvB,WAAM,GAAN,MAAM,CAAyB;QAC/B,aAAQ,GAAR,QAAQ,CAAe;IAChC,CAAC;CACR;AAED,MAAM,yBAAyB;IAM3B,YACa,QAA6B,EAC7B,6BAA+D;QAD/D,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,kCAA6B,GAA7B,6BAA6B,CAAkC;QALnE,gBAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;QAQtD,IAAI,CAAC,IAAI,GAAG,uCAAiB,CAAC,OAAO,CAAiD,IAAI,CAAC,CAAC;QAE5F,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;YACrD,IAAI,CAAC,WAAW,CA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,YAAY,EAAE,CAAC;YACrB,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBAClD,IAAI,UAAU,EAAE,CAAC;oBACb,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC/B,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AA7EY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CA6ElC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=decorations-service.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorations-service.spec.d.ts","sourceRoot":"","sources":["../../src/browser/decorations-service.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 Safi Seid-Ahmad, K2view and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const chai_1 = require("chai");
19
+ const common_1 = require("../common");
20
+ const uri_1 = require("../common/uri");
21
+ const decorations_service_1 = require("./decorations-service");
22
+ class TestDecorationsProvider {
23
+ constructor() {
24
+ this.onDidChangeEmitter = new common_1.Emitter();
25
+ this.decorations = new Map();
26
+ this.queried = [];
27
+ this.asynchronous = true;
28
+ }
29
+ get onDidChange() {
30
+ return this.onDidChangeEmitter.event;
31
+ }
32
+ fireDidChange(uris) {
33
+ this.onDidChangeEmitter.fire(uris);
34
+ }
35
+ provideDecorations(uri, token) {
36
+ this.queried.push(uri.toString());
37
+ const decoration = this.decorations.get(uri.toString());
38
+ return this.asynchronous ? Promise.resolve(decoration) : decoration;
39
+ }
40
+ }
41
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
42
+ describe('DecorationsServiceImpl', () => {
43
+ const uriA = new uri_1.default('file:///project/a.ts');
44
+ const uriB = new uri_1.default('file:///project/b.ts');
45
+ let service;
46
+ let provider;
47
+ let events;
48
+ beforeEach(() => {
49
+ service = new decorations_service_1.DecorationsServiceImpl();
50
+ provider = new TestDecorationsProvider();
51
+ service.registerDecorationsProvider(provider);
52
+ events = [];
53
+ service.onDidChangeDecorations(event => events.push(event));
54
+ });
55
+ afterEach(() => {
56
+ service.dispose();
57
+ });
58
+ it('resolves decorations of synchronous providers on first query', () => {
59
+ provider.asynchronous = false;
60
+ provider.decorations.set(uriA.toString(), { letter: 'M' });
61
+ const result = service.getDecoration(uriA, false);
62
+ (0, chai_1.expect)(result).to.have.lengthOf(1);
63
+ (0, chai_1.expect)(result[0].letter).to.equal('M');
64
+ });
65
+ it('caches "no decoration" results and does not query the provider again', async () => {
66
+ (0, chai_1.expect)(service.getDecoration(uriA, false)).to.have.lengthOf(0);
67
+ await sleep(20);
68
+ (0, chai_1.expect)(provider.queried).to.have.lengthOf(1);
69
+ (0, chai_1.expect)(service.getDecoration(uriA, false)).to.have.lengthOf(0);
70
+ await sleep(20);
71
+ (0, chai_1.expect)(provider.queried).to.have.lengthOf(1);
72
+ });
73
+ it('does not fire an event when an unknown resource resolves to no decoration', async () => {
74
+ service.getDecoration(uriA, false);
75
+ await sleep(20);
76
+ (0, chai_1.expect)(events).to.have.lengthOf(0);
77
+ });
78
+ it('fires a single batched event for resolutions of the same tick', async () => {
79
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
80
+ provider.decorations.set(uriB.toString(), { letter: 'B' });
81
+ service.getDecoration(uriA, false);
82
+ service.getDecoration(uriB, false);
83
+ await sleep(20);
84
+ (0, chai_1.expect)(events).to.have.lengthOf(1);
85
+ (0, chai_1.expect)(events[0].get(uriA.toString())?.letter).to.equal('A');
86
+ (0, chai_1.expect)(events[0].get(uriB.toString())?.letter).to.equal('B');
87
+ const cached = service.getDecoration(uriA, false);
88
+ (0, chai_1.expect)(cached).to.have.lengthOf(1);
89
+ (0, chai_1.expect)(cached[0].letter).to.equal('A');
90
+ });
91
+ it('re-fetches a resource when the provider signals a change for it', async () => {
92
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
93
+ service.getDecoration(uriA, false);
94
+ await sleep(20);
95
+ events.length = 0;
96
+ const queriesAfterWarmUp = provider.queried.length;
97
+ provider.decorations.set(uriA.toString(), { letter: 'D' });
98
+ provider.fireDidChange([uriA]);
99
+ await sleep(20);
100
+ (0, chai_1.expect)(provider.queried.length).to.be.greaterThan(queriesAfterWarmUp);
101
+ (0, chai_1.expect)(events).to.have.lengthOf(1);
102
+ (0, chai_1.expect)(events[0].get(uriA.toString())?.letter).to.equal('D');
103
+ (0, chai_1.expect)(service.getDecoration(uriA, false)[0].letter).to.equal('D');
104
+ });
105
+ it('fires an event when a decoration is removed', async () => {
106
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
107
+ service.getDecoration(uriA, false);
108
+ await sleep(20);
109
+ events.length = 0;
110
+ provider.decorations.delete(uriA.toString());
111
+ provider.fireDidChange([uriA]);
112
+ await sleep(20);
113
+ (0, chai_1.expect)(events).to.have.lengthOf(1);
114
+ (0, chai_1.expect)(events[0].has(uriA.toString())).to.equal(false);
115
+ (0, chai_1.expect)(service.getDecoration(uriA, false)).to.have.lengthOf(0);
116
+ });
117
+ it('announces a removal that settles synchronously after a cancelled in-flight request', async () => {
118
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
119
+ service.getDecoration(uriA, false);
120
+ await sleep(20);
121
+ events.length = 0;
122
+ // an async re-fetch is superseded by a synchronous one that removes the decoration
123
+ provider.fireDidChange([uriA]);
124
+ provider.asynchronous = false;
125
+ provider.decorations.delete(uriA.toString());
126
+ provider.fireDidChange([uriA]);
127
+ await sleep(20);
128
+ (0, chai_1.expect)(events).to.have.lengthOf(1);
129
+ (0, chai_1.expect)(events[0].has(uriA.toString())).to.equal(false);
130
+ (0, chai_1.expect)(service.getDecoration(uriA, false)).to.have.lengthOf(0);
131
+ });
132
+ it('keeps serving the previous decoration while a selective re-fetch is in flight', async () => {
133
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
134
+ service.getDecoration(uriA, false);
135
+ await sleep(20);
136
+ provider.decorations.set(uriA.toString(), { letter: 'D' });
137
+ provider.fireDidChange([uriA]);
138
+ const whileInFlight = service.getDecoration(uriA, false);
139
+ (0, chai_1.expect)(whileInFlight).to.have.lengthOf(1);
140
+ (0, chai_1.expect)(whileInFlight[0].letter).to.equal('A');
141
+ await sleep(20);
142
+ (0, chai_1.expect)(service.getDecoration(uriA, false)[0].letter).to.equal('D');
143
+ });
144
+ it('keeps serving the last known decoration while a flush re-fetch is in flight', async () => {
145
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
146
+ service.getDecoration(uriA, false);
147
+ await sleep(20);
148
+ provider.decorations.set(uriA.toString(), { letter: 'D' });
149
+ provider.fireDidChange(undefined);
150
+ await sleep(20);
151
+ // the first query after the flush triggers the re-fetch but serves the stale value
152
+ const whileInFlight = service.getDecoration(uriA, false);
153
+ (0, chai_1.expect)(whileInFlight).to.have.lengthOf(1);
154
+ (0, chai_1.expect)(whileInFlight[0].letter).to.equal('A');
155
+ await sleep(20);
156
+ (0, chai_1.expect)(service.getDecoration(uriA, false)[0].letter).to.equal('D');
157
+ });
158
+ it('drops all cached data on a flush event and re-fetches on demand', async () => {
159
+ provider.decorations.set(uriA.toString(), { letter: 'A' });
160
+ service.getDecoration(uriA, false);
161
+ service.getDecoration(uriB, false);
162
+ await sleep(20);
163
+ events.length = 0;
164
+ const queriesAfterWarmUp = provider.queried.length;
165
+ provider.fireDidChange(undefined);
166
+ await sleep(20);
167
+ // the flush itself announces an unspecified change with an empty payload
168
+ (0, chai_1.expect)(events).to.have.lengthOf(1);
169
+ (0, chai_1.expect)(events[0].size).to.equal(0);
170
+ service.getDecoration(uriA, false);
171
+ service.getDecoration(uriB, false);
172
+ await sleep(20);
173
+ (0, chai_1.expect)(provider.queried.length).to.equal(queriesAfterWarmUp + 2);
174
+ (0, chai_1.expect)(service.getDecoration(uriA, false)[0].letter).to.equal('A');
175
+ });
176
+ });
177
+ //# sourceMappingURL=decorations-service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorations-service.spec.js","sourceRoot":"","sources":["../../src/browser/decorations-service.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yDAAyD;AACzD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,+BAA8B;AAC9B,sCAA8D;AAC9D,uCAAgC;AAChC,+DAAgG;AAEhG,MAAM,uBAAuB;IAA7B;QAEuB,uBAAkB,GAAG,IAAI,gBAAO,EAAqB,CAAC;QAChE,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC5C,YAAO,GAAa,EAAE,CAAC;QAChC,iBAAY,GAAG,IAAI,CAAC;IAexB,CAAC;IAbG,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;IACzC,CAAC;IAED,aAAa,CAAC,IAAY;QACtB,IAAI,CAAC,kBAAkB,CAAC,I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AAC,EAAE,CAAC,CAAC;QAChB,IAAA,aAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC;QACjE,IAAA,aAAM,EAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
@@ -6,6 +6,11 @@ import '../../src/browser/style/hover-service.css';
6
6
  export type HoverPosition = 'left' | 'right' | 'top' | 'bottom';
7
7
  export declare namespace HoverPosition {
8
8
  function invertIfNecessary(position: HoverPosition, target: DOMRect, host: DOMRect, totalWidth: number, totalHeight: number): HoverPosition;
9
+ /**
10
+ * Tests whether a hover of the given dimensions fits next to its target in the given
11
+ * position without extending beyond the window bounds.
12
+ */
13
+ function fits(position: HoverPosition, target: DOMRect, host: DOMRect, totalWidth: number, totalHeight: number): boolean;
9
14
  }
10
15
  export interface HoverRequest {
11
16
  content: string | MarkdownString | HTMLElement;
@@ -49,14 +54,40 @@ export declare class HoverService {
49
54
  protected readonly markdownRenderer: MarkdownRenderer;
50
55
  protected readonly openerService: OpenerService;
51
56
  protected _hoverHost: HTMLElement | undefined;
57
+ /**
58
+ * The host of the current hover, which may live in a secondary window's document.
59
+ * Resolving against the main document here instead would silently replace the host
60
+ * whenever the current hover lives in another document, detaching the dismissal
61
+ * listeners and `unRenderHover` from the host that is actually rendered.
62
+ */
52
63
  protected get hoverHost(): HTMLElement;
64
+ /**
65
+ * Returns the host element to render hovers into for the given document, creating it if the
66
+ * current one belongs to a different document. A host is always created in the document it is
67
+ * shown in: adopting a host into another document would let it outlive its window, and touching
68
+ * it after that window was closed breaks (and in Electron crashes) the application.
69
+ */
70
+ protected getOrCreateHoverHost(targetDocument: Document): HTMLElement;
53
71
  protected pendingTimeout: Disposable | undefined;
54
72
  protected hoverTarget: HTMLElement | undefined;
73
+ /** Identifies the latest render so that superseded renders can detect they are stale. */
74
+ protected renderSequence: number;
55
75
  protected lastHidHover: number;
56
76
  protected readonly disposeOnHide: DisposableCollection;
57
77
  requestHover(request: HoverRequest): void;
78
+ /**
79
+ * Cancels the hover when the window hosting the target element goes away, e.g. when the
80
+ * secondary window containing the target is closed: neither the hover host nor any listeners
81
+ * may outlive the document they belong to.
82
+ */
83
+ protected listenForWindowClose(target: HTMLElement): void;
58
84
  protected getHoverDelay(): number;
59
85
  protected renderHover(request: HoverRequest): Promise<void>;
86
+ /**
87
+ * Waits for an animation frame in the window hosting the given target element,
88
+ * which may be a secondary window whose rendering is independent of the main window's.
89
+ */
90
+ protected hostAnimationFrame(target: HTMLElement): Promise<void>;
60
91
  protected setHostPosition(target: HTMLElement, host: HTMLElement, position: HoverPosition): HoverPosition;
61
92
  protected listenForMouseOut(): void;
62
93
  cancelHover(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"hover-service.d.ts","sourceRoot":"","sources":["../../src/browser/hover-service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAA4B,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAG9E,OAAO,EAAwB,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,2CAA2C,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAMhE,yBAAiB,aAAa,CAAC;IAC3B,SAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAm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