Plugin projectsearch: set command view text to current document selection.
This commit is contained in:
parent
b02aae939c
commit
2079e1f707
|
@ -229,8 +229,21 @@ local function begin_search(text, fn)
|
|||
end
|
||||
|
||||
|
||||
local function set_command_view_text()
|
||||
local view = core.active_view
|
||||
local doc = (view and view.doc) and view.doc or nil
|
||||
if doc then
|
||||
core.command_view:set_text(
|
||||
doc:get_text(table.unpack({ doc:get_selection() })),
|
||||
true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
command.add(nil, {
|
||||
["project-search:find"] = function()
|
||||
set_command_view_text()
|
||||
core.command_view:enter("Find Text In Project", function(text)
|
||||
text = text:lower()
|
||||
begin_search(text, function(line_text)
|
||||
|
@ -249,6 +262,7 @@ command.add(nil, {
|
|||
end,
|
||||
|
||||
["project-search:fuzzy-find"] = function()
|
||||
set_command_view_text()
|
||||
core.command_view:enter("Fuzzy Find Text In Project", function(text)
|
||||
begin_search(text, function(line_text)
|
||||
return common.fuzzy_match(line_text, text) and 1
|
||||
|
|
Loading…
Reference in New Issue