Add `find-replace:select-previous`
This commit is contained in:
parent
56eace627a
commit
e7be9652c9
|
@ -142,7 +142,7 @@ local function is_in_any_selection(line, col)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function select_next(all)
|
local function select_add_next(all)
|
||||||
local il1, ic1 = doc():get_selection(true)
|
local il1, ic1 = doc():get_selection(true)
|
||||||
for idx, l1, c1, l2, c2 in doc():get_selections(true, true) do
|
for idx, l1, c1, l2, c2 in doc():get_selections(true, true) do
|
||||||
local text = doc():get_text(l1, c1, l2, c2)
|
local text = doc():get_text(l1, c1, l2, c2)
|
||||||
|
@ -161,15 +161,22 @@ local function select_next(all)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
command.add(has_unique_selection, {
|
local function select_next(reverse)
|
||||||
["find-replace:select-next"] = function()
|
|
||||||
local l1, c1, l2, c2 = doc():get_selection(true)
|
local l1, c1, l2, c2 = doc():get_selection(true)
|
||||||
local text = doc():get_text(l1, c1, l2, c2)
|
local text = doc():get_text(l1, c1, l2, c2)
|
||||||
|
if reverse then
|
||||||
|
l1, c1, l2, c2 = search.find(doc(), l1, c1, text, { wrap = true, reverse = true })
|
||||||
|
else
|
||||||
l1, c1, l2, c2 = search.find(doc(), l2, c2, text, { wrap = true })
|
l1, c1, l2, c2 = search.find(doc(), l2, c2, text, { wrap = true })
|
||||||
|
end
|
||||||
if l2 then doc():set_selection(l2, c2, l1, c1) end
|
if l2 then doc():set_selection(l2, c2, l1, c1) end
|
||||||
end,
|
end
|
||||||
["find-replace:select-add-next"] = function() select_next(false) end,
|
|
||||||
["find-replace:select-add-all"] = function() select_next(true) end
|
command.add(has_unique_selection, {
|
||||||
|
["find-replace:select-next"] = select_next,
|
||||||
|
["find-replace:select-previous"] = function() select_next(true) end,
|
||||||
|
["find-replace:select-add-next"] = select_add_next,
|
||||||
|
["find-replace:select-add-all"] = function() select_add_next(true) end
|
||||||
})
|
})
|
||||||
|
|
||||||
command.add("core.docview", {
|
command.add("core.docview", {
|
||||||
|
|
|
@ -170,6 +170,7 @@ keymap.add_direct {
|
||||||
["ctrl+a"] = "doc:select-all",
|
["ctrl+a"] = "doc:select-all",
|
||||||
["ctrl+d"] = { "find-replace:select-add-next", "doc:select-word" },
|
["ctrl+d"] = { "find-replace:select-add-next", "doc:select-word" },
|
||||||
["ctrl+f3"] = "find-replace:select-next",
|
["ctrl+f3"] = "find-replace:select-next",
|
||||||
|
["ctrl+shift+f3"] = "find-replace:select-previous",
|
||||||
["ctrl+l"] = "doc:select-lines",
|
["ctrl+l"] = "doc:select-lines",
|
||||||
["ctrl+shift+l"] = { "find-replace:select-add-all", "doc:select-word" },
|
["ctrl+shift+l"] = { "find-replace:select-add-all", "doc:select-word" },
|
||||||
["ctrl+/"] = "doc:toggle-line-comments",
|
["ctrl+/"] = "doc:toggle-line-comments",
|
||||||
|
|
Loading…
Reference in New Issue