-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added in simple directory search to treeview. #1110
Added in simple directory search to treeview. #1110
Conversation
data/plugins/projectsearch.lua
Outdated
["project-search:find"] = function() | ||
core.command_view:enter("Find Text In Project", { | ||
["project-search:find"] = function(path) | ||
core.command_view:enter("Find Text In " .. (path or "Project"), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to show path
relative to the current project directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I'll fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I changed this to use paths relative to whichever project directory is the parent project.
data/plugins/projectsearch.lua
Outdated
@@ -332,3 +332,5 @@ keymap.add { | |||
["home"] = "project-search:move-to-start-of-doc", | |||
["end"] = "project-search:move-to-end-of-doc" | |||
} | |||
|
|||
return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return the ResultsView
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd have a table that contains resultsview, that represents the plugin as a whole, like the other plugins. I'll change it to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, seems like most of the core plugins don't bother doing this; so I'll just return to that convention.
if file.type == "file" then | ||
local path = (dir_name == core.project_dir and "" or (dir_name .. PATHSEP)) | ||
find_all_matches_in_file(self.results, path .. file.filename, fn) | ||
if file.type == "file" and (not path or (dir_name .. "/" .. file.filename):find(path, 1, true) == 1) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work too?
if file.type == "file" and (not path or (dir_name .. "/" .. file.filename):find(path, 1, true) == 1) then | |
if file.type == "file" and (not path or (dir_name .. "/"):find(path, 1, true) == 1) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, no, checked this; dir_name is the project path, file.filename is the subsequent path. We'll need the whole thing to check.
Strange way of naming things, really, but I think it's outside scope to fundamentally change the naming convention.
data/plugins/treeview.lua
Outdated
@@ -819,6 +819,22 @@ command.add(function() | |||
end | |||
}) | |||
|
|||
local projectsearch = core.try(require, "plugins.projectsearch") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC core.try
creates an error log entry on fail, so it might be better to use pcall
directly here.
We should probably add an optional require
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right a third time, I'll put it as pcall for now.
…ectsearch to use relative names.
OK, should be good. |
Tested and so far is working nicely! merging.... |
Changed projectsearch to allow for searching only particular sub-directories (I tend to have large, multiple directory projects), and this massively cuts down on what I have to search.
Thoughts?