-
Notifications
You must be signed in to change notification settings - Fork 154
Description
Description
Jump to definition feature doesn't seem to handle spaces in base/parent path correctly. Jump to-feature behaves as if trying to perform a global jump using the .lsp_symlink, even though the target is in same directory than jump source. Getting similar results both in Windows 10 and Ubuntu 18.04:
Reproduce
Not entirely sure if prerequisite in reproducing the issue, but I have jupytext installed.
- Start jupyterlab server in directory, which has spaces in the name (might be reproducible with just space in anywhere in path)
- Create a target file (extension.py in my example) with function definition
- Create and open another python file in notebook mode and import function
- Jump to function definition
While debugging the issue I pinpointed the culprit to:
https://github.com/krassowski/jupyterlab-lsp/blob/fbc9d1c2f67842352acbbcb276347c6e65d51d29/packages/jupyterlab-lsp/src/utils.ts#L134
where child and parent:
child = "file:///c:/Users/avaissi/Documents/My own robot/.virtual_documents/tasks/extension.py"
parent = "file:///c:/Users/avaissi/Documents/My%20own%20robot"
thus failing the child.startsWith(parent) comparison.
When tried to wrap the parent || server_root_uri() with decodeURI() -> parent = decodeURI(parent || server_root_uri()); things worked nicely.
Expected behavior
I'm expecting the jump to complete to a file/location within same directory.
And furthermore, I'm expecting the URI to compare spaces (and possibly other special characters) either encoded or decoded.
Context
- Windows 10, Ubuntu 18.04
- Chrome: Version 86.0.4240.183 (Official Build) (64-bit)
- JupyterLab version: 2.2.6
- jupyterlab-lsp: 2.0.8
Required: installed server extensions
jupyter_lsp 0.9.2 ok jupyterlab 2.2.6 ok jupytext 1.5.0 ok
Required: installed lab extensions
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled ok @krassowski/jupyterlab-lsp v2.0.8 enabled ok @robocorp/theme-robocodelab-extension v2.3.2 enabled ok jupyterlab-jupytext v1.2.1 enabled ok
Browser Output (recommended for all interface issues)
Will jump to the first of suggested locations: Array(1)0: {uri: "file:///c:/Users/avaissi/Documents/My%20own%20robot/.virtual_documents/tasks/extension.py", range: {…}}length: 1__proto__: Array(0)
jump_to.js:77 Jumping to external file: file:///c:/Users/avaissi/Documents/My own robot/.virtual_documents/tasks/extension.py
jump_to.js:78 Jump target (source location): Object
api/contents/c%3A/Users/avaissi/Documents/My%20own%20robot/.virtual_documents/tasks/extension.py?content=0&1604934607968:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jump_to.js:103 Error: c:/Users/avaissi/Documents/My own robot/.virtual_documents/tasks/extension.py is outside root contents directory
at Function.create (serverconnection.js:106)
at async Drive.get (index.js:496)
at async jump_to_CMJumpToDefinition.handle_jump (jump_to.js:96)
at async Object.execute (jump_to.js:137)
handle_jump @ jump_to.js:103
notebook.js:75 LSP: waiting for .lsp_symlink//c:Users/avaissi/Documents/My own robot/.virtual_documents/tasks/extension.py to fully load
api/contents/.lsp_symlink/c%3AUsers/avaissi/Documents/My%20own%20robot/.virtual_documents/tasks/extension.py?type=notebook&content=1&1604934607990:1 Failed to load resource: the server responded with a status of 404 (Not Found)
