Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

investigate escaping jumping to definition (and other features) with spaces #406

Merged
merged 15 commits into from
Nov 27, 2020

Conversation

bollwyvl
Copy link
Collaborator

@bollwyvl bollwyvl commented Nov 10, 2020

References

Code changes

  • atest
    • demonstrate a reproducible failure (bb39801)
    • rework some globals to be set by Variables.robot (can be overridden from CLI)
    • move more lab config into JSON, launch without shell=True
  • @krassowski/jupyterlab-lsp
    • remove a number of (decode|encode)URI calls
    • always encodeURI the document path
  • @krassowski/jupyterlab_go_to_definition
    • rename IGlobalJump.uri to IGlobalJump.contents_path
    • add some more information to the docstrings
    • sweep for more references to URIs that are actually contents paths
  • consider any additional ways to prevent this in the future

User-facing changes

Should reliably Jump between files in folders with spaces and special characters, including when jupyter lab is launched from directories containing spaces, especially on windows.

Backwards-incompatible changes

  • @krassowski/jupyterlab_go_to_definition
    • IGlobalJump.uri renamed to IGlobalJump.contents_path

Chores

  • linted
  • tested
  • documented
  • changelog entry

@bollwyvl
Copy link
Collaborator Author

Ha: failed to even start the acceptance tests on windows, so haven't yet reproduced (even though it's failing).

We're generally very careful about paths, but the way we start jupyter under test is quite kludgy... I'll look at doing more of it with a json file which is less sensitive to paths/escaping.

@avaissi
Copy link

avaissi commented Nov 11, 2020

Anything here I could help with? Maybe to investigate the issue more for root cause, if not already found

@bollwyvl
Copy link
Collaborator Author

bollwyvl commented Nov 11, 2020 via email

scripts/atest.py Outdated
@@ -80,7 +83,7 @@ def atest(attempt, extra_args):
if previous.exists():
extra_args += ["--rerunfailed", str(previous)]

out_dir = OUT / stem
out_dir = OUT / (stem + GH_403_BAD_PATH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the path addition should not be pushed further down to the actual robot tests. I think that we already have one notebook with space in the name, probably just not the one testing jump functions. Though having this as a top dir would be convenient indeed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! I was kind of tired.

Moved it (and a number of other paths) down into Variables.robot... they can be overridden with:

python -m scripts.atest --variable "NOTEBOOK DIR NAME:🐶 🐶 🐶"

would yield:

atest/output/linux_37_1/home/🐶 🐶 🐶/

@bollwyvl
Copy link
Collaborator Author

bollwyvl commented Nov 11, 2020 via email

@bollwyvl
Copy link
Collaborator Author

gah... the formatting of the flake8 messages now leads with the code, e.g. F821 undefined name. Will try with title*=[<the diagnostic>], as who knows...

@bollwyvl
Copy link
Collaborator Author

Well, still didn't get to reproducing #403 on windows (or at least hasn't finished), but otherwise good progress...

@bollwyvl bollwyvl changed the title [wip] investigate escaping spaces when renaming in rootUri [wip] investigate escaping jumping to definition (and other features) with spaces Nov 12, 2020
bollwyvl added a commit that referenced this pull request Nov 12, 2020
@bollwyvl bollwyvl mentioned this pull request Nov 12, 2020
4 tasks
@bollwyvl
Copy link
Collaborator Author

Great news! I can reproduce the error!

selenium-screenshot-1

Hopefully we'll get just that fail for all of the tests, and I can add the decodeURI part!

@bollwyvl
Copy link
Collaborator Author

Actually had a look deeper: turns out the IGlobalJump.uri is not a URI at all, and has always been the more "humane" Jupyter contents path. This in turn gets URL encoded when it actually hits the ContentsManager, as HTTP is ASCII, like it or lump it.

A few changes throughout were required to normalize this behavior (86f5abe), and make the naming more accurate (89102dd, breaking change), and linting (2e43577) but it should hopefully now be more robust overall, and address some other odd issues I had seen but hadn't narrowed down to this root cause.

On #278 I briefly toyed with using an existing URI library, but ran into some issues... it may be worth revisiting, either:

  • adopting somebody's,
  • getting one into lab/lumino
  • at worst rolling our own
    • which can already handle things like URI.toContentsPath(), etc.

At any rate, whatever we use, we should probably never treat a URI as a plain-old-string, which would prvent these kinds of issues, as well as double encode, etc.

Going to let a full local clean build run while CI is chugging, and might not address any more this evening... good times!

@bollwyvl
Copy link
Collaborator Author

Local run looks good, and 89102dd has test wins (aside from lint) on all the platforms:
https://github.com/krassowski/jupyterlab-lsp/runs/1404308642

Taking off WIP, ready for review!

@bollwyvl bollwyvl changed the title [wip] investigate escaping jumping to definition (and other features) with spaces investigate escaping jumping to definition (and other features) with spaces Nov 16, 2020
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@krassowski
Copy link
Member

Ok, looks great will merge once CI passes. Thank you!

@bollwyvl
Copy link
Collaborator Author

bollwyvl commented Nov 20, 2020 via email

@krassowski krassowski merged commit 4830b98 into jupyter-lsp:master Nov 27, 2020
@BugApe
Copy link

BugApe commented Jul 27, 2021

This problem also occurs when the filename contains "=", such as "NeuralTaskonomy_axis=1.ipynb", and renaming the variable will fail.
image

@krassowski
Copy link
Member

What language server are you using?

@BugApe
Copy link

BugApe commented Jul 29, 2021

What language server are you using?

python

@krassowski
Copy link
Member

@BugApe, which one:

  • pyls
  • pylsp
  • jedi-ls
  • pyright

? Could you open a new issue following bug report template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jump to definition handling spaces in URI inconsistently
4 participants