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

line number order depends on visual mode cursor position #65

Closed
alicewriteswrongs opened this issue Sep 26, 2022 · 0 comments · Fixed by #73
Closed

line number order depends on visual mode cursor position #65

alicewriteswrongs opened this issue Sep 26, 2022 · 0 comments · Fixed by #73
Assignees
Labels
bug Something isn't working

Comments

@alicewriteswrongs
Copy link

Describe the bug

A clear and concise description of what the bug is:

When grabbing a permalink for a visually-selected range the ordering of the line numbers at the end of the URL is dependent on the cursor position in the visual selection (i.e. is it on the first line of the selection or the last line).

What were you trying to do?

Trying to get a github permalink URL for a visually-selected range of lines.

What was the expected result?

I expect the line numbers to be in ascending order, like L2-L23, rather than dependent on cursor state.

Note that the line number ordering doesn't matter when opening a link in the browser to view the selected lines, so if you're just looking to open the page in the browser then

https://github.com/alicewriteswrongs/dotfiles/blob/c61ec53b39c49202aff593387fcb483cb0f74fee/nvim/init.vim#L481-L483

is as good as

https://github.com/alicewriteswrongs/dotfiles/blob/c61ec53b39c49202aff593387fcb483cb0f74fee/nvim/init.vim#L483-L481

However, I was a bit sad to learn today that github is not so flexible if you are trying to reference code in a comment. Normally for permalinks in the same repo Github will expand a link into a little embed, like so:

local git = require("gitlinker.git")
local buffer = require("gitlinker.buffer")
local mappings = require("gitlinker.mappings")
local opts = require("gitlinker.opts")

But this link, which just has the order of the line numbers swapped, doesn't work:

https://github.com/ruifm/gitlinker.nvim/blob/c68d4873a14d2ae614875685ccca2e49472989e8/lua/gitlinker.lua#L6-L3

What was the actual result?

If the cursor is on the first line of the selection then the order is swapped, so it's $ENDLINE-$STARTLINE, but if I have the cursor on the last line of the selection then it's $STARTLINE-$ENDLINE.

To Reproduce

I'm not using any fancy setup stuff, just doing the following in my init.vim:

require"gitlinker".setup()

To reproduce the error:

  1. open a file
  2. enter visual selection mode
  3. select a range of lines and do <leader>gy to get the git permalink
  4. observe that the order of the line numbers depends on whether the visual mode cursor is at the end or the beginning of the selection (see video below). I can freely toggle back-and-forth between these two behaviors by hitting o.

Screenshots

Screen.Recording.2022-09-26.at.12.56.05.PM.mov

System (please complete the following information):

  • OS: macOS 12.6
  • neovim --version: NVIM v0.8.0-dev+516-g8ea09fc90
  • git --version: 2.37.3
@alicewriteswrongs alicewriteswrongs added the bug Something isn't working label Sep 26, 2022
@ruifm ruifm closed this as completed in #73 Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants