aboutsummaryrefslogtreecommitdiff
path: root/plugins/dragdropselected.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dragdropselected.lua')
-rw-r--r--plugins/dragdropselected.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/dragdropselected.lua b/plugins/dragdropselected.lua
index 3c6583b..144c4da 100644
--- a/plugins/dragdropselected.lua
+++ b/plugins/dragdropselected.lua
@@ -14,6 +14,18 @@ local core = require "core"
local keymap = require "core.keymap"
local style = require "core.style"
+-- Workaround for bug in Lite XL 2.1
+-- Remove this when b029f5993edb7dee5ccd2ba55faac1ec22e24609 is in a release
+local function get_selection(doc, sort)
+ local line1, col1, line2, col2 = doc:get_selection_idx(doc.last_selection)
+ if line1 then
+ return doc:get_selection_idx(doc.last_selection, sort)
+ else
+ return doc:get_selection_idx(1, sort)
+ end
+end
+
+
-- helper function for on_mouse_pressed to determine if mouse down is in selection
-- iLine is line number where mouse down happened
-- iCol is column where mouse down happened
@@ -96,7 +108,7 @@ function DocView:on_mouse_pressed(button, x, y, clicks)
-- convert pixel coordinates to line and column coordinates
local iLine, iCol = self:resolve_screen_position(x, y)
-- get selection coordinates
- local iSelLine1, iSelCol1, iSelLine2, iSelCol2 = self.doc:get_selection(true)
+ local iSelLine1, iSelCol1, iSelLine2, iSelCol2 = get_selection(self.doc, true)
-- set flag for on_mouse_released and on_mouse_moved() methods to detect dragging
self.bClickedIntoSelection = isInSelection(iLine, iCol, iSelLine1, iSelCol1,
iSelLine2, iSelCol2)