Use correct view for scrolling to `find-replace:repeat-find` results (#1400)
This commit is contained in:
parent
067271bc02
commit
95611366bb
|
@ -240,34 +240,38 @@ command.add("core.docview!", {
|
||||||
})
|
})
|
||||||
|
|
||||||
local function valid_for_finding()
|
local function valid_for_finding()
|
||||||
return core.active_view:is(DocView) or core.active_view:is(CommandView)
|
-- Allow using this while in the CommandView
|
||||||
|
if core.active_view:is(CommandView) and last_view then
|
||||||
|
return true, last_view
|
||||||
|
end
|
||||||
|
return core.active_view:is(DocView), core.active_view
|
||||||
end
|
end
|
||||||
|
|
||||||
command.add(valid_for_finding, {
|
command.add(valid_for_finding, {
|
||||||
["find-replace:repeat-find"] = function()
|
["find-replace:repeat-find"] = function(dv)
|
||||||
if not last_fn then
|
if not last_fn then
|
||||||
core.error("No find to continue from")
|
core.error("No find to continue from")
|
||||||
else
|
else
|
||||||
local sl1, sc1, sl2, sc2 = doc():get_selection(true)
|
local sl1, sc1, sl2, sc2 = dv.doc:get_selection(true)
|
||||||
local line1, col1, line2, col2 = last_fn(doc(), sl1, sc2, last_text, case_sensitive, find_regex, false)
|
local line1, col1, line2, col2 = last_fn(dv.doc, sl1, sc2, last_text, case_sensitive, find_regex, false)
|
||||||
if line1 then
|
if line1 then
|
||||||
doc():set_selection(line2, col2, line1, col1)
|
dv.doc:set_selection(line2, col2, line1, col1)
|
||||||
last_view:scroll_to_line(line2, true)
|
dv:scroll_to_line(line2, true)
|
||||||
else
|
else
|
||||||
core.error("Couldn't find %q", last_text)
|
core.error("Couldn't find %q", last_text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["find-replace:previous-find"] = function()
|
["find-replace:previous-find"] = function(dv)
|
||||||
if not last_fn then
|
if not last_fn then
|
||||||
core.error("No find to continue from")
|
core.error("No find to continue from")
|
||||||
else
|
else
|
||||||
local sl1, sc1, sl2, sc2 = doc():get_selection(true)
|
local sl1, sc1, sl2, sc2 = dv.doc:get_selection(true)
|
||||||
local line1, col1, line2, col2 = last_fn(doc(), sl1, sc1, last_text, case_sensitive, find_regex, true)
|
local line1, col1, line2, col2 = last_fn(dv.doc, sl1, sc1, last_text, case_sensitive, find_regex, true)
|
||||||
if line1 then
|
if line1 then
|
||||||
doc():set_selection(line2, col2, line1, col1)
|
dv.doc:set_selection(line2, col2, line1, col1)
|
||||||
last_view:scroll_to_line(line2, true)
|
dv:scroll_to_line(line2, true)
|
||||||
else
|
else
|
||||||
core.error("Couldn't find %q", last_text)
|
core.error("Couldn't find %q", last_text)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue