Skip to content

Commit cfac3fc

Browse files
committed
Restore pre-fetching resolve(), remove unused activityObserver
1 parent aacc798 commit cfac3fc

File tree

1 file changed

+1
-38
lines changed
  • packages/jupyterlab-lsp/src/features/completion

1 file changed

+1
-38
lines changed

packages/jupyterlab-lsp/src/features/completion/renderer.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,20 @@ export class LSPCompletionRenderer
2121
implements Completer.IRenderer
2222
{
2323
// signals
24-
public activeChanged: Signal<LSPCompletionRenderer, ICompletionData>;
2524
public itemShown: Signal<LSPCompletionRenderer, ICompletionData>;
2625
// observers
2726
private visibilityObserver: IntersectionObserver;
28-
private activityObserver: MutationObserver;
2927
// element data maps (with weak references for better GC)
3028
private elementToItem: WeakMap<HTMLLIElement, CompletionItem>;
31-
private wasActivated: WeakMap<HTMLLIElement, boolean>;
3229

3330
protected ITEM_PLACEHOLDER_CLASS = 'lsp-detail-placeholder';
3431
protected EXTRA_INFO_CLASS = 'jp-Completer-typeExtended';
3532
protected LABEL_CLASS = 'jp-Completer-match';
3633

3734
constructor(protected options: LSPCompletionRenderer.IOptions) {
3835
super();
39-
this.activeChanged = new Signal(this);
4036
this.itemShown = new Signal(this);
4137
this.elementToItem = new WeakMap();
42-
this.wasActivated = new WeakMap();
4338

4439
this.visibilityObserver = new IntersectionObserver(
4540
entries => {
@@ -49,41 +44,13 @@ export class LSPCompletionRenderer
4944
}
5045
let li = entry.target as HTMLLIElement;
5146
let item = this.elementToItem.get(li)!;
52-
this.itemShown.emit({
53-
item: item,
54-
element: li
55-
});
47+
item.resolve().catch(console.error);
5648
});
5749
},
5850
{
5951
threshold: 0.25
6052
}
6153
);
62-
63-
// note: there should be no need to unobserve deleted elements as per:
64-
// https://stackoverflow.com/a/51106262/6646912
65-
this.activityObserver = new MutationObserver(mutations => {
66-
mutations.forEach(mutation => {
67-
let li = mutation.target;
68-
if (!(li instanceof HTMLLIElement)) {
69-
return;
70-
}
71-
let inactive = !this.wasActivated.get(li);
72-
73-
if (li.classList.contains('jp-mod-active')) {
74-
if (inactive) {
75-
this.wasActivated.set(li, true);
76-
let item = this.elementToItem.get(li)!;
77-
this.activeChanged.emit({
78-
item: item,
79-
element: li
80-
});
81-
}
82-
} else {
83-
this.wasActivated.set(li, false);
84-
}
85-
});
86-
});
8754
}
8855

8956
protected getExtraInfo(item: CompletionItem): string {
@@ -132,10 +99,6 @@ export class LSPCompletionRenderer
13299
if (lspItem) {
133100
lspItem.element = li;
134101
this.elementToItem.set(li, lspItem);
135-
this.activityObserver.observe(li, {
136-
attributes: true,
137-
attributeFilter: ['class']
138-
});
139102
this.visibilityObserver.observe(li);
140103
// TODO: build custom li from ground up
141104
this.updateExtraInfo(lspItem, li);

0 commit comments

Comments
 (0)