aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJefferson González <jgmdev@gmail.com>2021-06-11 17:38:36 -0400
committerGitHub <noreply@github.com>2021-06-11 17:38:36 -0400
commita85683d11056bca99f80fce1513c640b6e795d3c (patch)
treed62ac3fccded631d5b608471536f3cac8bd8e5dd /plugins
parent2eb160428bbdefd191e6cee4a58d156fd4dd66c9 (diff)
parent69547591d228a00140889df0b7fccda6e597c8d0 (diff)
downloadlite-xl-plugins-a85683d11056bca99f80fce1513c640b6e795d3c.tar.gz
lite-xl-plugins-a85683d11056bca99f80fce1513c640b6e795d3c.zip
Merge pull request #30 from jgmdev/selectionhighlight-improvement
[selectionhighlight] added option to not highlight empty spaces.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/selectionhighlight.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/selectionhighlight.lua b/plugins/selectionhighlight.lua
index fd10239..93ac0fb 100644
--- a/plugins/selectionhighlight.lua
+++ b/plugins/selectionhighlight.lua
@@ -1,6 +1,7 @@
-- mod-version:1 -- lite-xl 1.16
local style = require "core.style"
local DocView = require "core.docview"
+local config = require "core.config"
-- originally written by luveti
@@ -18,13 +19,16 @@ local draw_line_body = DocView.draw_line_body
function DocView:draw_line_body(idx, x, y)
local line1, col1, line2, col2 = self.doc:get_selection(true)
- if line1 == line2 and col1 ~= col2 then
+ local selection = self.doc:get_text(line1, col1, line2, col2)
+ if line1 == line2 and col1 ~= col2 and not selection:match("^%s+$") then
local lh = self:get_line_height()
local selected_text = self.doc.lines[line1]:sub(col1, col2 - 1)
local current_line_text = self.doc.lines[idx]
local last_col = 1
while true do
- local start_col, end_col = current_line_text:find(selected_text, last_col, true)
+ local start_col, end_col = current_line_text:find(
+ selected_text, last_col, true
+ )
if start_col == nil then break end
local x1 = x + self:get_col_x_offset(idx, start_col)
local x2 = x + self:get_col_x_offset(idx, end_col + 1)