Skip to content

Commit f34a686

Browse files
committed
fix: allow multibyte characters on buffer picker
1 parent 7ec240f commit f34a686

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lua/cokeline/buffers.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ local get_pick_letter = function(filename, bufnr)
113113
-- If the config option pick.use_filename is true, and the initial letter
114114
-- of the filename is valid and it hasn't already been assigned return that.
115115
if _G.cokeline.config.pick.use_filename then
116-
local init_letter = filename:sub(1, 1)
116+
local init_letter = vim.fn.strcharpart(filename, 0, 1)
117117
if valid_pick_letters:find(init_letter, nil, true) then
118118
valid_pick_letters = valid_pick_letters:gsub(init_letter, "")
119119
taken_pick_letters[bufnr] = init_letter
@@ -123,8 +123,8 @@ local get_pick_letter = function(filename, bufnr)
123123

124124
-- Return the first valid letter if there is one.
125125
if #valid_pick_letters > 0 then
126-
local first_valid = valid_pick_letters:sub(1, 1)
127-
valid_pick_letters = valid_pick_letters:sub(2)
126+
local first_valid = vim.fn.strcharpart(valid_pick_letters, 0, 1)
127+
valid_pick_letters = vim.fn.strcharpart(valid_pick_letters, 1, #valid_pick_letters - 1)
128128
taken_pick_letters[bufnr] = first_valid
129129
return first_valid
130130
end

0 commit comments

Comments
 (0)