aboutsummaryrefslogtreecommitdiff
path: root/plugins/indentguide.lua
diff options
context:
space:
mode:
authorTakase <20792268+takase1121@users.noreply.github.com>2021-05-31 11:18:12 +0800
committerGitHub <noreply@github.com>2021-05-31 11:18:12 +0800
commit0d87d70140b8c318ca171330658d3a7cf00f5037 (patch)
treeeb333ce5d63f7f393b61ac544124be5398496d3a /plugins/indentguide.lua
parenta07e30be3827f9444f967ba633171ea8c90cd41e (diff)
parent5b9a3bd28d937d131da5821f075952df80c14040 (diff)
downloadlite-xl-plugins-0d87d70140b8c318ca171330658d3a7cf00f5037.tar.gz
lite-xl-plugins-0d87d70140b8c318ca171330658d3a7cf00f5037.zip
Merge branch 'master' into contextmenu
Diffstat (limited to 'plugins/indentguide.lua')
-rw-r--r--plugins/indentguide.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/indentguide.lua b/plugins/indentguide.lua
index daf7d8b..f1b7cf7 100644
--- a/plugins/indentguide.lua
+++ b/plugins/indentguide.lua
@@ -1,3 +1,4 @@
+-- mod-version:1 -- lite-xl 1.16
local style = require "core.style"
local config = require "core.config"
local DocView = require "core.docview"
@@ -34,12 +35,16 @@ local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(idx, x, y)
local spaces = get_line_indent_guide_spaces(self.doc, idx)
- local sw = self:get_font():get_width(" ")
local w = math.ceil(1 * SCALE)
local h = self:get_line_height()
- for i = 0, spaces - 1, config.indent_size do
+ local sspaces = ""
+ local font = self:get_font()
+ local ss = font:subpixel_scale()
+ for _ = 0, spaces - 1, config.indent_size do
local color = style.guide or style.selection
- renderer.draw_rect(x + sw * i, y, w, h, color)
+ local sw = font:get_width_subpixel(sspaces) / ss
+ renderer.draw_rect(x + sw, y, w, h, color)
+ sspaces = sspaces .. (' '):rep(config.indent_size)
end
draw_line_text(self, idx, x, y)
end