Added find-replace:select-next, bound to ctrl+d by default
This commit is contained in:
parent
044fdb3655
commit
ab8510291e
|
@ -1,7 +1,5 @@
|
||||||
local core = require "core"
|
local core = require "core"
|
||||||
local common = require "core.common"
|
|
||||||
local command = require "core.command"
|
local command = require "core.command"
|
||||||
local config = require "core.config"
|
|
||||||
local search = require "core.doc.search"
|
local search = require "core.doc.search"
|
||||||
local DocView = require "core.docview"
|
local DocView = require "core.docview"
|
||||||
|
|
||||||
|
@ -85,6 +83,20 @@ local function replace(pattern_escape)
|
||||||
end
|
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", {
|
command.add("core.docview", {
|
||||||
["find-replace:find"] = function()
|
["find-replace:find"] = function()
|
||||||
find("Find Text", function(doc, line, col, text)
|
find("Find Text", function(doc, line, col, text)
|
||||||
|
|
|
@ -140,7 +140,7 @@ keymap.add {
|
||||||
["ctrl+shift+return"] = "doc:newline-above",
|
["ctrl+shift+return"] = "doc:newline-above",
|
||||||
["ctrl+j"] = "doc:join-lines",
|
["ctrl+j"] = "doc:join-lines",
|
||||||
["ctrl+a"] = "doc:select-all",
|
["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+l"] = "doc:select-lines",
|
||||||
["ctrl+/"] = "doc:toggle-line-comments",
|
["ctrl+/"] = "doc:toggle-line-comments",
|
||||||
["ctrl+up"] = "doc:move-lines-up",
|
["ctrl+up"] = "doc:move-lines-up",
|
||||||
|
|
Loading…
Reference in a new issue