Skip to content

Commit

Permalink
Chore: Rename tab.Configuration to tab.Preference
Browse files Browse the repository at this point in the history
  • Loading branch information
hankertrix committed Dec 27, 2024
1 parent a22bdc1 commit d816380
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ local DEFAULT_NOTIFICATION_OPTIONS = {
timeout = 5,
}

-- The tab configuration keys.
-- The tab preference keys.
-- The values are just dummy values
-- so that I don't have to maintain two
-- different types for the same thing.
---@type tab.Preference
local TAB_CONFIG_KEYS = {
local TAB_PREFERENCE_KEYS = {
sort_by = "alphabetical",
sort_sensitive = false,
sort_reverse = false,
Expand Down Expand Up @@ -785,25 +785,26 @@ local get_paths_of_selected_items = ya.sync(function(_, quote)
return paths_of_selected_items
end)

-- Function to get the tab configuration
---@type fun(_): tab.Preference
local get_tab_config = ya.sync(function(_)
-- Function to get the tab preferences
---@param _ State
---@return tab.Preference
local get_tab_preferences = ya.sync(function(_)
--

-- Create the table to store the tab configuration
local tab_config = {}
-- Create the table to store the tab preferences
local tab_preferences = {}

-- Iterate over the tab configuration keys
for key, _ in pairs(TAB_CONFIG_KEYS) do
-- Iterate over the tab preference keys
for key, _ in pairs(TAB_PREFERENCE_KEYS) do
--

-- Set the key in the table to the value
-- from the state
tab_config[key] = cx.active.pref[key]
tab_preferences[key] = cx.active.pref[key]
end

-- Return the tab configuration
return tab_config
-- Return the tab preferences
return tab_preferences
end)

-- Function to get if Yazi is loading
Expand Down Expand Up @@ -998,16 +999,16 @@ local function skip_single_child_directories(initial_directory_url)
-- Initialise the directory variable to the initial directory given
local directory = initial_directory_url

-- Get the tab configuration
local tab_config = get_tab_config()
-- Get the tab preferences
local tab_preferences = get_tab_preferences()

-- Start an infinite loop
while true do
--

-- Get all the items in the current directory
local directory_items =
get_directory_items(directory, tab_config.show_hidden)
get_directory_items(directory, tab_preferences.show_hidden)

-- If the number of directory items is not 1,
-- then break out of the loop.
Expand Down Expand Up @@ -2115,16 +2116,16 @@ local function handle_leave(args, config)
---@type Url
local directory = get_current_directory_url()

-- Get the tab configuration
local tab_config = get_tab_config()
-- Get the tab preferences
local tab_preferences = get_tab_preferences()

-- Start an infinite loop
while true do
--

-- Get all the items in the current directory
local directory_items =
get_directory_items(directory, tab_config.show_hidden)
get_directory_items(directory, tab_preferences.show_hidden)

-- If the number of directory items is not 1,
-- then break out of the loop.
Expand Down

0 comments on commit d816380

Please sign in to comment.