diff --git a/PSReadLine/Cmdlets.cs b/PSReadLine/Cmdlets.cs index ca865615..63d352ea 100644 --- a/PSReadLine/Cmdlets.cs +++ b/PSReadLine/Cmdlets.cs @@ -83,14 +83,6 @@ public SwitchParameter HistorySearchCursorMovesToEnd } internal SwitchParameter? _historySearchCursorMovesToEnd; - [Parameter(ParameterSetName = "OptionsSet")] - public int MinimumHistoryCommandLength - { - get { return _minimumHistoryCommandLength.GetValueOrDefault(); } - set { _minimumHistoryCommandLength = value; } - } - internal int? _minimumHistoryCommandLength; - [Parameter(ParameterSetName = "OptionsSet")] public int MaximumHistoryCount { diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs index a3e658cc..dbfa588d 100644 --- a/PSReadLine/ReadLine.cs +++ b/PSReadLine/ReadLine.cs @@ -175,13 +175,6 @@ static KeyHandler MakeKeyHandler(Action action, string /// private Func _addToHistoryHandler; - /// - /// Commands shorter than MinimumHistoryCommandLength will not be added - /// to the history. - /// - public const int DefaultMinimumHistoryCommandLength = 4; - private int _minimumHistoryCommandLength; - /// /// When true, duplicates will not be added to the history. /// @@ -335,11 +328,7 @@ void ProcessOneKey(ConsoleKeyInfo key, Dictionary di private string MaybeAddToHistory(string result) { - bool addToHistory = (result.Length >= _minimumHistoryCommandLength); - if (addToHistory && _addToHistoryHandler != null) - { - addToHistory = _addToHistoryHandler(result); - } + bool addToHistory = (_addToHistoryHandler == null) || _addToHistoryHandler(result); if (addToHistory && _historyNoDuplicates) { // REVIEW: should history be case sensitive - it is now. @@ -458,7 +447,6 @@ private PSConsoleReadLine() _continuationPromptForegroundColor = DefaultContinuationPromptForegroundColor; _continuationPromptBackgroundColor = DefaultContinuationPromptBackgroundColor; - _minimumHistoryCommandLength = DefaultMinimumHistoryCommandLength; _addToHistoryHandler = null; _historyNoDuplicates = DefaultHistoryNoDuplicates; _maximumHistoryCount = DefaultMaximumHistoryCount; @@ -1791,21 +1779,6 @@ private void SetOptionsInternal(SetPSReadlineOption options) { _addToHistoryHandler = options.AddToHistoryHandler; } - if (options._minimumHistoryCommandLength.HasValue) - { - _minimumHistoryCommandLength = options.MinimumHistoryCommandLength; - var newHistory = new HistoryQueue(_maximumHistoryCount); - while (_history.Count > 0) - { - var item = _history.Dequeue(); - if (item.Length >= _minimumHistoryCommandLength) - { - newHistory.Enqueue(item); - } - } - _history = newHistory; - _currentHistoryIndex = _history.Count; - } if (options._maximumHistoryCount.HasValue) { _maximumHistoryCount = options.MaximumHistoryCount; diff --git a/UnitTestPSReadLine/UnitTestReadLine.cs b/UnitTestPSReadLine/UnitTestReadLine.cs index d4095263..69d2a6f3 100644 --- a/UnitTestPSReadLine/UnitTestReadLine.cs +++ b/UnitTestPSReadLine/UnitTestReadLine.cs @@ -453,7 +453,6 @@ private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers) { AddToHistoryHandler = null, HistoryNoDuplicates = PSConsoleReadLine.DefaultHistoryNoDuplicates, - MinimumHistoryCommandLength = PSConsoleReadLine.DefaultMinimumHistoryCommandLength, MaximumHistoryCount = PSConsoleReadLine.DefaultMaximumHistoryCount, MaximumKillRingCount = PSConsoleReadLine.DefaultMaximumKillRingCount, ResetTokenColors = true, @@ -886,26 +885,6 @@ public void TestHistoryDuplicates() result = Test(keys5); Assert.AreEqual("aaaa", result); } - [TestMethod] - public void TestHistoryMinimumCommandLength() - { - TestSetup(KeyMode.Cmd); - PSConsoleReadLine.SetOptions(new SetPSReadlineOption {MinimumHistoryCommandLength = 6}); - - var keys = new [] {_.A, _.B, _.C, _.D, _.E, _.F, _.G, _.H, _.Enter}; - var result = Test(keys); Assert.AreEqual("abcdefgh", result); - keys = new [] {_.A, _.B, _.C, _.D, _.E, _.F, _.Enter}; - result = Test(keys); Assert.AreEqual("abcdef", result); - keys = new [] {_.A, _.B, _.C, _.D, _.E, _.Enter}; - result = Test(keys); Assert.AreEqual("abcde", result); - keys = new [] {_.UpArrow, _.Enter}; - result = Test(keys); Assert.AreEqual("abcdef", result); - - PSConsoleReadLine.SetOptions(new SetPSReadlineOption {MinimumHistoryCommandLength = 7}); - keys = new [] {_.UpArrow, _.Enter}; - result = Test(keys); Assert.AreEqual("abcdefgh", result); - } - [TestMethod] public void TestHistoryCount() { @@ -1419,7 +1398,6 @@ public void TestUselessStuffForBetterCoverage() + options.HistorySearchCursorMovesToEnd.GetHashCode() + options.MaximumHistoryCount.GetHashCode() + options.MaximumKillRingCount.GetHashCode() - + options.MinimumHistoryCommandLength.GetHashCode() + options.DingDuration.GetHashCode() + options.DingTone.GetHashCode() + options.BellStyle.GetHashCode()