aboutsummaryrefslogtreecommitdiff
path: root/plugins/dragdropselected.lua
diff options
context:
space:
mode:
authorGuldoman <giulio.lettieri@gmail.com>2023-01-31 23:03:34 +0100
committerGitHub <noreply@github.com>2023-01-31 17:03:34 -0500
commitca40109fb85eca29d7c17c5f5f92808e5ff9fcf6 (patch)
tree5c95875cf162d2ef2afd19ff1a62bb7c2071df3e /plugins/dragdropselected.lua
parentd7dc1806bf2eea33affbbd1a0a7c64141ee99ebf (diff)
downloadlite-xl-plugins-ca40109fb85eca29d7c17c5f5f92808e5ff9fcf6.tar.gz
lite-xl-plugins-ca40109fb85eca29d7c17c5f5f92808e5ff9fcf6.zip
Remove workaround for sorted `Doc:get_selection` issue (#197)
* `dragdropselected`: Replace deprecated `math.pow` with `^` * Remove workaround for sorted `Doc:get_selection` issue Reverts 94f7c8b33371e49d6f026f5be6a41acd73ad9c6b.
Diffstat (limited to 'plugins/dragdropselected.lua')
-rw-r--r--plugins/dragdropselected.lua16
1 files changed, 2 insertions, 14 deletions
diff --git a/plugins/dragdropselected.lua b/plugins/dragdropselected.lua
index 144c4da..8f41ec3 100644
--- a/plugins/dragdropselected.lua
+++ b/plugins/dragdropselected.lua
@@ -14,18 +14,6 @@ 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
@@ -43,7 +31,7 @@ end -- isInSelection
-- distance between two points
local function distance(x1, y1, x2, y2)
- return math.sqrt(math.pow(x2-x1, 2)+math.pow(y2-y1, 2))
+ return math.sqrt((x2-x1)^2+(y2-y1)^2)
end
local min_drag = style.code_font:get_width(" ")
@@ -108,7 +96,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 = get_selection(self.doc, true)
+ local iSelLine1, iSelCol1, iSelLine2, iSelCol2 = self.doc:get_selection(true)
-- set flag for on_mouse_released and on_mouse_moved() methods to detect dragging
self.bClickedIntoSelection = isInSelection(iLine, iCol, iSelLine1, iSelCol1,
iSelLine2, iSelCol2)