@@ -91,10 +91,10 @@ class KeyHandler
91
91
public string LongDescription ;
92
92
}
93
93
94
- [ DebuggerDisplay ( "{_buffer }" ) ]
94
+ [ DebuggerDisplay ( "{_line }" ) ]
95
95
class HistoryItem
96
96
{
97
- public StringBuilder _buffer ;
97
+ public string _line ;
98
98
}
99
99
100
100
static KeyHandler MakeKeyHandler ( Action < ConsoleKeyInfo ? , object > action , string briefDescription , string longDescription = null )
@@ -367,7 +367,7 @@ private string MaybeAddToHistory(string result)
367
367
}
368
368
if ( addToHistory )
369
369
{
370
- _history . Enqueue ( new HistoryItem { _buffer = new StringBuilder ( _buffer . ToString ( ) ) } ) ;
370
+ _history . Enqueue ( new HistoryItem { _line = _buffer . ToString ( ) } ) ;
371
371
_currentHistoryIndex = _history . Count ;
372
372
}
373
373
if ( _demoMode )
@@ -381,15 +381,15 @@ private void HistoryOnEnqueueHandler(HistoryItem obj)
381
381
{
382
382
if ( _historyNoDuplicates )
383
383
{
384
- _hashedHistory . Add ( obj . _buffer . ToString ( ) ) ;
384
+ _hashedHistory . Add ( obj . _line ) ;
385
385
}
386
386
}
387
387
388
388
private void HistoryOnDequeueHandler ( HistoryItem obj )
389
389
{
390
390
if ( _historyNoDuplicates )
391
391
{
392
- _hashedHistory . Remove ( obj . _buffer . ToString ( ) ) ;
392
+ _hashedHistory . Remove ( obj . _line ) ;
393
393
}
394
394
}
395
395
@@ -492,7 +492,7 @@ private PSConsoleReadLine()
492
492
_chordDispatchTable = new Dictionary < ConsoleKeyInfo , Dictionary < ConsoleKeyInfo , KeyHandler > > ( ) ;
493
493
494
494
_buffer = new StringBuilder ( ) ;
495
- _savedCurrentLine = new HistoryItem { _buffer = new StringBuilder ( ) } ;
495
+ _savedCurrentLine = new HistoryItem ( ) ;
496
496
497
497
_tokenForegroundColors = new ConsoleColor [ ( int ) TokenClassification . Member + 1 ] ;
498
498
_tokenBackgroundColors = new ConsoleColor [ _tokenForegroundColors . Length ] ;
@@ -860,11 +860,11 @@ public static void ClearHistory()
860
860
861
861
private void UpdateFromHistory ( bool moveCursor )
862
862
{
863
- var buffer = ( _currentHistoryIndex == _history . Count )
864
- ? _savedCurrentLine . _buffer
865
- : _history [ _currentHistoryIndex ] . _buffer ;
863
+ var line = ( _currentHistoryIndex == _history . Count )
864
+ ? _savedCurrentLine . _line
865
+ : _history [ _currentHistoryIndex ] . _line ;
866
866
_buffer . Clear ( ) ;
867
- _buffer . Append ( buffer ) ;
867
+ _buffer . Append ( line ) ;
868
868
if ( moveCursor )
869
869
{
870
870
_current = _buffer . Length ;
@@ -876,8 +876,7 @@ private void SaveCurrentLine()
876
876
{
877
877
if ( _singleton . _currentHistoryIndex == _history . Count )
878
878
{
879
- _savedCurrentLine . _buffer . Clear ( ) ;
880
- _savedCurrentLine . _buffer . Append ( _buffer . ToString ( ) ) ;
879
+ _savedCurrentLine . _line = _buffer . ToString ( ) ;
881
880
}
882
881
}
883
882
@@ -918,7 +917,7 @@ private void HistorySearch(bool backward)
918
917
int incr = backward ? - 1 : + 1 ;
919
918
for ( int i = _currentHistoryIndex + incr ; i >= 0 && i < _history . Count ; i += incr )
920
919
{
921
- if ( _history [ i ] . _buffer . ToString ( ) . StartsWith ( _searchHistoryPrefix ) )
920
+ if ( _history [ i ] . _line . StartsWith ( _searchHistoryPrefix ) )
922
921
{
923
922
_currentHistoryIndex = i ;
924
923
UpdateFromHistory ( moveCursor : _historySearchCursorMovesToEnd ) ;
@@ -1995,7 +1994,7 @@ private void SetOptionsInternal(SetPSReadlineOption options)
1995
1994
while ( _history . Count > 0 )
1996
1995
{
1997
1996
var item = _history . Dequeue ( ) ;
1998
- var itemStr = item . _buffer . ToString ( ) ;
1997
+ var itemStr = item . _line ;
1999
1998
if ( ! _hashedHistory . Contains ( itemStr ) )
2000
1999
{
2001
2000
newHistory . Enqueue ( item ) ;
0 commit comments