File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ private void ClearSavedCurrentLine()
140140 _savedCurrentLine . _editGroupStart = - 1 ;
141141 }
142142
143- private AddToHistoryOption GetAddToHistoryOption ( string line )
143+ private AddToHistoryOption GetAddToHistoryOption ( string line , bool fromHistoryFile )
144144 {
145145 // Whitespace only is useless, never add.
146146 if ( string . IsNullOrWhiteSpace ( line ) )
@@ -155,7 +155,7 @@ private AddToHistoryOption GetAddToHistoryOption(string line)
155155 return AddToHistoryOption . SkipAdding ;
156156 }
157157
158- if ( Options . AddToHistoryHandler != null )
158+ if ( ! fromHistoryFile && Options . AddToHistoryHandler != null )
159159 {
160160 if ( Options . AddToHistoryHandler == PSConsoleReadLineOptions . DefaultAddToHistoryHandler )
161161 {
@@ -204,10 +204,11 @@ private string MaybeAddToHistory(
204204 bool fromDifferentSession = false ,
205205 bool fromInitialRead = false )
206206 {
207- var addToHistoryOption = GetAddToHistoryOption ( result ) ;
207+ bool fromHistoryFile = fromDifferentSession || fromInitialRead ;
208+ var addToHistoryOption = GetAddToHistoryOption ( result , fromHistoryFile ) ;
209+
208210 if ( addToHistoryOption != AddToHistoryOption . SkipAdding )
209211 {
210- var fromHistoryFile = fromDifferentSession || fromInitialRead ;
211212 _previousHistoryItem = new HistoryItem
212213 {
213214 CommandLine = result ,
You can’t perform that action at this time.
0 commit comments