fix incorrect x_offset if opened docs have different tab sizes (#1383)

This commit is contained in:
vqn 2023-02-09 18:26:32 +01:00 committed by George Sokianos
parent b9cc661a84
commit 9b4a86f763
1 changed files with 6 additions and 0 deletions

View File

@ -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