Skip to content

Commit

Permalink
fix: use correct starting cycle position when not on a tagged file
Browse files Browse the repository at this point in the history
  • Loading branch information
cbochs committed Mar 15, 2024
1 parent 79fef01 commit e4d2031
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/grapple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ function Grapple.cycle(direction, opts)
-- 1. Change to 0-based indexing
-- 2. Perform index % container length, being careful of negative values
-- 3. Change back to 1-based indexing
local index = (container:find(opts) or 1) - 1
local index = (
container:find(opts)
or direction == "forward" and container:len()
or direction == "backward" and 1
) - 1
local next_direction = direction == "forward" and 1 or -1
local next_index = math.fmod(index + next_direction + container:len(), container:len()) + 1

Expand Down

0 comments on commit e4d2031

Please sign in to comment.