From c353dd6eda02b873de847c29ddb5df9c45c0b6c0 Mon Sep 17 00:00:00 2001 From: Jipok Date: Mon, 20 Dec 2021 16:20:06 +0500 Subject: [PATCH] Add for config.highlight_current_line new variant: no_selection --- data/core/config.lua | 1 + data/core/docview.lua | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/core/config.lua b/data/core/config.lua index 71e83994..a887d579 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -13,6 +13,7 @@ config.undo_merge_timeout = 0.3 config.max_undos = 10000 config.max_tabs = 8 config.always_show_tabs = true +-- Possible values: false, true, "no_selection" config.highlight_current_line = true config.line_height = 1.2 config.indent_size = 2 diff --git a/data/core/docview.lua b/data/core/docview.lua index a4587670..5bed6215 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -331,13 +331,22 @@ end function DocView:draw_line_body(idx, x, y) -- draw highlight if any selection ends on this line local draw_highlight = false - for lidx, line1, col1, line2, col2 in self.doc:get_selections(false) do - if line1 == idx then - draw_highlight = true - break + local hcl = config.highlight_current_line + if hcl ~= false then + for lidx, line1, col1, line2, col2 in self.doc:get_selections(false) do + if line1 == idx then + if hcl == "no_selection" then + if (line1 ~= line2) or (col1 ~= col2) then + draw_highlight = false + break + end + end + draw_highlight = true + break + end end end - if draw_highlight and config.highlight_current_line and core.active_view == self then + if draw_highlight and core.active_view == self then self:draw_line_highlight(x + self.scroll.x, y) end