Added `refresh` command (`f5`) to projectsearch plugin's ResultView

This commit is contained in:
rxi 2020-05-01 19:32:02 +01:00
parent 4ca35fe056
commit a9f3079c90
1 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,7 @@ end
function ResultsView:begin_search(text, fn) function ResultsView:begin_search(text, fn)
self.search_args = { text, fn }
self.results = {} self.results = {}
self.last_file_idx = 1 self.last_file_idx = 1
self.query = text self.query = text
@ -55,7 +56,14 @@ function ResultsView:begin_search(text, fn)
end end
self.searching = false self.searching = false
core.redraw = true core.redraw = true
end, self) end, self.results)
self.scroll.to.y = 0
end
function ResultsView:refresh()
self:begin_search(table.unpack(self.search_args))
end end
@ -245,9 +253,14 @@ command.add(ResultsView, {
["project-search:open-selected"] = function() ["project-search:open-selected"] = function()
core.active_view:open_selected_result() core.active_view:open_selected_result()
end, end,
["project-search:refresh"] = function()
core.active_view:refresh()
end,
}) })
keymap.add { keymap.add {
["f5"] = "project-search:refresh",
["ctrl+shift+f"] = "project-search:find", ["ctrl+shift+f"] = "project-search:find",
["up"] = "project-search:select-previous", ["up"] = "project-search:select-previous",
["down"] = "project-search:select-next", ["down"] = "project-search:select-next",