find files - display result count

This commit is contained in:
Matt Parker
2025-10-13 19:54:15 +10:00
parent 207b8fe3c8
commit 8f64f2266e
3 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,4 @@
using OneOf; using SharpIDE.Application.Features.SolutionDiscovery;
using SharpIDE.Application.Features.SolutionDiscovery;
namespace SharpIDE.Application.Features.Search; namespace SharpIDE.Application.Features.Search;

View File

@@ -6,6 +6,7 @@ namespace SharpIDE.Godot.Features.Search.SearchAllFiles;
public partial class SearchAllFilesWindow : PopupPanel public partial class SearchAllFilesWindow : PopupPanel
{ {
private Label _resultCountLabel = null!;
private LineEdit _lineEdit = null!; private LineEdit _lineEdit = null!;
private VBoxContainer _searchResultsContainer = null!; private VBoxContainer _searchResultsContainer = null!;
public SharpIdeSolutionModel Solution { get; set; } = null!; public SharpIdeSolutionModel Solution { get; set; } = null!;
@@ -15,6 +16,7 @@ public partial class SearchAllFilesWindow : PopupPanel
public override void _Ready() public override void _Ready()
{ {
_resultCountLabel = GetNode<Label>("%ResultCountLabel");
_lineEdit = GetNode<LineEdit>("%SearchLineEdit"); _lineEdit = GetNode<LineEdit>("%SearchLineEdit");
_lineEdit.Text = ""; _lineEdit.Text = "";
_searchResultsContainer = GetNode<VBoxContainer>("%SearchResultsVBoxContainer"); _searchResultsContainer = GetNode<VBoxContainer>("%SearchResultsVBoxContainer");
@@ -41,6 +43,7 @@ public partial class SearchAllFilesWindow : PopupPanel
private async Task Search(string text, CancellationToken cancellationToken) private async Task Search(string text, CancellationToken cancellationToken)
{ {
var result = await SearchService.FindFiles(Solution, text, cancellationToken); var result = await SearchService.FindFiles(Solution, text, cancellationToken);
if (cancellationToken.IsCancellationRequested) return;
await this.InvokeAsync(() => await this.InvokeAsync(() =>
{ {
_searchResultsContainer.GetChildren().ToList().ForEach(s => s.QueueFree()); _searchResultsContainer.GetChildren().ToList().ForEach(s => s.QueueFree());
@@ -51,6 +54,7 @@ public partial class SearchAllFilesWindow : PopupPanel
resultNode.ParentSearchAllFilesWindow = this; resultNode.ParentSearchAllFilesWindow = this;
_searchResultsContainer.AddChild(resultNode); _searchResultsContainer.AddChild(resultNode);
} }
_resultCountLabel.Text = $"{result.Count} files(s) found";
}); });
} }
} }

View File

@@ -46,7 +46,8 @@ layout_mode = 2
layout_mode = 2 layout_mode = 2
text = "Find Files" text = "Find Files"
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"] [node name="ResultCountLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
theme_override_font_sizes/font_size = 14 theme_override_font_sizes/font_size = 14
text = " 30 matching files" text = " 30 matching files"