Command History should discard empty histories first before discarding LRU non-empty history #18009

Closed
opened 2026-01-31 06:01:06 +00:00 by claunia · 3 comments
Owner

Originally created by @neerajsi-msft on GitHub (Jul 22, 2022).

Description of the new feature/enhancement

Scenario:

  1. Run one of the dbgeng console debuggers (cdb.exe) to debug a program in a build window.
  2. Exit the debugger.
  3. Run a build (I'm using the Windows build system).
  4. Relaunch the debugger and try to use the command history.

Behavior: No history for the debugger is preserved, since the executables in the build have flushed out the relevant history.

Desired Behavior: The executables that were part of the build had no input commands, while the console debugger had some input, so we should leave the console debugger's history in the list.

Proposed technical implementation details (optional)

There are a couple implementations we could consider to avoid discarding useful history:

  1. When picking a history in CommandHistory::s_Allocate, scan first for history buffers that aren't !CLE_ALLOCATED and have zero commands, and only discard a non-empty history if no candidate was found with zero commands.
  2. Alternatively, lazily call s_Allocate when the first command is added to a history buffer.

Option 1 is a simpler implementation, but option 2 is nice in that we can use the full NumberOfHistoryBuffers for useful histories, rather than losing one buffer for empty commands cycling through.

Originally created by @neerajsi-msft on GitHub (Jul 22, 2022). # Description of the new feature/enhancement Scenario: 1) Run one of the dbgeng console debuggers (cdb.exe) to debug a program in a build window. 2) Exit the debugger. 3) Run a build (I'm using the Windows build system). 4) Relaunch the debugger and try to use the command history. Behavior: No history for the debugger is preserved, since the executables in the build have flushed out the relevant history. Desired Behavior: The executables that were part of the build had no input commands, while the console debugger had some input, so we should leave the console debugger's history in the list. # Proposed technical implementation details (optional) There are a couple implementations we could consider to avoid discarding useful history: 1) When picking a history in CommandHistory::s_Allocate, scan first for history buffers that aren't !CLE_ALLOCATED and have zero commands, and only discard a non-empty history if no candidate was found with zero commands. 2) Alternatively, lazily call s_Allocate when the first command is added to a history buffer. Option 1 is a simpler implementation, but option 2 is nice in that we can use the full NumberOfHistoryBuffers for useful histories, rather than losing one buffer for empty commands cycling through.
Author
Owner

@DHowett commented on GitHub (Jul 22, 2022):

Huh. That's a good point.

@DHowett commented on GitHub (Jul 22, 2022): _Huh_. That's a good point.
Author
Owner

@zadjii-msft commented on GitHub (Jul 25, 2022):

now this is a commandline change I can get behind and can't POSSIBLY imagine that an oil rig is depending on. Thanks for the suggestion!

@zadjii-msft commented on GitHub (Jul 25, 2022): now this is a commandline change I can get behind and can't POSSIBLY imagine that an oil rig is depending on. Thanks for the suggestion!
Author
Owner

@ghost commented on GitHub (Sep 13, 2022):

:tada:This issue was addressed in #13869, which has now been successfully released as Windows Terminal Preview v1.16.252.🎉

Handy links:

@ghost commented on GitHub (Sep 13, 2022): :tada:This issue was addressed in #13869, which has now been successfully released as `Windows Terminal Preview v1.16.252`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.16.252) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18009