aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-11-14 16:27:25 -0500
committerGitHub <noreply@github.com>2021-11-14 16:27:25 -0500
commitca448c5fdbb6cb2d5f87d5955eabb9a3dfdd0e0b (patch)
treebe2ef3446bf1b9f3a340ff6316fcf228f87cb8d0 /data
parent09bf8bab2f0993737c8b49084330f6c19c5c34f8 (diff)
parentb3eef15e7ae5eab34e0e2fc731ddd17f9214149b (diff)
downloadpragtical-ca448c5fdbb6cb2d5f87d5955eabb9a3dfdd0e0b.tar.gz
pragtical-ca448c5fdbb6cb2d5f87d5955eabb9a3dfdd0e0b.zip
Merge pull request #664 from Guldoman/highlight_caret_line
Highlight any line that contains a caret
Diffstat (limited to 'data')
-rw-r--r--data/core/docview.lua21
1 files changed, 12 insertions, 9 deletions
diff --git a/data/core/docview.lua b/data/core/docview.lua
index 4e95c359..6621ef72 100644
--- a/data/core/docview.lua
+++ b/data/core/docview.lua
@@ -354,6 +354,18 @@ function DocView:draw_caret(x, y)
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
+ end
+ end
+ if draw_highlight and config.highlight_current_line and core.active_view == self then
+ self:draw_line_highlight(x + self.scroll.x, y)
+ end
+
-- draw selection if it overlaps this line
for lidx, line1, col1, line2, col2 in self.doc:get_selections(true) do
if idx >= line1 and idx <= line2 then
@@ -368,15 +380,6 @@ function DocView:draw_line_body(idx, x, y)
end
end
end
- local draw_highlight = nil
- for lidx, line1, col1, line2, col2 in self.doc:get_selections(true) do
- -- draw line highlight if caret is on this line
- if draw_highlight ~= false and config.highlight_current_line
- and line1 == idx and core.active_view == self then
- draw_highlight = (line1 == line2 and col1 == col2)
- end
- end
- if draw_highlight then self:draw_line_highlight(x + self.scroll.x, y) end
-- draw line's text
self:draw_line_text(idx, x, y)