Skip to content

Commit

Permalink
fix out of bounds bug in harpoon
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxelPrismatic committed Jun 7, 2024
1 parent b135c29 commit ad5f0c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lua/rabbit/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ require("rabbit").setup({


## Harpoon ![harpoon][harpoon]
Like [ThePrimeagen/Harpoon][https://github.com/ThePrimeagen/harpoon/tree/harpoon2], as far as I know.
Like [ThePrimeagen/Harpoon](https://github.com/ThePrimeagen/harpoon/tree/harpoon2), as far as I know.
```lua
require("rabbit").setup({
plugins_opts = { harpoon = { opts = { ---@type Rabbit.Plugin.Harpoon.Options
Expand All @@ -110,6 +110,15 @@ require("rabbit").setup({
<details>
<summary><h3>Changelog</h3></summary>
<ul>
<li>
<b>v1.1</b>
<ul>
<li>
Fixed a bug where you could duplicate entries out of bounds
<br><sub><i>I had the right code, just in the wrong spot :facepalm:</i></sub>
</li>
</ul>
</li>
<li>
<b>v1</b>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion lua/rabbit/plugins/VERSION.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"history": "v2",
"reopen": "v2",
"oxide": "v3",
"harpoon": "v1"
"harpoon": "v1.1"
}
2 changes: 1 addition & 1 deletion lua/rabbit/plugins/harpoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function M.func.file_add(n)
M.listing[0] = require("rabbit").ctx.listing
local cwd = vim.fn.getcwd()
M.listing.persist[cwd] = M.listing.persist[cwd] or {}
n = math.max(1, math.min(#M.listing[0] + 1, n))

M.listing.opened[1] = M.listing.opened[1] or vim.api.nvim_buf_get_name(require("rabbit").user.buf)
if vim.uv.fs_stat(M.listing.opened[1] .. "") == nil then
Expand All @@ -63,6 +62,7 @@ function M.func.file_add(n)

set.sub(M.listing.persist[cwd], M.listing.opened[1])
set.sub(M.listing[0], M.listing.opened[1])
n = math.max(1, math.min(#M.listing[0] + 1, n))
table.insert(M.listing.persist[cwd], n, M.listing.opened[1])
table.insert(M.listing[0], n, M.listing.opened[1])
set.save(M.memory, M.listing.persist)
Expand Down

0 comments on commit ad5f0c5

Please sign in to comment.