Skip to content

Commit

Permalink
Refactor: Use a variable to store the number of files
Browse files Browse the repository at this point in the history
  • Loading branch information
hankertrix authored Jun 30, 2024
1 parent 89ecec9 commit 8ef2947
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,17 @@ local wraparound_arrow = ya.sync(function(_, args)
-- Get the step from the arguments given
local step = table.remove(args, 1)

-- Get the number of files in the current tab
local number_of_files = #current_tab.files

-- If there are no files in the current tab, exit the function
if #current_tab.files == 0 then return end
if number_of_files == 0 then return end

-- Get the new cursor index,
-- which is the current cursor position plus the step given
-- to the arrow function, modulus the number of files in
-- the current tab
local new_cursor_index = (current_tab.cursor + step) % #current_tab.files
local new_cursor_index = (current_tab.cursor + step) % number_of_files

-- Emit the arrow function with the new cursor index minus
-- the current cursor index to determine how to move the cursor
Expand Down

0 comments on commit 8ef2947

Please sign in to comment.