Skip to content

Commit

Permalink
Fuzzy finder (#1393)
Browse files Browse the repository at this point in the history
* Added a fuzzy search modal

* Fixed indent

* Use accent color for selection

* Listen to git change

* Use async fuzzy finder and ignore paths from .gitignore

* Resize dialog

* Added scrolling by up/down arrows

* Check project content on each search to get all changes

* Add basic debouncing and cancellation for each search query

* Add cancellable checks to all loops during fuzzy search

* Increase fuzzy search results update speed

* Fix long delay before fuzzy finder dialog opens

- Fuzzy finder paths indexed when plugin is activated
- Fuzy finder dialog now opens instantly

* Fix vala-lint errors in fuzzy-search plugin directory

* Prevent fuzzy search dialog from opening if there are no projects opened

* Clicking on fuzzy search results loads the clicked result

* Fuzzy search results across multiple projects are disambiguated using the project name before file path

* Update fuzzy search debug logs

* Improve Fuzzy Search Accuracy

- Combine file name and file paths in fuzzy finder

* Ignore dot-prefixed directories in fuzzy search

* Update debug messaging for fuzzy search

* Fix code style warnings in fuzzy search plugin

* Update license and copyright info for Fuzzy Finder plugin

* Add end method to project path parsing async call

* Fix vala-lint errors

* Improve fuzzy matching

- Fix issue how matches are added to list of matches
- Stop using a combined score. Prefer filename based matches when available
- Stop including directory separator in separator bonus

* Change fuzzy search keyboard shortcut to 'ALT + F'

* Remove unused GitManager signals

* Files that cannot be opened in Code are filtered out of fuzzy search

* Render fuzzy search items with list boxes

* Add mouser hover styling to fuzzy search items

* Handle Fuzzy Search key presses with EventControllerKey

* Now using popover to show fuzzy search

* Add title label to fuzzy search popover

* Remove unused window size and positining code

* Prevent focus on fuzzy item results

* Fuzzy search results for current project are prioritised

* Expose fuzzy find function and accelerator in sidebar action menu (#1395)

* Add Fuzzy Find menuitem to sidebar

* Consistently use "Find Project Files"

* Move SearchProject to separate file

* Fix lint

* Remove menuitem on deactivation of "Find Project Files" plugin

* Associate popover with foldermanager (#1396)

* Associate popover with foldermanager
* Remove deprecated PopoverConstraint

* Add folder_item_change plugin manager hook in preparation for background indexing

* Allow search project parsing to be cancellable

* Create indexer and add methods for adding and removing files and directories to search project class

* Use fuzzy search indexer for fuzzy search results

* Update indexer debug logs

* Update license info and comments in Fuzzy Search Project

* Remove old fuzzy search indexer testing logs

---------

Co-authored-by: Marvin Ahlgrimm <[email protected]>
Co-authored-by: Jeremy Wootten <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2024
1 parent 344f1f8 commit 5b67e6b
Show file tree
Hide file tree
Showing 19 changed files with 1,391 additions and 17 deletions.
49 changes: 49 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,52 @@ textview.scrubber {
border: 0;
}

.fuzzy-popover {
padding-top: 0.5rem;
padding-bottom: 1rem;
}

.fuzzy-popover entry {
margin-left: 1rem;
margin-right: 1rem;
}

.fuzzy-popover scrolledwindow {
margin-top: 1rem;
}

.fuzzy-list {
background-color: transparent;
}

.fuzzy-item {
padding: 0.5rem;
margin-left: 10px;
margin-right: 10px;
background-color: transparent;
}

.fuzzy-item.preselect-fuzzy,
.fuzzy-item:hover {
border-radius: 0.5rem;
}

.fuzzy-item:hover {
background-color: @theme_unfocused_selected_bg_color;
}

.fuzzy-item.preselect-fuzzy {
background-color: @selected_bg_color;
}

.fuzzy-item .fuzzy-file-icon {
margin-right: 0.5rem;
}

.fuzzy-item label:nth-child(1) {
font-weight: 700;
}

.fuzzy-item.preselect-fuzzy label {
opacity: 0.7;
}
58 changes: 58 additions & 0 deletions plugins/fuzzy-search/file-item.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2023 elementary, Inc. <https://elementary.io>
*
* Authored by: Marvin Ahlgrimm
* Colin Kiama <[email protected]>
*/

public class FileItem : Gtk.ListBoxRow {
private SearchResult result;

public string filepath {
get {
return result.full_path;
}
}
public FileItem (SearchResult res, bool should_distinguish_project = false) {
this.get_style_context ().add_class ("fuzzy-item");
this.get_style_context ().add_class ("flat");

result = res;
Icon icon;
var path_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 1);
path_box.valign = Gtk.Align.CENTER;

var path_label = new Gtk.Label (
@"$(should_distinguish_project ? result.project + "" : "")$(result.relative_path)"
);

path_label.halign = Gtk.Align.START;

var filename_label = new Gtk.Label (Path.get_basename (result.relative_path));
filename_label.halign = Gtk.Align.START;

try {
var fi = File.new_for_path (result.full_path);
var info = fi.query_info ("standard::*", 0);
icon = ContentType.get_icon (info.get_content_type ());
} catch (Error e) {
icon = ContentType.get_icon ("text/plain");
}

var image = new Gtk.Image.from_gicon (icon, Gtk.IconSize.DND);
image.get_style_context ().add_class ("fuzzy-file-icon");

path_box.add (filename_label);
path_box.add (path_label);

var container_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 1) {
valign = Gtk.Align.CENTER
};

container_box.add (image);
container_box.add (path_box);

this.child = container_box;
}
}
Loading

0 comments on commit 5b67e6b

Please sign in to comment.