Skip to content

Commit 8ae1b9e

Browse files
committed
fix completion regression
1 parent 3fa15ee commit 8ae1b9e

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

atest/05_Features/Completion.robot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ Select Completer Suggestion
110110

111111
Completer Should Suggest
112112
[Arguments] ${text}
113-
Page Should Contain Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
113+
Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
114+
Capture Page Screenshot ${text.replace(' ', '_')}.png
114115

115116
Completer Should Not Suggest
116117
[Arguments] ${text}
117-
Page Should Not Contain Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
118+
Wait Until Page Does Not Contain Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"]
118119

119120
Trigger Completer
120121
Press Keys None TAB

packages/jupyterlab-lsp/src/adapters/jupyterlab/components/completion.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export class LSPConnector extends DataConnector<
112112
): Promise<CompletionHandler.IReply> {
113113
let editor = this._editor;
114114

115+
console.error('NRB: editor', (editor as any)._editor.display.lineDiv);
116+
115117
const cursor = editor.getCursorPosition();
116118
const token = editor.getTokenForPosition(cursor);
117119

packages/jupyterlab-lsp/src/adapters/jupyterlab/notebook.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ export class NotebookAdapter extends JupyterLabWidgetAdapter {
8989
this
9090
);
9191
this.widget.content.activeCellChanged.disconnect(this.on_completions, this);
92-
for (const handler of this.completion_handlers.values()) {
93-
handler.connector = null;
94-
handler.editor = null;
92+
if (this.current_completion_handler) {
93+
this.current_completion_handler.connector = null;
94+
this.current_completion_handler.editor = null;
95+
this.current_completion_handler = null;
9596
}
96-
this.completion_handlers.clear();
9797
super.dispose();
9898
}
9999

@@ -175,10 +175,7 @@ export class NotebookAdapter extends JupyterLabWidgetAdapter {
175175
});
176176
}
177177

178-
completion_handlers = new Map<
179-
Cell,
180-
ICompletionManager.ICompletableAttributes
181-
>();
178+
current_completion_handler: ICompletionManager.ICompletableAttributes;
182179

183180
connect_completion() {
184181
// see https://github.com/jupyterlab/jupyterlab/blob/c0e9eb94668832d1208ad3b00a9791ef181eca4c/packages/completer-extension/src/index.ts#L198-L213
@@ -192,19 +189,20 @@ export class NotebookAdapter extends JupyterLabWidgetAdapter {
192189
editor: cell.editor,
193190
parent: this.widget
194191
});
195-
this.completion_handlers.set(cell, handler);
192+
this.current_completion_handler = handler;
193+
this.widget.content.activeCellChanged.connect(this.on_completions, this);
196194
}
197195

198196
on_completions(notebook: Notebook, cell: Cell) {
199197
if (cell == null) {
200198
return;
201199
}
200+
console.error(
201+
'NRB: on_completions',
202+
(cell.editor as any)._editor.display.lineDiv
203+
);
202204
this.set_completion_connector(cell);
203-
const handler = this.completion_handlers.get(cell);
204-
if (handler == null) {
205-
return;
206-
}
207-
handler.editor = cell.editor;
208-
handler.connector = this.current_completion_connector;
205+
this.current_completion_handler.editor = cell.editor;
206+
this.current_completion_handler.connector = this.current_completion_connector;
209207
}
210208
}

0 commit comments

Comments
 (0)