Don't add more than 10000 search results

This commit is contained in:
Thomas
2023-03-04 07:56:44 +00:00
parent 4cc0c3a9ef
commit f670cc831f

View File

@@ -25,6 +25,16 @@ namespace Terminal.Gui {
private const string HeaderModified = "Modified";
private const string HeaderType = "Type";
/// <summary>
/// The maximum number of results that will be collected
/// when searching before stopping.
/// </summary>
/// <remarks>
/// This prevents performance issues e.g. when searching
/// root of file system for a common letter (e.g. 'e').
/// </remarks>
public int MaxSearchResults {get;set;} = 10000;
/// <summary>
/// True if the file/folder must exist already to be selected.
/// This prevents user from entering the name of something that
@@ -1444,6 +1454,12 @@ namespace Terminal.Gui {
if (f.Name.Contains (searchTerms)) {
lock (oLockFound) {
found.Add (f);
if(found.Count >= Parent.MaxSearchResults)
{
finished = true;
return;
}
}
}
@@ -1567,7 +1583,7 @@ namespace Terminal.Gui {
}
}
internal class SpinnerLabel : Label {
private Rune [] runes = new Rune [] { '|', '/', '\u2500', '/', '\u2500', '\\' };
private Rune [] runes = new Rune [] { '|', '/', '\u2500', '\\'};
private int currentIdx = 0;
private DateTime lastRender = DateTime.MinValue;