Skip to content

Commit

Permalink
Use open crate to implement showing external documents
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeiml committed Feb 26, 2023
1 parent 71c64da commit ed98b14
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ anyhow = "1"
once_cell = "1.17"

which = "4.4"
open = "3.2.0"

tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
Expand Down
13 changes: 11 additions & 2 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,17 @@ impl Application {
use helix_view::editor::Action;

if params.external.unwrap_or(false) {
// TODO: Implement this
Ok(json!(lsp::ShowDocumentResult { success: false }))
match open::that(params.uri.as_str()) {
Ok(_) => Ok(json!(lsp::ShowDocumentResult { success: true })),
Err(err) => {
let err = format!(
"failed to open path externally: {:?}: {:?}",
params.uri, err
);
self.editor.set_error(err);
Ok(json!(lsp::ShowDocumentResult { success: false }))
}
}
} else {
match params.uri.to_file_path() {
Err(_) => {
Expand Down

0 comments on commit ed98b14

Please sign in to comment.