console.lua: take position indicator into account when calculating width
sometimes the position indicator takes up a large portion of the input area, leaving almost no space for input.
This commit is contained in:
1 parent
bdbeecbc11
commit
3d709c731c
1 file changed
+5
-1
@@ -348,6 +348,10 @@ local function calculate_max_item_width()
|
||||
end
|
||||
|
||||
local longest_item = prompt .. ("a"):rep(9)
|
||||
if #selectable_items > calculate_max_lines() then
|
||||
local digits = math.floor(math.log(#selectable_items, 10)) + 1
|
||||
longest_item = longest_item .. ("0"):rep(digits) .. "/" .. ("0"):rep(digits)
|
||||
end
|
||||
local longest_item_width = utils.terminal_display_width(longest_item)
|
||||
for _, item in pairs(selectable_items) do
|
||||
local item_width = utils.terminal_display_width(item)
|
||||
@@ -669,7 +673,7 @@ local function print_to_terminal()
|
||||
local counter = ""
|
||||
if selectable_items then
|
||||
if #selectable_items > calculate_max_lines() then
|
||||
local digits = math.ceil(math.log(#selectable_items, 10))
|
||||
local digits = math.floor(math.log(#selectable_items, 10)) + 1
|
||||
counter = terminal_styles.disabled ..
|
||||
"[" .. string.format("%0" .. digits .. "d", focused_match) ..
|
||||
"/" .. string.format("%0" .. digits .. "d", #matches) ..
|
||||
|
||||
Reference in new issue
Block a user