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

Add goto_url (gu) command #4398

Closed
wants to merge 2 commits into from
Closed

Conversation

izoslav
Copy link

@izoslav izoslav commented Oct 21, 2022

This PR adds gu command which opens URL (either selected or hovered).

Closes #1472

use helix_lsp::Url;

let (view, doc) = current_ref!(cx.editor);
let selection = doc.selection(view.id).primary();
Copy link
Member

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),
Copy link
Member

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) {
Copy link
Member

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"
Copy link
Member

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) {
Copy link
Member

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` |
Copy link
Member

@dead10ck dead10ck Oct 21, 2022

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.

@archseer
Copy link
Member

Why do we need a second command for this? Couldn't gf be enhanced to also support this?

@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 25, 2022
@pascalkuthe pascalkuthe added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2023
matoous added a commit to matoous/helix that referenced this pull request Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Feb 4, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Mar 10, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Mar 31, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Mar 31, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request May 24, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Nov 9, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
matoous added a commit to matoous/helix that referenced this pull request Nov 19, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
pascalkuthe pushed a commit that referenced this pull request Nov 21, 2023
* feat(commands): open urls with goto_file command

Add capability for `goto_file` command to open an URL under cursor.

Fixes: #1472
Superseds: #4398

* open files inside helix

* address code review

* bump deps

* fix based on code review comments
matoous added a commit to matoous/helix that referenced this pull request Nov 21, 2023
Add capability for `goto_file` command to open an URL under cursor.

Fixes: helix-editor#1472
Superseds: helix-editor#4398
@David-Else
Copy link
Contributor

@pascalkuthe This can be closed now #5820 was merged.

dgkf pushed a commit to dgkf/helix that referenced this pull request Jan 30, 2024
* 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
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 2, 2024
* 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
Vulpesx pushed a commit to Vulpesx/helix that referenced this pull request Jun 7, 2024
* 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
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open URL under cursor
6 participants