Skip to content

Jump to definition handling spaces in URI inconsistently #403

@avaissi

Description

@avaissi

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:

image

Reproduce

Not entirely sure if prerequisite in reproducing the issue, but I have jupytext installed.

  1. Start jupyterlab server in directory, which has spaces in the name (might be reproducible with just space in anywhere in path)
  2. Create a target file (extension.py in my example) with function definition
  3. Create and open another python file in notebook mode and import function
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions