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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/ark/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ pub struct RMain {

// LSP tokio runtime used to spawn LSP tasks on the executor and the
// corresponding backend used to send LSP requests to the frontend.
// Used by R callbacks, like `ps_editor()` for `utils::file.edit()`.
// The backend is initialized on LSP start up, and is refreshed after a
// frontend reconnect.
lsp_runtime: Arc<Runtime>,
Expand Down
84 changes: 0 additions & 84 deletions crates/ark/src/lsp/editor.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/ark/src/lsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod definitions;
pub mod diagnostics;
pub mod document_context;
pub mod documents;
pub mod editor;
pub mod encoding;
pub mod events;
pub mod handler;
Expand Down
6 changes: 5 additions & 1 deletion crates/ark/src/modules/positron/editor.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ handler_editor <- function(file, title, ..., name = NULL) {
ensure_file(file)

# Edit those files.
.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)

.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

}

invisible()
}
5 changes: 4 additions & 1 deletion crates/ark/src/modules/positron/frontend-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
#

# TODO: Unexport these methods

#' @export
.ps.ui.LastActiveEditorContext <- function() {
.ps.Call("ps_ui_last_active_editor_context")
Expand All @@ -31,7 +33,8 @@
}

#' @export
.ps.ui.navigateToFile <- function(file, line, column) {
.ps.ui.navigateToFile <- function(file = character(0), line = -1L, column = -1L) {
file <- normalizePath(file)
.ps.Call("ps_ui_navigate_to_file", file, line, column)
}

Expand Down
1 change: 0 additions & 1 deletion crates/ark/src/modules/rstudio/stubs.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# TODO: support moveCursor argument
stopifnot(moveCursor)

file <- normalizePath(file)
invisible(.ps.ui.navigateToFile(file, line, column))
}

Expand Down
Loading