Added find-replace:select-next, bound to ctrl+d by default

This commit is contained in:
rxi 2020-05-01 10:21:57 +01:00
parent 044fdb3655
commit ab8510291e
2 changed files with 15 additions and 3 deletions

View File

@ -1,7 +1,5 @@
local core = require "core"
local common = require "core.common"
local command = require "core.command"
local config = require "core.config"
local search = require "core.doc.search"
local DocView = require "core.docview"
@ -85,6 +83,20 @@ local function replace(pattern_escape)
end
local function has_selection()
return core.active_view:is(DocView)
and core.active_view.doc:has_selection()
end
command.add(has_selection, {
["find-replace:select-next"] = function()
local l1, c1, l2, c2 = doc():get_selection(true)
local text = doc():get_text(l1, c1, l2, c2)
local l1, c1, l2, c2 = search.find(doc(), l2, c2, text, { wrap = true })
doc():set_selection(l2, c2, l1, c1)
end
})
command.add("core.docview", {
["find-replace:find"] = function()
find("Find Text", function(doc, line, col, text)

View File

@ -140,7 +140,7 @@ keymap.add {
["ctrl+shift+return"] = "doc:newline-above",
["ctrl+j"] = "doc:join-lines",
["ctrl+a"] = "doc:select-all",
["ctrl+d"] = "doc:select-word",
["ctrl+d"] = { "find-replace:select-next", "doc:select-word" },
["ctrl+l"] = "doc:select-lines",
["ctrl+/"] = "doc:toggle-line-comments",
["ctrl+up"] = "doc:move-lines-up",