aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-06-04 13:57:27 +0100
committerrxi <rxi@users.noreply.github.com>2020-06-04 14:04:46 +0100
commitbd0644a5bb95f85e0d11c87ebdfd61c8fd82fae8 (patch)
tree9d4ac6cb0ea674bc73f8936888434eb5ad790d57
parent3569abcb53dc756668791f1e3df80700255495e5 (diff)
downloadpragtical-bd0644a5bb95f85e0d11c87ebdfd61c8fd82fae8.tar.gz
pragtical-bd0644a5bb95f85e0d11c87ebdfd61c8fd82fae8.zip
Added resetting of selection on intermediate find-text failure
-rw-r--r--data/core/commands/findreplace.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/data/core/commands/findreplace.lua b/data/core/commands/findreplace.lua
index e3e31a37..937c410a 100644
--- a/data/core/commands/findreplace.lua
+++ b/data/core/commands/findreplace.lua
@@ -45,23 +45,24 @@ local function find(label, search_fn)
else
core.error("Couldn't find %q", text)
dv.doc:set_selection(table.unpack(sel))
+ dv:scroll_to_make_visible(sel[1], sel[2])
end
end, function(text)
local ok, line1, col1, line2, col2 = pcall(search_fn, dv.doc, sel[1], sel[2], text)
- if text == "" then
- dv.doc:set_selection(table.unpack(sel))
- elseif ok and line1 then
+ if ok and line1 and text ~= "" then
dv.doc:set_selection(line2, col2, line1, col1)
dv:scroll_to_line(line2, true)
found = true
else
+ dv.doc:set_selection(table.unpack(sel))
found = false
end
end, function(explicit)
if explicit then
dv.doc:set_selection(table.unpack(sel))
+ dv:scroll_to_make_visible(sel[1], sel[2])
end
end)
end