Skip to content

Commit

Permalink
Fix-folder-search-filtering-1198 (#1379)
Browse files Browse the repository at this point in the history
* Folder search is now scoped to selected folder

* Fixes #1198
  • Loading branch information
colinkiama committed Nov 21, 2023
1 parent 6ee2b1f commit 51dd521
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/FolderManager/FileView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ public class Scratch.FolderManager.FileView : Granite.Widgets.SourceList, Code.P
if (item_for_path != null) {
var search_root = item_for_path.get_root_folder ();
if (search_root is ProjectFolderItem) {
search_root.global_search (search_root.file.file, term);
GLib.File start_folder = (item_for_path is FolderItem)
? item_for_path.file.file
: search_root.file.file;

bool is_explicit = !(item_for_path is ProjectFolderItem);
search_root.global_search (start_folder, term, is_explicit);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/FolderManager/ProjectFolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ namespace Scratch.FolderManager {
return is_git_repo ? monitored_repo.is_valid_new_local_branch_name (new_name) : false;
}

public void global_search (GLib.File start_folder = this.file.file, string? term = null) {
public void global_search (
GLib.File start_folder = this.file.file,
string? term = null,
bool is_explicit = false
) {
/* For now set all options to the most inclusive (except case).
* The ability to set these in the dialog (or by parameter) may be added later. */
string? search_term = null;
Expand Down Expand Up @@ -410,7 +414,7 @@ namespace Scratch.FolderManager {
remove_all_badges ();
collapse_all ();

if (monitored_repo != null) {
if (monitored_repo != null && !is_explicit) {
try {
monitored_repo.git_repo.file_status_foreach (status_options, (rel_path, status) => {
var target = file.file.resolve_relative_path (rel_path);
Expand Down

0 comments on commit 51dd521

Please sign in to comment.