From 4e5a3f170f620591ce8214441fe4d34572be38f5 Mon Sep 17 00:00:00 2001 From: Aleksandr Jakusev Date: Fri, 15 Mar 2024 17:41:45 +0100 Subject: [PATCH] Use unicode-aware substring when deriving foldtext --- lua/neorg/modules/core/concealer/module.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/neorg/modules/core/concealer/module.lua b/lua/neorg/modules/core/concealer/module.lua index 6e548b5be..7ed023dd8 100644 --- a/lua/neorg/modules/core/concealer/module.lua +++ b/lua/neorg/modules/core/concealer/module.lua @@ -479,13 +479,11 @@ module.public = { for _, extmark in ipairs(icon_extmarks) do local extmark_details = extmark[4] - local extmark_column = extmark[3] + (line_length - vim.api.nvim_strwidth(line)) for _, virt_text in ipairs(extmark_details.virt_text or {}) do - line = line:sub(1, extmark_column) + line = vim.fn.strcharpart( line, 0, extmark[3] ) .. virt_text[1] - .. line:sub(extmark_column + vim.api.nvim_strwidth(virt_text[1]) + 1) - line_length = vim.api.nvim_strwidth(line) - line_length + vim.api.nvim_strwidth(virt_text[1]) + .. vim.fn.strcharpart( line, extmark[3] + vim.api.nvim_strwidth(virt_text[1]) ) end end