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

Open files via Jupyter instead of LSP #357

Merged
merged 1 commit into from
May 29, 2024
Merged

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented May 17, 2024

Follow-up to:

As I was working on posit-dev/positron#2999, I initially thought that Backend should be the sole owner of a WorldState struct which should not be clonable, which meant Backend could no longer be clonable. This PR is a step towards making the LSP the sole owner of Backend by changing our implementation of file.edit() to make a request via the UI Jupyter comm instead of the LSP. The Jupyter request is blocking, unlike the LSP one, but this is sufficiently fast that it shouldn't matter.

Note that I later figured out that a clonable state is a good thing as long it doesn't have any interior mutability. A clone of the worldstate is a snapshot and it allows background workers to work without risking having their data change from under their feet. In any case, making the kernel independent from the LSP is cleaner (see posit-dev/positron#3180), so I've kept this commit.

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@DavisVaughan DavisVaughan left a comment

Choose a reason for hiding this comment

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

Tested locally, working nicely still!

for (f in file) {
# This blocks until a response from the frontend, unlike RStudio which
# uses a fire-and-forget event. This shouldn't cause any issues.
.ps.ui.navigateToFile(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

This was probably already the case before, but I guess a different frontend will have to have their own editor hook, or we will eventually make these UI function override-able if you are outside positron

.ps.Call("ps_editor", file, title)
for (f in file) {
# This blocks until a response from the frontend, unlike RStudio which
# uses a fire-and-forget event. This shouldn't cause any issues.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I actually prefer blocking in case the user tries to do some immediate follow up code on the opened file (similar to the "save all documents" issue we have about it being non-blocking right now)

@lionel- lionel- merged commit be27e88 into main May 29, 2024
1 check passed
@lionel- lionel- deleted the upkeep/open-editor-via-jupyter branch May 29, 2024 09:19
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.

3 participants