Skip to content

Commit

Permalink
fix: reuse pick letters (#186)
Browse files Browse the repository at this point in the history
Make `first_valid` a function-level variable rather than a module-level
one.  This way when buffers are deleted, the letters at the begining of
the list are re-used.

This improves the UX when `use_filename` is false:
  - The letters at the begining of the list are likely to be the best
    ones.  My setup puts the home row keys at the start.
  - Otherwise, if you keep deleting buffers you can use up all the
    letters and get `?` for all your buffers.
  • Loading branch information
bendk committed Dec 30, 2023
1 parent 0706949 commit a5e41ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/cokeline/buffers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ local current_valid_index
---@type string?
local valid_pick_letters

local first_valid = 1

local taken_pick_letters = {}
local taken_pick_indices = {}
local buf_order = {}
Expand Down Expand Up @@ -106,6 +104,8 @@ end
---@param bufnr bufnr
---@return string
local get_pick_letter = function(filename, bufnr)
local first_valid = 1

-- Initialize the valid letters string, if not already initialized
if not valid_pick_letters then
valid_pick_letters = config.pick.letters
Expand Down

0 comments on commit a5e41ba

Please sign in to comment.