smoka7/hop.nvim

Bug: Invalid `end_col`: out of range

Closed this issue · 0 comments

Describe the bug

When using <cmd>HopLineAC<cr> or <cmd>HopLineBC<cr> to jump to below/above lines, there's an error:

image

To Reproduce

Install hop.nvim with lazy.nvim:

  {
    "smoka7/hop.nvim",
    version = "*",
    config = function() 
      require("hop").setup()
    end,
  },

I found in below lua file, it can always re-produce this issue.

Here's the file link: https://github.com/linrongbin16/fzfx.nvim/blob/2f7425cf7fdb94814eb98295f3fb7851daace68d/spec/lib/switches_spec.lua?plain=1#L13

local cwd = vim.fn.getcwd()

describe("lib.switches", function()
  local assert_eq = assert.is_equal
  local assert_true = assert.is_true
  local assert_false = assert.is_false

  before_each(function()
    vim.api.nvim_command("cd " .. cwd)
  end)

  local switches = require("fzfx.lib.switches")
  describe("[fzfx_disable_buffer_previewer]", function()
    it("disabled", function()
      vim.g.fzfx_disable_buffer_previewer = 1
      assert_true(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = true
      assert_true(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = "true"
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = nil
      assert_false(switches.buffer_previewer_disabled())
    end)
    it("enabled", function()
      vim.g.fzfx_disable_buffer_previewer = 0
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = false
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = "false"
      assert_false(switches.buffer_previewer_disabled())
      vim.g.fzfx_disable_buffer_previewer = nil
      assert_false(switches.buffer_previewer_disabled())
    end)
  end)
end)

The re-produce steps are:

  1. Place the cursor to line-13, column-47 (the function()).
  2. Press <S-V> to enter visual mode (and current line is selected).
  3. Press G to go to bottom line (and from the start line to the bottom line are all selected).
  4. Press <Leader>k (I mapped this key to <cmd>HopLineBC<cr>) to jump to above lines.

Expected behavior

Don't throw exception, and jump correctly.

Screenshots

See above.

version (please complete the following information):

  • Nvim version: NVIM v0.10.1, Build type: Release.
  • hop.nvim version: v2.7.0.

Additional context

N/A.