fix: take into account prompt size in nui and builtin selects (#135)
This commit is contained in:
parent
2caff86e8b
commit
d7dde6afff
|
@ -55,7 +55,7 @@ M.select = function(config, items, opts, on_choice)
|
||||||
end
|
end
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local highlights = {}
|
local highlights = {}
|
||||||
local max_width = 1
|
local max_width = opts.prompt and vim.api.nvim_strwidth(opts.prompt) or 1
|
||||||
for idx, item in ipairs(items) do
|
for idx, item in ipairs(items) do
|
||||||
local prefix = ""
|
local prefix = ""
|
||||||
if config.show_numbers then
|
if config.show_numbers then
|
||||||
|
|
|
@ -8,7 +8,7 @@ M.select = function(config, items, opts, on_choice)
|
||||||
local Menu = require("nui.menu")
|
local Menu = require("nui.menu")
|
||||||
local event = require("nui.utils.autocmd").event
|
local event = require("nui.utils.autocmd").event
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local line_width = 1
|
local line_width = opts.prompt and vim.api.nvim_strwidth(opts.prompt) or 1
|
||||||
for i, item in ipairs(items) do
|
for i, item in ipairs(items) do
|
||||||
local line = opts.format_item(item)
|
local line = opts.format_item(item)
|
||||||
line_width = math.max(line_width, vim.api.nvim_strwidth(line))
|
line_width = math.max(line_width, vim.api.nvim_strwidth(line))
|
||||||
|
|
Loading…
Reference in New Issue