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()
140
140
_savedCurrentLine . _editGroupStart = - 1 ;
141
141
}
142
142
143
- private AddToHistoryOption GetAddToHistoryOption ( string line )
143
+ private AddToHistoryOption GetAddToHistoryOption ( string line , bool fromHistoryFile )
144
144
{
145
145
// Whitespace only is useless, never add.
146
146
if ( string . IsNullOrWhiteSpace ( line ) )
@@ -155,7 +155,7 @@ private AddToHistoryOption GetAddToHistoryOption(string line)
155
155
return AddToHistoryOption . SkipAdding ;
156
156
}
157
157
158
- if ( Options . AddToHistoryHandler != null )
158
+ if ( ! fromHistoryFile && Options . AddToHistoryHandler != null )
159
159
{
160
160
if ( Options . AddToHistoryHandler == PSConsoleReadLineOptions . DefaultAddToHistoryHandler )
161
161
{
@@ -204,10 +204,11 @@ private string MaybeAddToHistory(
204
204
bool fromDifferentSession = false ,
205
205
bool fromInitialRead = false )
206
206
{
207
- var addToHistoryOption = GetAddToHistoryOption ( result ) ;
207
+ bool fromHistoryFile = fromDifferentSession || fromInitialRead ;
208
+ var addToHistoryOption = GetAddToHistoryOption ( result , fromHistoryFile ) ;
209
+
208
210
if ( addToHistoryOption != AddToHistoryOption . SkipAdding )
209
211
{
210
- var fromHistoryFile = fromDifferentSession || fromInitialRead ;
211
212
_previousHistoryItem = new HistoryItem
212
213
{
213
214
CommandLine = result ,
You can’t perform that action at this time.
0 commit comments