Skip to content

Commit

Permalink
fix(floating-big-letter): calculate max width (#74)
Browse files Browse the repository at this point in the history
Instead of calculating width based on 2nd index of a line, we calculate
it based on the longest length instead. Without it, we have rendering
issues on "wide" characters being forcibly wrapped.

This enables future support of custom fonts via `figlet` or `toilet`.

Fixes: #69
  • Loading branch information
lamchau committed Dec 16, 2023
1 parent 7c936dd commit 154b2c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/window-picker/hints/floating-big-letter-hint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ function M:_show_letter_in_window(window, char)

local lines = self._add_big_char_margin(vim.split(char, '\n'))

local width = utf8.len(lines[2])
local width = 0
for _, line in ipairs(lines) do
width = math.max(width, utf8.len(line))
end
local height = #lines

local buffer_id = vim.api.nvim_create_buf(false, true)
Expand Down

0 comments on commit 154b2c4

Please sign in to comment.