-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Upgrade sidebar search #614
Conversation
BhagatHarsh
commented
Feb 12, 2025
•
edited by lazysegtree
Loading
edited by lazysegtree
- Addresses: Search Bar Support in Side Bar #573
- Code improvements in handing sidebar movements
- Code improvements in rendering and operations related to pinned and disk divider in sidebar directories
- Improved render and used pre-rendered strings for efficiency
✅ Deploy Preview for superfile canceled.
|
@BhagatHarsh We have fuzzy search implemented in file panel search. It would be inconsistent if sidebar search is not fuzzy search ![]() ![]() ![]() |
Also make sure to rebase your branch against Just run |
@BhagatHarsh It would be great to keep the same sidebar grouping also on search results ![]() ![]() Sample changes
func getFilteredDirectories(query string) []directory {
directories := []directory{}
directories = append(directories,
getFilteredDirectoriesFromSource(query, getWellKnownDirectories())...)
directories = append(directories, directory{
// Just make sure no one owns the hard drive or directory named this path
location: "Pinned+-*/=?",
})
directories = append(directories,
getFilteredDirectoriesFromSource(query, getPinnedDirectories())...)
directories = append(directories, directory{
// Just make sure no one owns the hard drive or directory named this path
location: "Disks+-*/=?",
})
directories = append(directories,
getFilteredDirectoriesFromSource(query, getExternalMediaFolders())...)
return directories
}
func getFilteredDirectoriesFromSource(query string, source []directory) []directory {
query = strings.ToLower(query)
if query == "" {
return source
}
var filteredDirectories []directory
for _, dir := range source {
if strings.Contains(strings.ToLower(dir.name), query) {
filteredDirectories = append(filteredDirectories, dir)
}
}
return filteredDirectories
}
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@BhagatHarsh maybe dont spend time on fixing any comments for now. Let me send a patch. |
eb49be9
to
c69b2c4
Compare
Some issues identified in testing
|
459188b
to
6bc2257
Compare
@@ -404,135 +410,91 @@ func (m *model) itemSelectDown(wheel bool) { | |||
|
|||
// ======================================== Sidebar controller ======================================== | |||
|
|||
// Yorukot: P.S God bless me, this sidebar controller code is really ugly... |
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.
@yorukot Please check the current code. I have improved it now.
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.
Yes it's really great!!
// Otherwise dividers are sometimes skipped in render in case of | ||
// large pinned directories | ||
s.updateRenderIndex(mainPanelHeight) | ||
if s.directories[s.cursor].isDivider() { |
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.
Since s.noActualDir()
is not true. There definitely are non-Divider normar directories, and code will never get stuck in infinite loop
package internal | ||
|
||
// These are effectively consts | ||
var pinnedDividerDir = 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.
We have used a sentinel value, and we will use it everywhere instead of using "Pinned+-*/=?"
string constant everywhere
location: "Disks+-*/=?", | ||
}) | ||
directories = append(directories, getExternalMediaFolders()...) | ||
func formDirctorySlice(homeDirectories []directory, pinnedDirectories []directory, diskDirectories []directory) []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.
is this checking that no one owns the hard drive or 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.
No, but why do we need 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.
im assuming the original comment is talking about directories belonging to other users or os's , we dont want to display them as a normal directory, theyll need to be specifically displayed as not owned by current user.
@lazysegtree your thoughts?
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.
Let me check this today. I have been wanting to test and understand the disk's part of sidebar, but my mac has no disks. I will try to set something up
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.
@anaypurohit0907 external directories are displayed seperately.
Although we dont do any specific ownership check, we just utilize disk.Partitions
from github.com/shirou/gopsutil/disk
package, and get disk partitions. Additional partitions other then the current partitions of superfile are listed in disks section. Since they are displayed under disk's, we dont need to explicitly tell that "not owned by current user"

Overall I think it's very good,Thanks for you guys! but I think the search bar should be hidden when not in use. Of course, if you think this improvement is not good, please tell me, I am willing to discuss! |
But then how will the user know that this feature exists? |
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.
Sorry my bad :/ I updated to the wrong branch.
9879842
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.
Looks good now. I think we are okay to merge