From 154b2c4c2ea768f361e37ef5b4fd8144ad2634f9 Mon Sep 17 00:00:00 2001 From: Lam Chau Date: Sat, 16 Dec 2023 13:52:36 -0800 Subject: [PATCH] fix(floating-big-letter): calculate max width (#74) 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 --- lua/window-picker/hints/floating-big-letter-hint.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/window-picker/hints/floating-big-letter-hint.lua b/lua/window-picker/hints/floating-big-letter-hint.lua index 0cf0d31..c036e14 100644 --- a/lua/window-picker/hints/floating-big-letter-hint.lua +++ b/lua/window-picker/hints/floating-big-letter-hint.lua @@ -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)