hop.nvim icon indicating copy to clipboard operation
hop.nvim copied to clipboard

Error when trying to navigate to line from empty line

Open chaudry-786 opened this issue 3 years ago • 21 comments

Hi, If I try to navigate to another line "HopLineAC" or "HopLineBC" from an empty line I get following error.

E5108: Error executing lua /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:130: col value outside range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:130: in function 'set_unmatched_lines'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:140: in function 'apply_dimming'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:352: in function 'hint_with_callback'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:304: in function 'hint_with'
        /Users/sabah/.vim/plugged/hop.nvim/lua/hop/init.lua:544: in function 'hint_lines'
        [string ":lua"]:1: in main chunk

chaudry-786 avatar Oct 20 '22 13:10 chaudry-786

This doesn't happen for me on Ubuntu 22.04 with Neovim v0.8.0-1210-gd367ed9b2 (Release) and LuaJIT 2.1.0-beta3 . Is there something unique about your setup or file that you're editing that might suggest the cause of the issue?

image

samjwill avatar Oct 23 '22 17:10 samjwill

:HopWordAC and :HopWordBC also have the same error when used on an empty line.

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3

cheeze2000 avatar Oct 24 '22 04:10 cheeze2000

NVIM v0.7.2 Build type: Release LuaJIT 2.1.0-beta3

chaudry-786 avatar Oct 24 '22 09:10 chaudry-786

@sabah1994, are you using the hop.hint_lines API?

mystilleef avatar Oct 24 '22 09:10 mystilleef

@mystilleef I dont't think so.

This is my config https://github.com/sabah1994/dotfiles/blob/d758306f2b02436ad5b48d6f8957e34b5e9a6405/nvim/lua/plug-config/hop.lua#L3

chaudry-786 avatar Oct 24 '22 09:10 chaudry-786

@samjwill @mystilleef any update on this please?

chaudry-786 avatar Oct 25 '22 13:10 chaudry-786

@samjwill @mystilleef any update on this please?

Unfortunately, I'm having the same issue.

mystilleef avatar Oct 26 '22 08:10 mystilleef

I have the same issue with HopChar2AC and HopChar2BC. It seems like the error occurs when I jump from an empty line and Hop suggests multiple destinations. When there is only one matching destination no error occurs.

klingberg avatar Oct 26 '22 22:10 klingberg

I’m having a look at that tomorrow. That bug has been crawling around in several part of the API, and a refactor of the window position / jump is probably required as more and more features were added in the past months.

hadronized avatar Oct 26 '22 23:10 hadronized

Currently having the same issue, anyone been able to find a workaround?

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by [email protected]

juanchinojo avatar Nov 01 '22 06:11 juanchinojo

Currently having the same issue, anyone been able to find a workaround?

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by [email protected]

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

BartSte avatar Nov 02 '22 18:11 BartSte

@phaazon any update on this?

chaudry-786 avatar Nov 06 '22 23:11 chaudry-786

Same issue on hint_char1 and hint_word

NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3

jesHrz avatar Nov 07 '22 06:11 jesHrz

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by [email protected]

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines šŸ˜ž But for now it's the only solution šŸ‘ˆļø

liketurbo avatar Nov 09 '22 08:11 liketurbo

any progress on this?

chaudry-786 avatar Dec 07 '22 12:12 chaudry-786

This doesn't happen for me on Ubuntu 22.04 with Neovim v0.8.0-1210-gd367ed9b2 (Release) and LuaJIT 2.1.0-beta3 . Is there something unique about your setup or file that you're editing that might suggest the cause of the issue?

Not sure about Ubuntu, but having the same problem both in Mac Ventura and W10.

AlkTheOrg avatar Dec 28 '22 19:12 AlkTheOrg

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by [email protected]

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines disappointed But for now it's the only solution point_left

A better work around is to use the following branch instead of the workaround above: https://github.com/aznhe21/hop.nvim/tree/fix-some-bugs

Hopefully it gets merged soon...

BartSte avatar Dec 30 '22 15:12 BartSte

Plug 'aznhe21/hop.nvim', { 'branch': 'fix-some-bugs'}

spire-carlos avatar Jan 11 '23 20:01 spire-carlos

Will this fix ever get merged?

BartSte avatar Apr 01 '23 10:04 BartSte

Will this fix ever get merged?

@BartSte can't say for sure, but you might try directly using the branch that fixes it in your config

FelipeLema avatar Apr 03 '23 15:04 FelipeLema

Currently having the same issue, anyone been able to find a workaround? NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by [email protected]

As a workaround, when the cursor is on a blank line, I let it jump to the next non-blank line, for example:

local function hop_w()
    local opts = { direction = hint.HintDirection.AFTER_CURSOR }
    vim.cmd('.g/^$/normal )')
    hop.hint_words(opts)
end

Not a nice way, and it won't work all the time, but it is enough for now...

Still will break though if you on the last line and it is empty or file consists of an empty lines disappointed But for now it's the only solution point_left

A better work around is to use the following branch instead of the workaround above: https://github.com/aznhe21/hop.nvim/tree/fix-some-bugs

Hopefully it gets merged soon...

Yes I know ;) @FelipeLema

BartSte avatar Apr 03 '23 16:04 BartSte