Repository: microsoft/terminal (language: cpp)

Issue:
Can't cycle through command history using the down-arrow
### Windows Terminal version

1.21.2911.0

### Windows build number

10.0.22631.4391

### Other Software

_No response_

### Steps to reproduce

I used to be able to run

```
> echo 1
1
> echo 2
2
> echo 3
3
```
and then press UP ARROW three times to repeat `echo 1` and then DOWN ARROW to cycle through `echo 2`, `echo 3`, `echo 1`, etc. Now the first DOWN ARROW does nothing.

I think both Command Prompt and PowerShell had this behavior. I do know I used that pattern of cycling through the history for Command Prompt quite frequently, but now I find that I must press UP ARROW three times each time I want to cycle through the last three commands. It would be nice to have the old behavior back.

I haven't found any documentation or bug reports that addresses this issue. Thanks in advance for your help.

### Expected Behavior

After pressing UP ARROW three times and ENTER to execute the third command back in history, I expected pressing DOWN ARROW followed by ENTER to execute each of the past 3 commands in sequence ad infinitum.


### Actual Behavior

After pressing UP ARROW three times and ENTER to execute the third command back in history, pressing DOWN ARROW does nothing. No previous command is recalled from history.


Discussion / hints:
As a temporary measure, downgrading to release v1.21.2361.0 or lower rolls back this change.
Thank you. I rolled back to v1.21.2361.0 (which works well enough and resolves this issue for the time being) and look forward to the release of v1.23.
Apparently that's how cmd has always worked if "Discard old duplicates" is enabled, huh. I wonder if I should double-down by changing the "Discard old duplicates" behavior and add the "circling" that you describe, or if I should revert enabling it by default under Windows Terminal.
i think a problem here is that the "replay" behaviour working consistently is dependent on not deleting old duplicate commands, since if you delete an old duplicate, you change the command sequence

i.e. with dedup
```
cls
echo 1
echo 2
echo 3
...
echo 2
```
means that "replaying" from cls onwards would then run
```
cls
echo 1
echo 3
```
i think that, if there can't be configuration on the user end, not having dedup is the better option since the only downside (afaik) is that it's inefficient usage of the history buffer (and to my knowledge that shoudn't be an issue if the history buffer is set to any reasonable size)

Fix patch:
diff --git a/src/host/settings.cpp b/src/host/settings.cpp
index 746bd91564f..4650fbf9eb1 100644
--- a/src/host/settings.cpp
+++ b/src/host/settings.cpp
@@ -36,7 +36,7 @@ Settings::Settings() :
     _bAutoPosition(true),
     _uHistoryBufferSize(DEFAULT_NUMBER_OF_COMMANDS),
     _uNumberOfHistoryBuffers(DEFAULT_NUMBER_OF_BUFFERS),
-    _bHistoryNoDup(true),
+    _bHistoryNoDup(false),
     // ColorTable initialized below
     _uCodePage(ServiceLocator::LocateGlobals().uiOEMCP),
     _uScrollScale(1),
@@ -110,7 +110,7 @@ void Settings::ApplyDesktopSpecificDefaults()
     _bQuickEdit = TRUE;
     _uHistoryBufferSize = 50;
     _uNumberOfHistoryBuffers = 4;
-    _bHistoryNoDup = true;
+    _bHistoryNoDup = FALSE;
 
     _renderSettings.ResetColorTable();
 
diff --git a/src/propsheet/registry.cpp b/src/propsheet/registry.cpp
index 3a7283e080e..64d392aa76d 100644
--- a/src/propsheet/registry.cpp
+++ b/src/propsheet/registry.cpp
@@ -79,7 +79,7 @@ VOID InitRegistryValues(
     pStateInfo->CursorSize = 25;
     pStateInfo->HistoryBufferSize = 25;
     pStateInfo->NumberOfHistoryBuffers = 4;
-    pStateInfo->HistoryNoDup = 1;
+    pStateInfo->HistoryNoDup = 0;
 
     // clang-format off
     if (pStateInfo->fIsV2Console)


Test patch: