Repository navigation
Add a clear recently used item to the file history menu - #747
Conversation
The Last used dropdown now ends with a separator and a localized Clear recently used row that empties the file history list, persists the settings immediately, and rebuilds the menu. The row is disabled when the history is empty. Clearing only touches FileHistoryList; the search, filter, URI, regex and columnizer history lists are untouched. The click handler tells the new row apart from the file entries by reference, so the displayed text is never treated as a path. RemoveFromFileHistory and its HistoryItemRemoveRequested wiring are removed along with it: the right-click-to-remove handler subscribed to the dropdown's MouseUp, which a ToolStripDropDownMenu only raises for clicks outside its items, so the remove path never fired and is dead code. Tests: ClearFileHistoryTests covers clearing, persistence and that other history lists survive; MenuToolbarControllerTests covers the menu layout, the disabled state and that clicking the clear row does not raise HistoryItemClicked.
Hirogen
left a comment
There was a problem hiding this comment.
Thanks for this, @mfkeeq199458 — clean, well-scoped change, and the tests are nice.
I double-checked the dead-code claim against the WinForms source: ToolStrip.OnMouseUp only raises the public MouseUp when no item is under the cursor, so OnHistoryStripMouseUp could never have removed an entry (a right-click on an entry actually just opened the file via ItemClicked). Agreed, removing it is correct.
A few small, optional things:
- Naming: the field is
_clearHistoryItem, the control isclearFileHistoryToolStripMenuItem, and the event isHistoryClearRequested. Could we settle on one, e.g._clearFileHistoryItem/FileHistoryClearRequested? - Comment on
_clearHistoryItem(MenuToolbarController.cs:52) can go; the name already says it. - Locking:
ClearFileHistorymutates the list without_loadSaveLock, whileClearLastOpenFilesListright below takes it.AddToFileHistorydoesn't lock either, so it's consistent, but taking the lock would match the neighbouring clear method. - Double rebuild:
LogTabWindowcallsFillHistoryMenuexplicitly, and theSave→ConfigChanged→ApplySettingspath rebuilds it again. Harmless; feel free to drop the explicit call or leave it. - Tests:
ResetConfigManagerInitializationduplicates the helper inConfigManagerPortableModeTests. Not blocking, just noting it as a candidate for a shared helper later. - The whitespace-only change in
IConfigManager.cs:178can be reverted to keep the diff minimal.
None of these block merging. Happy to merge as is later this day, or after a quick touch-up if you want to address the naming.
- Rename _clearHistoryItem to _clearFileHistoryItem and HistoryClearRequested to FileHistoryClearRequested so the field, the event and the control name share one term - Drop the redundant comment on the clear item field - Take _loadSaveLock around the list clear in ClearFileHistory to match the neighbouring ClearLastOpenFilesList - Remove the explicit FillHistoryMenu call after ClearFileHistory; the Save -> ConfigChanged -> ApplySettings path already rebuilds the menu - Share the ConfigManager reset helper between test fixtures via ConfigManagerTestReflection (fail-fast variant) - Revert the whitespace-only change in IConfigManager.cs - Update the stale PopulateFileHistory doc comment: right-click removal was removed earlier in this branch
Hirogen
left a comment
There was a problem hiding this comment.
Thanks @mfkeeq199458, that addresses everything.
- Naming is consistent now (
_clearFileHistoryItem/FileHistoryClearRequested/clearFileHistoryToolStripMenuItem) - The lock in
ClearFileHistorymatchesClearLastOpenFilesList - I traced the rebuild path:
Save→ConfigChanged→ApplySettings→FillHistoryMenuruns synchronously, so dropping the explicit call is fine, and the comment explaining it is helpful - Nice to see the shared
ConfigManagerTestReflectionhelper, plus the fail-fast change for the portable-mode tests
One tiny nit: using LogExpert.Core.Config; in ConfigManagerTestReflection.cs is unused. Not blocking, so feel free to fix it or leave it.
Approving, thanks for the contribution!
The Last used dropdown now ends with a separator and a localized Clear recently used row that empties the file history list, persists the settings immediately, and rebuilds the menu. The row is disabled when the history is empty. Clearing only touches FileHistoryList; the search, filter, URI, regex and columnizer history lists are untouched.
The click handler tells the new row apart from the file entries by reference, so the displayed text is never treated as a path.
RemoveFromFileHistory and its HistoryItemRemoveRequested wiring are removed along with it: the right-click-to-remove handler subscribed to the dropdown's MouseUp, which a ToolStripDropDownMenu only raises for clicks outside its items, so the remove path never fired and is dead code.
Tests: ClearFileHistoryTests covers clearing, persistence and that other history lists survive; MenuToolbarControllerTests covers the menu layout, the disabled state and that clicking the clear row does not raise HistoryItemClicked.