-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add goto_url (gu) command #4398
Conversation
use helix_lsp::Url; | ||
|
||
let (view, doc) = current_ref!(cx.editor); | ||
let selection = doc.selection(view.id).primary(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a range; could we change this name to range
?
let text = if selection.to() - selection.from() == 1 { | ||
let current_word = movement::move_next_long_word_start( | ||
text.slice(..), | ||
movement::move_prev_long_word_start(text.slice(..), selection, 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a little clearer if this were in its own variable.
@@ -1079,6 +1079,12 @@ impl Editor { | |||
self._refresh(); | |||
} | |||
|
|||
pub fn open_url(&mut self, url: lsp::Url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably just all go into the command. I'm not sure I understand why this is an Editor
function.
@@ -43,6 +43,8 @@ log = "~0.4" | |||
|
|||
which = "4.2" | |||
|
|||
open = "3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maintainers might be wary of pulling in a crate for just this command.
text.slice(selection.from()..selection.to()).to_string() | ||
}; | ||
|
||
match Url::parse(&text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to parse a URL? What happens if you run this command with some arbitrary text?
@@ -195,6 +195,7 @@ Jumps to various locations. | |||
| `g` | Go to line number `<n>` else start of file | `goto_file_start` | | |||
| `e` | Go to the end of the file | `goto_last_line` | | |||
| `f` | Go to files in the selection | `goto_file` | | |||
| `u` | Go to url in the selection | `goto_url` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer if this explicitly mentioned that it will open the URL in a web browser.
Why do we need a second command for this? Couldn't |
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398
@pascalkuthe This can be closed now #5820 was merged. |
* feat(commands): open urls with goto_file command Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398 * open files inside helix * address code review * bump deps * fix based on code review comments
* feat(commands): open urls with goto_file command Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398 * open files inside helix * address code review * bump deps * fix based on code review comments
* feat(commands): open urls with goto_file command Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398 * open files inside helix * address code review * bump deps * fix based on code review comments
* feat(commands): open urls with goto_file command Add capability for `goto_file` command to open an URL under cursor. Fixes: helix-editor#1472 Superseds: helix-editor#4398 * open files inside helix * address code review * bump deps * fix based on code review comments
This PR adds
gu
command which opens URL (either selected or hovered).Closes #1472