aboutsummaryrefslogtreecommitdiff
path: root/plugins/regexreplacepreview.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/regexreplacepreview.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/regexreplacepreview.lua')
-rw-r--r--plugins/regexreplacepreview.lua16
1 files changed, 2 insertions, 14 deletions
diff --git a/plugins/regexreplacepreview.lua b/plugins/regexreplacepreview.lua
index 7675d54..a0d416e 100644
--- a/plugins/regexreplacepreview.lua
+++ b/plugins/regexreplacepreview.lua
@@ -65,18 +65,6 @@ local function substitute(pattern_string, str, replacement)
return table.concat(result) .. str:sub(offset), matches, replacements
end
--- 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
-
-
-- Takes the following pattern: /pattern/replace/
-- Capture groupings can be replaced using \1 through \9
local function regex_replace_file(view, pattern, old_lines, raw, start_line, end_line)
@@ -165,8 +153,8 @@ command.add("core.docview!", {
["regex-replace-preview:find-replace-regex"] = function(view)
local old_lines = {}
local doc = view.doc
- local original_selection = { get_selection(doc, true) }
- local selection = doc:has_selection() and { get_selection(doc, true) } or {}
+ local original_selection = { doc:get_selection(true) }
+ local selection = doc:has_selection() and { doc:get_selection(true) } or {}
core.command_view:enter("Regex Replace (enter pattern as /old/new/)", {
text = "/",
submit = function(pattern)