Skip to content

Commit 0a0d5c9

Browse files
authored
Merge pull request #478 from krassowski/fix-kernel-change-and-restart
Fix handling of kernel change and restart
2 parents f111e6b + 02f5130 commit 0a0d5c9

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
- bug fixes:
1010

11-
- fix completions with R double and triple colon prefix ([#449])
12-
- fix contrast on status icon when status item is active ([#465])
13-
- fix connection manager loosing track of notebooks when multiple were open ([#474])
11+
- namespace completions in R (after double and triple colon) now work properly ([#449])
12+
- improved status icon contrast when status item is active ([#465])
13+
- connection manager now properly keeps track of notebooks when multiple notebooks are open ([#474])
14+
- new cells added after kernel restart now work properly; kernel changes are handled correctly ([#478])
1415

1516
[#449]: https://github.com/krassowski/jupyterlab-lsp/pull/449
1617
[#465]: https://github.com/krassowski/jupyterlab-lsp/pull/465
1718
[#474]: https://github.com/krassowski/jupyterlab-lsp/pull/474
19+
[#478]: https://github.com/krassowski/jupyterlab-lsp/pull/478
1820

1921
### `jupyter-lsp 1.0.1` (unreleased)
2022

atest/05_Features/Completion.robot

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Works With Kernel Running
2828

2929
Works When Kernel Is Shut Down
3030
Lab Command Shut Down All Kernels…
31+
Wait For Dialog
3132
Capture Page Screenshot 01-shutting-kernels.png
3233
Accept Default Dialog Option
3334
Capture Page Screenshot 02-kernels-shut.png
@@ -39,6 +40,21 @@ Works When Kernel Is Shut Down
3940
# this comes from kernel:
4041
Completer Should Not Suggest %%timeit
4142

43+
Works After Kernel Restart In New Cells
44+
Lab Command Restart Kernel…
45+
Wait For Dialog
46+
Accept Default Dialog Option
47+
Enter Cell Editor 1 line=2
48+
# works in old cells
49+
Trigger Completer
50+
Completer Should Suggest test
51+
Lab Command Insert Cell Below
52+
Enter Cell Editor 2 line=1
53+
# works in new cells
54+
Press Keys None lis
55+
Trigger Completer
56+
Completer Should Suggest list
57+
4258
Works In File Editor
4359
[Setup] Prepare File for Editing Python completion completion.py
4460
Place Cursor In File Editor At 9 2

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,17 @@ export abstract class WidgetAdapter<T extends IDocumentWidget> {
236236
);
237237

238238
// recreate virtual document using current path and language
239-
let virtual_document = this.create_virtual_document();
240-
this.virtual_editor.virtual_document = virtual_document;
239+
// as virtual editor assumes it gets the virtual document at init,
240+
// just dispose virtual editor (which disposes virtual document too)
241+
// and re-initialize both virtual editor and document
242+
this.virtual_editor.dispose();
243+
244+
this.init_virtual();
245+
241246
// reconnect
242-
this.connect_document(virtual_document, true).catch(console.warn);
247+
this.connect_document(this.virtual_editor.virtual_document, true).catch(
248+
console.warn
249+
);
243250
}
244251

245252
protected on_save_state(context: any, state: DocumentRegistry.SaveState) {

0 commit comments

Comments
 (0)