chrishrb / gx.nvim

Implementation of gx without the need of netrw
Apache License 2.0
186 stars 19 forks source link

bug: github handler doesn't handle `org/repo#issue` #56

Closed aarondill closed 2 months ago

aarondill commented 3 months ago

Opening a github url like org/repo#issue instead tries to open the current git remote URL (and fails due to #45). for example:

> git remote -v
origin  https://github.com/sindrets/diffview.nvim.git (fetch) [blob:none]
origin  https://github.com/sindrets/diffview.nvim.git (push)

pressing gx on neovim/neovim#23943 results in the choice between searching the string or opening https://github.com/sindrets/diffview.nvim.git (fetch)/issues/23943

Instead, this should open https://github.com/neovim/neovim/issues/23943

sportshead commented 2 months ago

Fixed in #46

aarondill commented 2 months ago

@sportshead @chrishrb I've tested this with the latest HEAD(4136a82a48e8601fe8f2fde5d2ac2d706ac6d0b6) with both of these:

chrishrb/gx.nvim#46
neovim/neovim#23943

the first results in a choice between opening https://chrishrb/gx.nvim# and a google search. The second results in an error gx.nvim: No remote git repository found! and a google search.

  1. Test with mkdir .repro && cd "$_" && git init && touch file && nvim file
  2. paste the above contents
  3. For each line:
    1. Highlight the line with V OR 0v$
    2. Press gx to open the link
    3. Observe incorrect behavior
  4. Clean up the repro with rm -f file && rm -rf .git && cd .. && rmdir .repro
sportshead commented 2 months ago

@aarondill - thanks for the testing!

The first issue is a problem with the matching regex that doesn't include the . character while searching. The second also is that the plugin cannot find a remote. However, I can make it fallback to use github.com in the case that no repo is found but both owner and repo are passed.