Skip to content

Commit b8413d2

Browse files
committed
review comments
1 parent 927dbd8 commit b8413d2

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

lua/telescope/builtin/lsp.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ lsp.code_actions = function(opts)
142142
}
143143

144144
for key, value in pairs(widths) do
145-
widths[key] = math.max(value, vim.fn.strdisplaywidth(entry[key]))
145+
widths[key] = math.max(value, utils.strdisplaywidth(entry[key]))
146146
end
147147

148148
table.insert(results, entry)
@@ -159,15 +159,15 @@ lsp.code_actions = function(opts)
159159
local displayer = entry_display.create {
160160
separator = " ",
161161
items = {
162-
{ width = widths.idx },
162+
{ width = widths.idx + 1 }, -- +1 for ":" suffix
163163
{ width = widths.command_title },
164164
{ width = widths.client_name },
165165
},
166166
}
167167

168168
local function make_display(entry)
169169
return displayer {
170-
{entry.idx, "TelescopePromptPrefix"},
170+
{entry.idx .. ":", "TelescopePromptPrefix"},
171171
{entry.command_title},
172172
{entry.client_name, "TelescopeResultsComment"},
173173
}

lua/telescope/utils.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,14 @@ utils.strdisplaywidth = (function()
259259

260260
return function(str, col)
261261
local startcol = col or 0
262+
str = tostring(str)
262263
local s = ffi.new('char[?]', #str + 1)
263264
ffi.copy(s, str)
264265
return ffi.C.linetabsize_col(startcol, s) - startcol
265266
end
266267
else
267268
return function(str, col)
268-
return #str - (col or 0)
269+
return #(tostring(str)) - (col or 0)
269270
end
270271
end
271272
end)()

0 commit comments

Comments
 (0)