Skip to content

Commit 6f16bfa

Browse files
authored
Merge pull request #423 from krassowski/refactor-jump-to-definition
Refactor jump-to functionality, remove unused code
2 parents 2a7291a + f02c1ee commit 6f16bfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+609
-3222
lines changed

.github/workflows/job.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222

2323
LINKED_EXTENSIONS: >-
2424
packages/lsp-ws-connection
25-
packages/jupyterlab-go-to-definition
25+
packages/code-jumpers
2626
packages/completion-theme
2727
packages/theme-vscode
2828
packages/theme-material
@@ -148,7 +148,7 @@ jobs:
148148
run: jlpm test
149149

150150
# js_cov_packages:
151-
# - jupyterlab-go-to-definition
151+
# - code-jumpers
152152
# - jupyterlab-lsp
153153

154154
#- task: PublishTestResults@2

CHANGELOG.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55
- features
66

7-
- The virtual document folder can be configure with `JP_LSP_VIRTUAL_DIR` or
8-
`LanguageServerManager.virtual_documents_dir`. Its default value is kept
7+
- the virtual documents' folder can be configured with `JP_LSP_VIRTUAL_DIR` or
8+
`LanguageServerManager.virtual_documents_dir`; its default value is kept
99
unchanged: _contents.root_dir_ / `.virtual_documents` ([#416])
1010

1111
[#416]: https://github.com/krassowski/jupyterlab-lsp/issues/416
1212

13-
### `@krassowski/jupyterlab-lsp 2.0.9` (???)
13+
### `@krassowski/jupyterlab-lsp 2.1.0` (???)
14+
15+
- features
16+
17+
- added "click to jump" functionality (by default using <kbd>Ctrl</kbd> modifier) ([#423])
18+
- added "jump back" command, by default activated with <kbd>Ctrl</kbd> + <kbd>o</kbd> ([#423])
1419

1520
- bug fixes
1621

@@ -23,14 +28,17 @@
2328
[#403]: https://github.com/krassowski/jupyterlab-lsp/issues/403
2429
[#421]: https://github.com/krassowski/jupyterlab-lsp/issues/421
2530

26-
### `@krassowski/jupyterlab_go_to_definition 2.0.0` (???)
31+
### `@krassowski/code-jumpers 1.0.0` (???)
2732

28-
- features
29-
30-
- breaking change: renames `uri` to `contents_path` to help avoid programmer issues
33+
- breaking changes
34+
- split away from `@krassowski/jupyterlab_go_to_definition`, renamed to `@krassowski/code-jumpers` ([#423]):
35+
- removed unused code
36+
- refactored history operations to track files and always use global location data
37+
- renamed `uri` to `contents_path` to help avoid programmer issues
3138
with characters requiring URI encoding ([#406])
3239

3340
[#406]: https://github.com/krassowski/jupyterlab-lsp/pull/406
41+
[#423]: https://github.com/krassowski/jupyterlab-lsp/pull/423
3442

3543
### `@krassowski/jupyterlab-lsp 2.0.8` (2020-10-25)
3644

@@ -123,15 +131,15 @@
123131
- rename operation status reporting got improved ([#318])
124132
- replaced the generic status icons with code check icon (coloured differently according to the status) ([#318])
125133
- added icons for all the features and their commands ([#318])
126-
- refactored the codebase with a new architecture which allows dynamic feature, document widget adapter, and code editor registration ([#318])
134+
- refactored the codebase with a new architecture which allows dynamic features, document widget adapter, and code editor registration ([#318])
127135
- the document in the connections list in the statusbar popover are now represented by easy-to-understand DocumentLocator (breadcrumbs) widget rather than an internal id ([bacc006])
128136
- syntax highlighting mode is adjusted to the language with the majority of the code in an editor ([#319])
129137
- copy diagnostics message and filter diagnostics from context menu of Diagnostic Panel ([#330])
130138

131139
- bug fixes
132140

133-
- path-autocompletion issues were resolved upstream an this release adopts these changes
134-
- missing caret and document connection icons were restored in the statusbar popover ([#318])
141+
- path-autocompletion issues were resolved upstream and this release adopts these changes
142+
- the missing caret and document connection icons were restored in the statusbar popover ([#318])
135143
- pressing "Cancel" rename during rename now correctly aborts the rename operation ([#318])
136144
- when a language server for a foreign document is not available an explanation is displayed (rather than the "Connecting..." status as before) ([4e5b2ad])
137145
- when jump target is not found a message is now shown instead of raising an exception ([00448d0])

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ over the underlined code to see a more detailed message
2727

2828
### Jump to Definition
2929

30-
Use the context menu entries to jump to definitions
30+
Use the context menu entry, or <kbd>Alt</kbd> + :computer_mouse: to jump to definitions (you can change it to <kbd>Ctrl</kbd>/<kbd>⌘</kbd> in settings); use <kbd>Alt</kbd> + <kbd>o</kbd> to jump back
3131

3232
![jump](https://raw.githubusercontent.com/krassowski/jupyterlab-lsp/master/examples/screenshots/jump_to_definition.png)
3333

atest/05_Features/Jump.robot

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ Python Jumps between Files
1717
Wait Until Page Contains ANOTHER_CONSTANT
1818
Capture Page Screenshot 10-jumped.png
1919

20+
Ctrl Click And Jumping Back Works
21+
[Setup] Prepare File for Editing Python editor jump.py
22+
Configure JupyterLab Plugin {"modifierKey": "Accel"} plugin id=${JUMP PLUGIN ID}
23+
Wait Until Fully Initialized
24+
${usage} = Set Variable a_variable
25+
${sel} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), '${usage}')])[last()]
26+
Click Element ${sel}
27+
${original} = Measure Cursor Position
28+
Capture Page Screenshot 01-ready-to-jump.png
29+
${key} = Evaluate 'COMMAND' if platform.system() == 'Darwin' else 'CTRL' platform
30+
Click Element ${sel} modifier=${key}
31+
Capture Page Screenshot 02-jumped.png
32+
Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${original}
33+
${new} = Measure Cursor Position
34+
Press Keys None ALT+o
35+
Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${new}
36+
${back} = Measure Cursor Position
37+
Should Be Equal ${original} ${back}
38+
Configure JupyterLab Plugin {"modifierKey": "Alt"} plugin id=${JUMP PLUGIN ID}
39+
Click Element ${sel} modifier=ALT
40+
Wait Until Keyword Succeeds 10 x 1 s Cursor Should Jump ${original}
41+
[Teardown] Clean Up After Working With File jump.py
42+
2043
*** Keywords ***
2144
Copy Files to Folder With Spaces
2245
[Arguments] @{files}

atest/Variables.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ${CM CURSORS} css:.jp-MainAreaWidget:not(.lm-mod-hidden) .CodeMirror-cursors
4545
# settings
4646
${LSP PLUGIN ID} @krassowski/jupyterlab-lsp:plugin
4747
${COMPLETION PLUGIN ID} @krassowski/jupyterlab-lsp:completion
48+
${JUMP PLUGIN ID} @krassowski/jupyterlab-lsp:jump_to
4849
${DIAGNOSTICS PLUGIN ID} @krassowski/jupyterlab-lsp:diagnostics
4950
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
5051
${JLAB XP CLOSE SETTINGS} ${JLAB XP DOCK TAB}\[contains(., 'Settings')]/*[contains(@class, 'm-TabBar-tabCloseIcon')]

atest/examples/jump.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
a_variable = 1
2+
3+
4+
a_variable
5.69 KB
Loading

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@
3838
"private": true,
3939
"scripts": {
4040
"bootstrap": "jlpm --no-optional --prefer-offline && lerna bootstrap && jlpm lint && jlpm clean && jlpm build",
41-
"build": "jlpm build:schema && jlpm build:completion-theme && jlpm build:theme-material && jlpm build:theme-vscode && jlpm build:meta && jlpm build:ws",
41+
"build": "jlpm build:schema && jlpm build:completion-theme && jlpm build:theme-material && jlpm build:theme-vscode && jlpm build:jump && jlpm build:meta && jlpm build:ws",
4242
"build:schema": "lerna run build:schema --stream",
4343
"build:meta": "lerna run build --stream --scope @krassowski/jupyterlab-lsp-metapackage",
4444
"build:completion-theme": "lerna run build --stream --scope @krassowski/completion-theme",
4545
"build:theme-vscode": "lerna run build --stream --scope @krassowski/theme-vscode",
4646
"build:theme-material": "lerna run build --stream --scope @krassowski/theme-material",
4747
"build:ws": "lerna run build --stream --scope lsp-ws-connection",
48+
"build:jump": "lerna run build --stream --scope @krassowski/code-jumpers",
4849
"watch": "lerna run --parallel watch",
4950
"bundle": "lerna run --parallel bundle",
5051
"clean": "lerna run --parallel clean",

packages/code-jumpers/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code Jumpers
2+
3+
Implementation underlying the jump to definition functionality in [JupyterLab-LSP](https://github.com/krassowski/jupyterlab-lsp).

0 commit comments

Comments
 (0)