Skip to content

Commit e35581b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bump-deps
2 parents ea538c0 + cad9207 commit e35581b

File tree

10 files changed

+86
-18
lines changed

10 files changed

+86
-18
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://jupyterlab.readthedocs.io/en/latest/getting_started/issue.html
1212

1313
## Description
1414

15-
<!--Describe the bug clearly and concisely. Include screenshots if possible-->
15+
<!--Describe the bug clearly and concisely. Include screenshots (or even better - gifs) if possible-->
1616

1717
## Reproduce
1818

@@ -52,7 +52,7 @@ You may want to sanitize the paths in the output.
5252
</pre>
5353
</details>
5454

55-
<!--The more contet you provide, the more we can help!-->
55+
<!--The more content you provide, the more we can help!-->
5656

5757
<details><summary>Troubleshoot Output</summary>
5858
<pre>
@@ -67,8 +67,14 @@ Paste the output from your command line running `jupyter lab` here, use `--debug
6767
</pre>
6868
</details>
6969

70-
<details><summary>Browser Output</summary>
70+
<details><summary>Browser Output (recommended for all interface issues)</summary>
7171
<pre>
72-
Paste the output from your browser Javascript console here.
72+
Paste the output from your browser JavaScript console replacing the text in here.
73+
74+
To learn how to open the developer tools in your browser:
75+
https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools#How_to_open_the_devtools_in_your_browser
76+
If too many messagess accumulated after many hours of working in JupyterLab,
77+
consider refreshing the window and then reproducing the bug to reduce the noise in the logs.
78+
7379
</pre>
7480
</details>

.github/workflows/job.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defaults:
1414
env:
1515
# TODO extract these from files instead
1616
PY_JLSP_VERSION: 0.9.2
17-
JS_JLLSP_VERSION: 2.0.7
17+
JS_JLLSP_VERSION: 2.0.8
1818
JS_JLG2D_VERSION: 1.0.0
1919

2020
PYTHONUNBUFFERED: 1

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
## CHANGELOG
22

3+
### `@krassowski/jupyterlab-lsp 2.0.8` (2020-10-25)
4+
5+
- bug fixes
6+
7+
- custom cell syntax highlighting is now properly removed when no longer needed ([#387])
8+
- the completer in continuous hinting now works well with the pasted text ([#389])
9+
- continuous hinting suggestions will no longer show up if the only hint is the same as the current token ([#391])
10+
- available options for hover modifier keys are now listed in the setting descriptions ([#377])
11+
12+
[#377]: https://github.com/krassowski/jupyterlab-lsp/issues/377
13+
[#387]: https://github.com/krassowski/jupyterlab-lsp/issues/387
14+
[#389]: https://github.com/krassowski/jupyterlab-lsp/issues/389
15+
[#391]: https://github.com/krassowski/jupyterlab-lsp/issues/391
16+
317
### `@krassowski/jupyterlab-lsp 2.0.7` (2020-09-18)
418

519
- bug fixes

atest/05_Features/Completion.robot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ Works In File Editor
4747
Completer Should Suggest add
4848
[Teardown] Clean Up After Working With File completion.py
4949

50+
Continious Hinting Works
51+
Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID}
52+
Prepare File for Editing Python completion completion.py
53+
Place Cursor In File Editor At 9 2
54+
Capture Page Screenshot 01-editor-ready.png
55+
Press Keys None d
56+
Completer Should Suggest addition
57+
5058
Autocompletes If Only One Option
5159
Enter Cell Editor 3 line=1
5260
Press Keys None cle
@@ -149,8 +157,8 @@ VSCode Dark Theme Works
149157
Configure JupyterLab Plugin {"theme": "vscode"} plugin id=${COMPLETION PLUGIN ID}
150158
Capture Page Screenshot 01-configured.png
151159
Open ${file} in ${MENU NOTEBOOK}
152-
Enter Cell Editor 1 line=2
153160
Wait Until Fully Initialized
161+
Enter Cell Editor 1 line=2
154162
Trigger Completer
155163
Capture Page Screenshot 02-completions-shown.png
156164
Completer Should Suggest TabError

atest/05_Features/Syntax_highlighting.robot

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,29 @@ Highlighing Mode Works For Multiple Documents
2424
${mode} = Get Mode Of A Cell 6
2525
should be equal ${mode['name']} javascript
2626

27+
Highlighting Mode Changes Back And Forth After Edits
28+
${mode} = Get Mode Of A Cell 2
29+
should be equal ${mode['name']} markdown
30+
Enter Cell Editor 2 line=1
31+
Press Keys None BACKSPACE
32+
Capture Page Screenshot backapse.png
33+
wait until keyword succeeds 5x 2s Mode Of A Cell Should Equal 2 ipython
34+
Enter Cell Editor 2 line=1
35+
Press Keys None n
36+
wait until keyword succeeds 5x 2s Mode Of A Cell Should Equal 2 markdown
37+
2738
*** Keywords ***
2839
Get Mode Of A Cell
29-
[Arguments] ${cell_nr}
30-
Click Element css:.jp-Cell:nth-child(${cell_nr})
31-
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_nr}) .CodeMirror-focused
32-
${mode} = Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getMode()
40+
[Arguments] ${cell_number}
41+
Click Element css:.jp-Cell:nth-child(${cell_number})
42+
Wait Until Page Contains Element css:.jp-Cell:nth-child(${cell_number}) .CodeMirror-focused
43+
${mode} = Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_number}) .CodeMirror').CodeMirror.getMode()
3344
[Return] ${mode}
3445

3546
Setup Highlighting Test
3647
Setup Notebook Python Syntax highlighting.ipynb
48+
49+
Mode Of A Cell Should Equal
50+
[Arguments] ${cell_number} ${expected_mode}
51+
${mode} = Get Mode Of A Cell ${cell_number}
52+
should be equal ${mode['name']} ${expected_mode}

packages/jupyterlab-lsp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@krassowski/jupyterlab-lsp",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "Language Server Protocol integration for JupyterLab",
55
"keywords": [
66
"jupyter",

packages/jupyterlab-lsp/src/editor_integration/codemirror.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ export abstract class CodeMirrorIntegration
230230

231231
protected extract_last_character(change: CodeMirror.EditorChange): string {
232232
if (change.origin === 'paste') {
233-
return change.text[0][change.text.length - 1];
233+
let last_line = change.text[change.text.length - 1];
234+
return last_line[last_line.length - 1];
234235
} else {
235236
return change.text[0][0];
236237
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class LSPConnector
205205
}
206206

207207
return promise.then(reply => {
208-
reply = this.suppress_if_needed(reply);
208+
reply = this.suppress_if_needed(reply, token);
209209
this.trigger_kind = CompletionTriggerKind.Invoked;
210210
return reply;
211211
});
@@ -413,9 +413,17 @@ export class LSPConnector
413413
return Promise.resolve(undefined);
414414
}
415415

416-
private suppress_if_needed(reply: CompletionHandler.ICompletionItemsReply) {
416+
private suppress_if_needed(
417+
reply: CompletionHandler.ICompletionItemsReply,
418+
token: CodeEditor.IToken
419+
) {
417420
if (this.trigger_kind == AdditionalCompletionTriggerKinds.AutoInvoked) {
418-
if (reply.start == reply.end) {
421+
if (
422+
// do not auto-invoke if no match found
423+
reply.start == reply.end ||
424+
// do not auto-invoke if only one match found and this match is exactly the same as the current token
425+
(reply.items.length === 1 && reply.items[0].insertText === token.value)
426+
) {
419427
return {
420428
start: reply.start,
421429
end: reply.end,

packages/jupyterlab-lsp/src/features/syntax_highlighting.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ const FEATURE_ID = PLUGIN_ID + ':syntax_highlighting';
2929
export class CMSyntaxHighlighting extends CodeMirrorIntegration {
3030
lab_integration: SyntaxLabIntegration;
3131
settings: IFeatureSettings<LSPSyntaxHighlightingSettings>;
32+
editors_with_active_highlight: Set<CodeMirrorEditor>;
3233

3334
constructor(options: IEditorIntegrationOptions) {
3435
super(options);
3536
this.virtual_document.changed.connect(this.update_mode.bind(this), this);
37+
this.editors_with_active_highlight = new Set();
3638
}
3739

3840
private get_mode(language: string) {
@@ -52,10 +54,12 @@ export class CMSyntaxHighlighting extends CodeMirrorIntegration {
5254

5355
update_mode() {
5456
let root = this.virtual_document;
57+
let editors_with_current_highlight = new Set<CodeMirrorEditor>();
58+
5559
for (let map of root.foreign_document_maps) {
5660
for (let [range, block] of map.entries()) {
57-
let ce_editor = block.editor;
58-
let editor = (ce_editor as CodeMirrorEditor).editor;
61+
let ce_editor = block.editor as CodeMirrorEditor;
62+
let editor = ce_editor.editor;
5963
let lines = editor.getValue('\n');
6064
let total_area = lines.concat('').length;
6165

@@ -75,13 +79,24 @@ export class CMSyntaxHighlighting extends CodeMirrorIntegration {
7579

7680
// change the mode if the majority of the code is the foreign code
7781
if (coverage > this.settings.composite.foreignCodeThreshold) {
82+
editors_with_current_highlight.add(ce_editor);
7883
let old_mode = editor.getOption('mode');
7984
if (old_mode != mode.mime) {
8085
editor.setOption('mode', mode.mime);
8186
}
8287
}
8388
}
8489
}
90+
91+
if (editors_with_current_highlight != this.editors_with_active_highlight) {
92+
for (let ce_editor of this.editors_with_active_highlight) {
93+
if (!editors_with_current_highlight.has(ce_editor)) {
94+
ce_editor.editor.setOption('mode', ce_editor.model.mimeType);
95+
}
96+
}
97+
}
98+
99+
this.editors_with_active_highlight = editors_with_current_highlight;
85100
}
86101
}
87102

packages/metapackage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@krassowski/jupyterlab-lsp-metapackage",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "JupyterLab LSP - Meta Package. All of the packages used by JupyterLab LSP",
55
"homepage": "https://github.com/krassowski/jupyterlab-lsp",
66
"bugs": {

0 commit comments

Comments
 (0)