Skip to content

Commit f173fbc

Browse files
authored
Merge pull request #284 from bollwyvl/fix-change-of-unopened-files
backport open-before-change from #278
2 parents 13c8000 + 463e295 commit f173fbc

File tree

15 files changed

+217
-36
lines changed

15 files changed

+217
-36
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
- fixes currently-highlighted token in dark editor themes against light lab theme
88
(and vice versa) ([#195][])
99
- restores sorting order-indicating caret icons in diagnostics panel table ([#261][])
10+
- handles document open and change operation ordering more predictably ([#284][])
1011

1112
[#195]: https://github.com/krassowski/jupyterlab-lsp/issues/195
1213
[#261]: https://github.com/krassowski/jupyterlab-lsp/issues/261
14+
[#284]: https://github.com/krassowski/jupyterlab-lsp/pull/284
1315

1416
### `@krassowski/jupyterlab-lsp 1.0.0` (2020-03-14)
1517

atest/02_Settings.robot

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ Resource Keywords.robot
44

55
*** Test Cases ***
66
Settings
7-
[Setup] Reset Application State
87
Open in Advanced Settings ${LSP PLUGIN ID}
98
Capture Page Screenshot 01-settings-lsp.png

atest/04_Interface/DiagnosticsPanel.robot

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Settings ***
22
Suite Setup Setup Suite For Screenshots diagnostics_panel
33
Resource ../Keywords.robot
4+
Test Setup Gently Reset Workspace
45

56
*** Variables ***
67
${EXPECTED_COUNT} 1
@@ -11,15 +12,13 @@ ${MENU COLUMN MESSAGE} xpath://div[contains(@class, 'p-Menu-itemLabel')][cont
1112

1213
*** Test Cases ***
1314
Diagnostics Panel Opens
14-
[Setup] Gently Reset Workspace
1515
Open Notebook And Panel Panel.ipynb
1616
Capture Page Screenshot 03-panel-opens.png
1717
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
1818
[Teardown] Clean Up After Working With File Panel.ipynb
1919

2020
Diagnostics Panel Works After Rename
2121
[Documentation] Test for #141 bug (diagnostics were not cleared after rename)
22-
[Setup] Gently Reset Workspace
2322
Open Notebook And Panel Panel.ipynb
2423
Rename Jupyter File Panel.ipynb PanelRenamed.ipynb
2524
Close Diagnostics Panel
@@ -32,15 +31,13 @@ Diagnostics Panel Works After Rename
3231
[Teardown] Clean Up After Working With File Panel.ipynb
3332

3433
Diagnostics Panel Can Be Restored
35-
[Setup] Gently Reset Workspace
3634
Open Notebook And Panel Panel.ipynb
3735
Close Diagnostics Panel
3836
Open Diagnostics Panel
3937
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
4038
[Teardown] Clean Up After Working With File Panel.ipynb
4139

4240
Columns Can Be Hidden
43-
[Setup] Gently Reset Workspace
4441
Open Notebook And Panel Panel.ipynb
4542
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
4643
Open Context Menu Over css:.lsp-diagnostics-listing th

atest/05_Features/Completion.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*** Settings ***
22
Suite Setup Setup Suite For Screenshots completion
3-
Test Setup Setup Notebook Python Completion.ipynb
3+
Test Setup Setup Completion Test
44
Test Teardown Clean Up After Working With File Completion.ipynb
55
Force Tags feature:completion
66
Resource ../Keywords.robot
@@ -92,6 +92,9 @@ Triggers Completer On Dot
9292
Completer Should Suggest append
9393

9494
*** Keywords ***
95+
Setup Completion Test
96+
Setup Notebook Python Completion.ipynb
97+
9598
Get Cell Editor Content
9699
[Arguments] ${cell_nr}
97100
${content} Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getValue()

atest/Keywords.robot

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Setup Server and Browser
2222
Initialize User Settings
2323
${cmd} = Create Lab Launch Command ${root}
2424
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots
25-
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${OUTPUT DIR}${/}lab.log
25+
Set Global Variable ${LAB LOG} ${OUTPUT DIR}${/}lab.log
26+
Set Global Variable ${PREVIOUS LAB LOG LENGTH} 0
27+
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${LAB LOG}
2628
... stderr=STDOUT
2729
Set Global Variable ${SERVER} ${server}
2830
Open JupyterLab
@@ -65,6 +67,14 @@ Tear Down Everything
6567
Terminate All Processes
6668
Terminate All Processes kill=${True}
6769

70+
Lab Log Should Not Contain Known Error Messages
71+
${log} = Get File ${LAB LOG}
72+
${test log} = Set Variable ${log[${PREVIOUS LAB LOG LENGTH}:]}
73+
${length} = Get Length ${log}
74+
Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
75+
Run Keyword If ("${OS}", "${PY}") !\= ("Windows", "36")
76+
... Should Not Contain Any ${test log} @{KNOWN BAD ERRORS}
77+
6878
Wait For Splash
6979
Go To ${URL}lab?reset&token=${TOKEN}
7080
Set Window Size 1024 768
@@ -201,6 +211,7 @@ Clean Up After Working With File
201211
[Arguments] ${file}
202212
Remove File ${OUTPUT DIR}${/}home${/}${file}
203213
Reset Application State
214+
Lab Log Should Not Contain Known Error Messages
204215

205216
Setup Notebook
206217
[Arguments] ${Language} ${file} ${isolated}=${True}

atest/Variables.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ ${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterla
3737
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
3838
# diagnostics
3939
${CSS DIAGNOSTIC} css:.cm-lsp-diagnostic
40+
# log messages
41+
@{KNOWN BAD ERRORS}
42+
... pyls_jsonrpc.endpoint - Failed to handle notification
43+
... pyls_jsonrpc.endpoint - Failed to handle request

atest/__init__.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
Suite Setup Setup Server and Browser
33
Suite Teardown Tear Down Everything
44
Test Setup Reset Application State
5+
Test Teardown Lab Log Should Not Contain Known Error Messages
56
Force Tags os:${OS.lower()} py:${PY}
67
Resource Keywords.robot

ci/env-test.yml.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ dependencies:
1515
- python-language-server
1616
- ujson <=1.35
1717
# for R language server and kernel
18-
- r
18+
# TODO: try r 4.0 soon
19+
- r <4
1920
- r-irkernel
2021
- r-languageserver
22+
- r-stringi >=1.4.6
2123
- rpy2
2224
# test tools
2325
- pytest-asyncio

ci/job.test.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ parameters:
22
platforms:
33
- name: Linux
44
vmImage: ubuntu-16.04
5-
activate: source activate
5+
activate: source activate base
66
- name: MacOSX
77
vmImage: macos-10.14
8-
activate: source activate
8+
activate: source activate base
99
- name: Windows
1010
vmImage: vs2017-win2016
11-
activate: call activate
11+
activate: call activate base
1212
pythons:
1313
- name: ThreeSix
14-
spec: '>=3.6,<3.7.0a0'
14+
spec: '=3.6'
1515
lab: '>=2,<3.0.0a0'
1616
nodejs: '>=10,<11.0.0.a0'
1717
- name: ThreeSeven
18-
spec: '>=3.7,<3.8.0a0'
18+
spec: '=3.7'
1919
lab: '>=2,<3.0.0a0'
2020
nodejs: '>=12,<13.0.0a0'
2121
- name: ThreeEight
22-
spec: '>=3.8,<3.9.0a0'
22+
spec: '=3.8'
2323
lab: '>=2,<3.0.0a0'
2424
nodejs: '>=13,<14.0.0a0'
2525
js_cov_packages:
2626
- jupyterlab-go-to-definition
2727
- jupyterlab-lsp
28-
env_update: conda env update -n jupyterlab-lsp --file env-test.yml --quiet
28+
env_update: conda env update -n base --file env-test.yml --quiet
2929
lab_link: jupyter labextension link --debug --no-build $(LINKED_EXTENSIONS)
3030
lab_ext: jupyter labextension install --debug --no-build $(FIRST_PARTY_LABEXTENSIONS)
3131
lab_build: jupyter lab build --debug --dev-build=False --minimize=True
@@ -40,32 +40,36 @@ jobs:
4040
- template: steps.conda.yml
4141
parameters:
4242
name: ${{ platform.name }}
43+
packages: "'python${{ python.spec }}'"
4344

4445
- script: ${{ platform.activate }} && cd ci && python env_template.py "${{ python.spec }}" "${{ python.lab }}" "${{ python.nodejs }}"
4546
displayName: generate env with python, lab, and nodejs version
4647

4748
- script: ${{ parameters.env_update }} || ${{ parameters.env_update }} || ${{ parameters.env_update }}
4849
displayName: update conda environment with test dependencies
4950

50-
- script: conda info && conda list -n jupyterlab-lsp
51+
- script: conda info && conda list -n base
5152
displayName: list conda packages and info
5253

53-
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm || jlpm || jlpm
54+
- script: ${{ platform.activate }} && jlpm || jlpm || jlpm
5455
displayName: install npm dependencies
5556

56-
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm build
57+
- script: ${{ platform.activate }} && jlpm build
5758
displayName: build typescript
5859

59-
- script: ${{ platform.activate }} jupyterlab-lsp && python setup.py sdist bdist_wheel
60+
- script: ${{ platform.activate }} && python setup.py sdist bdist_wheel
6061
displayName: build python distributions
6162

62-
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm lerna run bundle
63+
- script: ${{ platform.activate }} && jlpm lerna run bundle
6364
displayName: build npm bundles
6465

65-
- script: ${{ platform.activate }} jupyterlab-lsp && cd dist && python -m pip install jupyter_lsp-$(PY_JLSP_VERSION)-py3-none-any.whl --no-deps
66+
- script: ${{ platform.activate }} && cd dist && python -m pip install jupyter_lsp-$(PY_JLSP_VERSION)-py3-none-any.whl --no-deps
6667
displayName: install python wheel
6768

68-
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm test
69+
- script: ${{ platform.activate }} && python scripts/jedi_cache.py
70+
displayName: warm up jedi cache
71+
72+
- script: ${{ platform.activate }} && jlpm test
6973
displayName: run frontend unit tests
7074

7175
- task: PublishTestResults@2
@@ -84,28 +88,28 @@ jobs:
8488
summaryFileLocation: 'packages/${{ js_package }}/coverage/cobertura-coverage.xml'
8589
condition: always()
8690

87-
- script: ${{ platform.activate }} jupyterlab-lsp && jupyter serverextension list
91+
- script: ${{ platform.activate }} && jupyter serverextension list
8892
displayName: list server extensions
8993

90-
- script: ${{ platform.activate }} jupyterlab-lsp && python scripts/utest.py --test-run-title="Pytest ${{ platform.name }}${{ python.name }}"
94+
- script: ${{ platform.activate }} && python scripts/utest.py --test-run-title="Pytest ${{ platform.name }}${{ python.name }}"
9195
displayName: run python tests
9296

93-
- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_link }} || ${{ parameters.lab_link }} || ${{ parameters.lab_link }}
97+
- script: ${{ platform.activate }} && ${{ parameters.lab_link }} || ${{ parameters.lab_link }} || ${{ parameters.lab_link }}
9498
displayName: install support packages
9599

96-
- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }}
100+
- script: ${{ platform.activate }} && ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }}
97101
displayName: install labextensions
98102

99-
- script: ${{ platform.activate }} jupyterlab-lsp && jupyter labextension list
103+
- script: ${{ platform.activate }} && jupyter labextension list
100104
displayName: list labextensions before build
101105

102-
- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_build }} || ${{ parameters.lab_build }} || ${{ parameters.lab_build }}
106+
- script: ${{ platform.activate }} && ${{ parameters.lab_build }} || ${{ parameters.lab_build }} || ${{ parameters.lab_build }}
103107
displayName: build lab
104108

105-
- script: ${{ platform.activate }} jupyterlab-lsp && jupyter labextension list
109+
- script: ${{ platform.activate }} && jupyter labextension list
106110
displayName: list labextensions after build
107111

108-
- script: ${{ platform.activate }} jupyterlab-lsp && python scripts/atest.py
112+
- script: ${{ platform.activate }} && python scripts/atest.py
109113
displayName: run browser tests
110114

111115
- task: PublishTestResults@2

packages/jupyterlab-lsp/src/connection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ export class LSPConnection extends LspWsConnection {
119119
changeEvents: lsProtocol.TextDocumentContentChangeEvent[],
120120
documentInfo: IDocumentInfo
121121
) {
122-
if (!this.isConnected || !this.isInitialized) {
122+
if (!this.isReady) {
123123
return;
124124
}
125+
if (!this.openedUris.get(documentInfo.uri)) {
126+
this.sendOpen(documentInfo);
127+
}
125128
const textDocumentChange: lsProtocol.DidChangeTextDocumentParams = {
126129
textDocument: {
127130
uri: documentInfo.uri,

0 commit comments

Comments
 (0)