From e9091774826b0bd97e8494babcd19d6a9080d204 Mon Sep 17 00:00:00 2001 From: krassowski Date: Fri, 15 Oct 2021 22:23:27 +0100 Subject: [PATCH 01/12] Try to reduce flakiness of tests --- atest/05_Features/Completion.robot | 1 + atest/05_Features/Signature.robot | 3 ++- atest/Keywords.robot | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index 514b831fd..43119ae5d 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -393,6 +393,7 @@ Completer Should Not Suggest Trigger Completer [Arguments] ${timeout}=35s + Wait For Ready State Press Keys None TAB Wait Until Page Contains Element ${COMPLETER_BOX} timeout=${timeout} diff --git a/atest/05_Features/Signature.robot b/atest/05_Features/Signature.robot index 7ee3cda17..7fafebe28 100644 --- a/atest/05_Features/Signature.robot +++ b/atest/05_Features/Signature.robot @@ -20,7 +20,8 @@ Triggers Signature Help After A Keystroke Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} x # should remain visible after typing an argument Press Keys None x=2, - Element Should Contain ${SIGNATURE_BOX} Important docstring of abc() + Wait For Ready State + Wait Until Keyword Succeeds 10x 0.5s Element Should Contain ${SIGNATURE_BOX} Important docstring of abc() # and should switch highlight to y Wait Until Keyword Succeeds 20x 0.5s Element Should Contain ${SIGNATURE_HIGHLIGHTED_ARG} y Press Keys None LEFT diff --git a/atest/Keywords.robot b/atest/Keywords.robot index e1b207bd7..90601e385 100644 --- a/atest/Keywords.robot +++ b/atest/Keywords.robot @@ -322,9 +322,14 @@ Place Cursor In File Editor At Wait Until Fully Initialized Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=60s +Wait For Ready State + Wait For Condition return document.readyState=="complete" + Open Context Menu Over [Arguments] ${sel} + Wait For Ready State Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel} + Wait For Ready State Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel} Context Menu Should Contain From 85feec60e9cf02e93c456c7a44aa3f03c5ca3aa7 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 13:11:23 +0100 Subject: [PATCH 02/12] Correct setup of "Continuous Hinting Works" test, fix typo --- atest/05_Features/Completion.robot | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index 43119ae5d..b6380cc8a 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -120,16 +120,18 @@ Completes In Strings Or Python Dictionaries Wait Until Keyword Succeeds 40x 0.5s File Editor Line Should Equal 15 test_dict['key_a'] [Teardown] Clean Up After Working With File completion.py -Continious Hinting Works +Continuous Hinting Works + [Setup] Prepare File for Editing Python completion completion.py Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID} - Prepare File for Editing Python completion completion.py Place Cursor In File Editor At 9 2 - Capture Page Screenshot 01-editor-ready.png + Wait For Ready State Press Keys None d + Wait For Ready State Completer Should Suggest addition # gh430 - auto invoke after dot should work too Press Keys None . Completer Should Suggest __doc__ + [Teardown] Clean Up After Working With File completion.py Autocompletes If Only One Option Enter Cell Editor 3 line=1 From 3e124da67a2c51108cec3f22c84e49dfd9154015 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 13:12:30 +0100 Subject: [PATCH 03/12] Fix placeholder removal overwriting documentation from newer request --- .../src/features/completion/completion.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/jupyterlab-lsp/src/features/completion/completion.ts b/packages/jupyterlab-lsp/src/features/completion/completion.ts index ff9382d42..7fec62d42 100644 --- a/packages/jupyterlab-lsp/src/features/completion/completion.ts +++ b/packages/jupyterlab-lsp/src/features/completion/completion.ts @@ -86,6 +86,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { protected current_completion_handler: CompletionHandler; protected current_adapter: WidgetAdapter = null; protected renderer: LSPCompletionRenderer; + private _latestActiveItem: LazyCompletionItem = null; constructor( private app: JupyterFrontEnd, @@ -134,6 +135,9 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { item .resolve() .then(resolvedCompletionItem => { + if (item.self !== this._latestActiveItem.self) { + return; + } this.set_doc_panel_placeholder(false); if (resolvedCompletionItem === null) { return; @@ -141,6 +145,11 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { this.refresh_doc_panel(item); }) .catch(e => { + // disabling placeholder can remove currently displayed documentation, + // so only do that if this is really the active item! + if (item.self !== this._latestActiveItem.self) { + return; + } this.set_doc_panel_placeholder(false); console.warn(e); }); @@ -151,6 +160,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { active_completion: ICompletionData ) { let { item } = active_completion; + this._latestActiveItem = item; if (!item.supportsResolution()) { if (item.isDocumentationMarkdown) { // TODO: remove once https://github.com/jupyterlab/jupyterlab/pull/9663 is merged and released From fdf0f9b32448e4738d71b94a56e9c1e8a6da7cc4 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 14:37:00 +0100 Subject: [PATCH 04/12] Try to fix flake on "Mid Token Completions Do Not Overwrite" --- CHANGELOG.md | 2 ++ atest/05_Features/Completion.robot | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b99537bb4..6cb249fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,14 @@ - fix tab completions not showing up in strings due to incomplete trigger kind invalidation ([#686]) - fix path completions reconciliation for `pyls`/`pylsp` with `IPython` ([#686]) - improve escaping rule for IPython magics overrides ([#688]) + - fix documentation panel not showing up when typing fast ([#692]) [#671]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/671 [#675]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/675 [#686]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/686 [#688]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/688 [#689]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/689 +[#692]: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/692 ### `@krassowski/jupyterlab-lsp 3.8.1` (2021-08-02) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index b6380cc8a..be333f402 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -176,7 +176,9 @@ Mid Token Completions Do Not Overwrite # `display` → `display_table` Place Cursor In Cell Editor At 11 line=1 character=4 Trigger Completer + Wait For Ready State Completer Should Suggest display_table + Wait For Ready State Select Completer Suggestion display_table Wait Until Keyword Succeeds 40x 0.5s Cell Editor Should Equal 11 display_table @@ -378,7 +380,6 @@ Select Completer Suggestion Completer Should Suggest [Arguments] ${text} ${timeout}=10s Wait Until Page Contains Element ${COMPLETER_BOX} .jp-Completer-item[data-value="${text}"] timeout=${timeout} - Capture Page Screenshot ${text.replace(' ', '_')}.png Get Completion Item Vertical Position [Arguments] ${text} From c5b3edc2de785f3168b2371ae7bdde66c797184f Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 18:21:59 +0100 Subject: [PATCH 05/12] Further improve documentation panel reliability --- .../src/features/completion/completion.ts | 13 ++++++++----- .../src/features/completion/renderer.ts | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/jupyterlab-lsp/src/features/completion/completion.ts b/packages/jupyterlab-lsp/src/features/completion/completion.ts index 7fec62d42..dbeff9cfe 100644 --- a/packages/jupyterlab-lsp/src/features/completion/completion.ts +++ b/packages/jupyterlab-lsp/src/features/completion/completion.ts @@ -147,11 +147,10 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { .catch(e => { // disabling placeholder can remove currently displayed documentation, // so only do that if this is really the active item! - if (item.self !== this._latestActiveItem.self) { - return; + if (item.self === this._latestActiveItem.self) { + this.set_doc_panel_placeholder(false); } - this.set_doc_panel_placeholder(false); - console.warn(e); + this.console.warn(e); }); } @@ -174,6 +173,10 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { this.fetchDocumentation(item); } else if (item.isResolved()) { this.refresh_doc_panel(item); + } else { + // resolution has already started, but the re-render update could have been invalidated + // by user action, so let's ensure the documentation will get shown this time. + this.fetchDocumentation(item); } // also fetch completion for the previous and the next item to prevent jitter @@ -328,7 +331,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { private get current_index() { let completer = this.current_completion_handler.completer; - // TODO upstream: add getActiveItem() to Completer + // TODO: use public activeIndex available since 3.1 // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return completer._activeIndex; diff --git a/packages/jupyterlab-lsp/src/features/completion/renderer.ts b/packages/jupyterlab-lsp/src/features/completion/renderer.ts index 12cf15b13..452dab5b6 100644 --- a/packages/jupyterlab-lsp/src/features/completion/renderer.ts +++ b/packages/jupyterlab-lsp/src/features/completion/renderer.ts @@ -142,6 +142,8 @@ export class LSPCompletionRenderer } createDocumentationNode(item: LazyCompletionItem): HTMLElement { + // note: not worth trying to `fetchDocumentation()` as this is not + // invoked if documentation is empty (as of jlab 3.2) if (item.isDocumentationMarkdown) { let documentation = item.documentation; this.options.markdownRenderer From 3dd700b22a336eab351592ac1269cb7f8a800b28 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 18:22:24 +0100 Subject: [PATCH 06/12] Clean up after setting server priority --- atest/01_Editor.robot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atest/01_Editor.robot b/atest/01_Editor.robot index e27ce7650..2042acca4 100644 --- a/atest/01_Editor.robot +++ b/atest/01_Editor.robot @@ -79,6 +79,9 @@ Editor Shows Features for Server Configure JupyterLab Plugin ... {"language_servers": {"${server}": {"priority": 10000}}} Editor Shows Features for Language ${Language} ${file} &{features} + # reset to empty settings + Configure JupyterLab Plugin + ... {} Editor Shows Features for Language [Arguments] ${Language} ${file} &{features} From dde5263b5508d9e8426632aeb4d857ab666529d8 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 21:36:26 +0100 Subject: [PATCH 07/12] Clear theme change --- atest/06_Style.robot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atest/06_Style.robot b/atest/06_Style.robot index a429b590e..0866745b0 100644 --- a/atest/06_Style.robot +++ b/atest/06_Style.robot @@ -35,6 +35,8 @@ Screenshot Editor Themes with Lab Theme FOR ${editor theme} IN @{THEME NAMES} Capture Theme Screenshot ${editor theme} END + # Reset theme + Lab Command Use Theme: JupyterLab Light [Teardown] Clean Up After Working With File ${file} Capture Theme Screenshot From 1005177eb466d551fdd06507833dd147af2e691c Mon Sep 17 00:00:00 2001 From: krassowski Date: Sat, 16 Oct 2021 21:42:12 +0100 Subject: [PATCH 08/12] Try to reduce flake on mouse operations --- atest/05_Features/Completion.robot | 3 ++- atest/Keywords.robot | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index be333f402..77a72c925 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -373,7 +373,8 @@ Activate Completer Suggestion Select Completer Suggestion [Arguments] ${text} ${suggestion} = Set Variable css:.jp-Completer-item[data-value="${text}"] - Wait Until Element Is Visible ${suggestion} timeout=10s + Wait Until Element Is Visible ${suggestion} timeout=15s + Scroll Element Into View ${suggestion} Mouse Over ${suggestion} Click Element ${suggestion} code diff --git a/atest/Keywords.robot b/atest/Keywords.robot index 90601e385..83cecc1ba 100644 --- a/atest/Keywords.robot +++ b/atest/Keywords.robot @@ -245,6 +245,7 @@ Open Folder FOR ${path} IN @{paths} ${sel} = Set Variable css:li.jp-DirListing-item\[title^='Name: ${path}'] Wait Until Page Contains Element ${sel} + Wait Until Element Is Visible ${sel} timeout=5s Double Click Element ${sel} END @@ -395,6 +396,7 @@ Jump To Definition Open Context Menu Over ${sel} ${cursor} = Measure Cursor Position Capture Page Screenshot 02-jump-to-definition-0.png + Wait Until Element Is Visible ${MENU JUMP} timeout=5s Mouse Over ${MENU JUMP} Capture Page Screenshot 02-jump-to-definition-1.png Click Element ${MENU JUMP} From af8599fee6d4de03eaa0e9ec3f354691c013732e Mon Sep 17 00:00:00 2001 From: krassowski Date: Sun, 17 Oct 2021 11:03:55 +0100 Subject: [PATCH 09/12] Actually use different Python versions... --- .github/workflows/job.test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/job.test.yml b/.github/workflows/job.test.yml index 9b7da86b3..76c1d5b4d 100644 --- a/.github/workflows/job.test.yml +++ b/.github/workflows/job.test.yml @@ -259,6 +259,7 @@ jobs: - name: Set up Python and mamba uses: conda-incubator/setup-miniconda@v2 with: + python-version: ${{ matrix.python }} environment-file: requirements/github-actions.yml miniforge-variant: Mambaforge use-mamba: true From 9d1c4a9450cd0c8c4483078a23ea8bae3dc686df Mon Sep 17 00:00:00 2001 From: krassowski Date: Sun, 17 Oct 2021 11:55:57 +0100 Subject: [PATCH 10/12] Actually test focus loss --- atest/05_Features/Completion.robot | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index 77a72c925..11d41be5a 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -48,19 +48,22 @@ Can Prioritize LSP Completions Should Be True ${kernel_position} > ${lsp_position} Invalidates On Cell Change + # this test seems to crash Jedi (highlights crash on + # `usages = document.jedi_script().get_references(**code_position)` Enter Cell Editor 1 line=2 Press Keys None TAB Enter Cell Editor 2 - # just to increase chances of caching this on CI (which is slow) - Sleep 5s + # just to increase chances of catching this on CI (which is slow) + Sleep 4s Completer Should Not Suggest test Invalidates On Focus Loss Enter Cell Editor 1 line=2 Press Keys None TAB - Enter Cell Editor 2 - # just to increase chances of caching this on CI (which is slow) - Sleep 5s + Click JupyterLab Menu Menu + Enter Cell Editor 1 line=2 + # just to increase chances of catching this on CI (which is slow) + Sleep 4s Completer Should Not Suggest test Uses LSP Completions When Kernel Resoponse Times Out From eb6e0a0bc94b9f67ebf98133f5688d5030f72fdd Mon Sep 17 00:00:00 2001 From: krassowski Date: Sun, 17 Oct 2021 11:56:20 +0100 Subject: [PATCH 11/12] Increase timeout for diagnostics --- atest/01_Editor.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atest/01_Editor.robot b/atest/01_Editor.robot index 2042acca4..697c35898 100644 --- a/atest/01_Editor.robot +++ b/atest/01_Editor.robot @@ -100,7 +100,7 @@ Editor Shows Features for Language Editor Should Show Diagnostics [Arguments] ${diagnostic} Set Tags feature:diagnostics - Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=20s + Wait Until Page Contains Element css:.cm-lsp-diagnostic[title*="${diagnostic}"] timeout=25s Capture Page Screenshot 01-diagnostics.png Open Diagnostics Panel Capture Page Screenshot 02-diagnostics.png From 40e043c0244ff391185807fa6641d01437a1f730 Mon Sep 17 00:00:00 2001 From: krassowski Date: Sun, 17 Oct 2021 13:05:45 +0100 Subject: [PATCH 12/12] Fix the focus loss test --- atest/05_Features/Completion.robot | 4 ++-- atest/Keywords.robot | 2 +- atest/Variables.robot | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/atest/05_Features/Completion.robot b/atest/05_Features/Completion.robot index 11d41be5a..6bd4e8521 100644 --- a/atest/05_Features/Completion.robot +++ b/atest/05_Features/Completion.robot @@ -60,11 +60,11 @@ Invalidates On Cell Change Invalidates On Focus Loss Enter Cell Editor 1 line=2 Press Keys None TAB - Click JupyterLab Menu Menu - Enter Cell Editor 1 line=2 + Click JupyterLab Menu File # just to increase chances of catching this on CI (which is slow) Sleep 4s Completer Should Not Suggest test + Enter Cell Editor 1 line=2 Uses LSP Completions When Kernel Resoponse Times Out Configure JupyterLab Plugin {"kernelResponseTimeout": 1, "waitForBusyKernel": true} plugin id=${COMPLETION PLUGIN ID} diff --git a/atest/Keywords.robot b/atest/Keywords.robot index 83cecc1ba..82f41a0e1 100644 --- a/atest/Keywords.robot +++ b/atest/Keywords.robot @@ -184,7 +184,7 @@ Click JupyterLab Menu [Arguments] ${label} [Documentation] Click a top-level JupyterLab menu bar item with by ``label``, ... e.g. File, Help, etc. - ${xpath} = Set Variable ${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}'] + ${xpath} = Set Variable xpath:${JLAB XP TOP}${JLAB XP MENU LABEL}\[text() = '${label}'] Wait Until Page Contains Element ${xpath} Mouse Over ${xpath} Click Element ${xpath} diff --git a/atest/Variables.robot b/atest/Variables.robot index 009369604..7aec5bc14 100644 --- a/atest/Variables.robot +++ b/atest/Variables.robot @@ -19,8 +19,8 @@ ${HEADLESS} 1 ${CMD PALETTE INPUT} css:#command-palette .lm-CommandPalette-input ${CMD PALETTE ITEM ACTIVE} css:#command-palette .lm-CommandPalette-item.lm-mod-active ${JLAB XP TOP} //div[@id='jp-top-panel'] -${JLAB XP MENU ITEM LABEL} //div[@class='lm-Menu-itemLabel'] -${JLAB XP MENU LABEL} //div[@class='lm-MenuBar-itemLabel'] +${JLAB XP MENU ITEM LABEL} //div[contains(@class, 'lm-Menu-itemLabel')] +${JLAB XP MENU LABEL} //div[contains(@class, 'lm-MenuBar-itemLabel')] ${JLAB XP DOCK TAB} xpath://div[contains(@class, 'lm-DockPanel-tabBar')]//li[contains(@class, 'lm-TabBar-tab')] ${JLAB CSS VERSION} css:.jp-About-version ${JLAB CSS REFRESH FILES} css:button[title="Refresh File List"]