diff --git a/Terminal.Gui/Windows/FileDialog2.cs b/Terminal.Gui/Windows/FileDialog2.cs
index a1c9f278d..b3e162046 100644
--- a/Terminal.Gui/Windows/FileDialog2.cs
+++ b/Terminal.Gui/Windows/FileDialog2.cs
@@ -25,6 +25,16 @@ namespace Terminal.Gui {
private const string HeaderModified = "Modified";
private const string HeaderType = "Type";
+ ///
+ /// The maximum number of results that will be collected
+ /// when searching before stopping.
+ ///
+ ///
+ /// This prevents performance issues e.g. when searching
+ /// root of file system for a common letter (e.g. 'e').
+ ///
+ public int MaxSearchResults {get;set;} = 10000;
+
///
/// 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;