fix incorrect x_offset if opened docs have different tab sizes (#1383)
This commit is contained in:
parent
8bf47ec172
commit
a07a4e3706
|
@ -168,10 +168,13 @@ end
|
||||||
|
|
||||||
function DocView:get_col_x_offset(line, col)
|
function DocView:get_col_x_offset(line, col)
|
||||||
local default_font = self:get_font()
|
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 column = 1
|
||||||
local xoffset = 0
|
local xoffset = 0
|
||||||
for _, type, text in self.doc.highlighter:each_token(line) do
|
for _, type, text in self.doc.highlighter:each_token(line) do
|
||||||
local font = style.syntax_fonts[type] or default_font
|
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
|
for char in common.utf8_chars(text) do
|
||||||
if column == col then
|
if column == col then
|
||||||
return xoffset
|
return xoffset
|
||||||
|
@ -190,8 +193,11 @@ function DocView:get_x_offset_col(line, x)
|
||||||
|
|
||||||
local xoffset, last_i, i = 0, 1, 1
|
local xoffset, last_i, i = 0, 1, 1
|
||||||
local default_font = self:get_font()
|
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
|
for _, type, text in self.doc.highlighter:each_token(line) do
|
||||||
local font = style.syntax_fonts[type] or default_font
|
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
|
for char in common.utf8_chars(text) do
|
||||||
local w = font:get_width(char)
|
local w = font:get_width(char)
|
||||||
if xoffset >= x then
|
if xoffset >= x then
|
||||||
|
|
Loading…
Reference in New Issue