From 9b45c9bdbd06c4e8ba720365530129c846e41ef1 Mon Sep 17 00:00:00 2001 From: vqn <85911372+vqns@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:26:32 +0100 Subject: [PATCH] fix incorrect x_offset if opened docs have different tab sizes (#1383) --- data/core/docview.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/core/docview.lua b/data/core/docview.lua index 1c3ff6de..cdfb0298 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -168,10 +168,13 @@ end function DocView:get_col_x_offset(line, col) local default_font = self:get_font() + local _, indent_size = self.doc:get_indent_info() + default_font:set_tab_size(indent_size) local column = 1 local xoffset = 0 for _, type, text in self.doc.highlighter:each_token(line) do local font = style.syntax_fonts[type] or default_font + if font ~= default_font then font:set_tab_size(indent_size) end for char in common.utf8_chars(text) do if column == col then return xoffset @@ -190,8 +193,11 @@ function DocView:get_x_offset_col(line, x) local xoffset, last_i, i = 0, 1, 1 local default_font = self:get_font() + local _, indent_size = self.doc:get_indent_info() + default_font:set_tab_size(indent_size) for _, type, text in self.doc.highlighter:each_token(line) do local font = style.syntax_fonts[type] or default_font + if font ~= default_font then font:set_tab_size(indent_size) end for char in common.utf8_chars(text) do local w = font:get_width(char) if xoffset >= x then