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

Open
opened 2026-01-31 06:00:58 +00:00 by claunia · 0 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18004