You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LastOpenFilesList is only cleared inside one branch of LoadStartupFiles. Two common startup paths skip that clear, after which every application close appends the current tabs to the stale list instead of replacing it. The list grows without bound, and once it is read again the user gets tabs they closed sessions ago, opened before the current ones.
Steps to reproduce
Enable Open last files in the preferences.
Start LogExpert normally, open a.log and b.log, close the app.
Start LogExpert by double-clicking c.log in Explorer (i.e. with a command-line file argument). Close the app.
Start LogExpert normally again.
Expected: only c.log is restored. Actual:a.log, b.log and c.log are restored, with the stale files first. settings.json now holds five entries for three files.
Repeating steps 3–4 keeps growing the list.
The same happens with Open last files disabled: the list is never read and never cleared, so it accumulates silently. Enabling the preference later opens a flood of stale tabs.
ClearLastOpenFilesList() is called from exactly one place — line 353, inside the if (_configManager.Settings.Preferences.OpenLastFiles) branch of LoadStartupFiles, after the reopen loop:
publicvoidLoadStartupFiles(IList<string>lastOpenFiles,string[]?startupFileNames){if(startupFileNames!=null&&startupFileNames.Length>0){_=LoadFilesWithOption(startupFileNames,false);return;// <-- no clear}if(_configManager.Settings.Preferences.OpenLastFiles)// <-- no clear when false{foreach(varnameinlastOpenFiles.Where(filename =>!string.IsNullOrEmpty(filename))){_=AddFileTab(newFileTabRequest{FileName=name});}_configManager.ClearLastOpenFilesList();}}
SaveLastOpenFilesList (line 330) only ever calls Add, so it depends on that clear having happened:
It is invoked unconditionally from OnLogTabWindowFormClosing (src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs:1759), so save and clear are not symmetric.
Duplicate entries do not create duplicate tabs — AddFileTab resolves an existing window by normalized full path (line 66) and activates it instead — so the visible symptoms are unwanted tabs and an ever-growing settings list, not duplicated tabs.
Suggested fix
Make the save total rather than additive, so it no longer depends on a clear elsewhere:
Alternative: move ClearLastOpenFilesList() in LoadStartupFiles so it runs on every path including the command-line early return. The first option is preferable — it makes the method self-contained and idempotent regardless of how startup went.
Notes
src/LogExpert.Tests/Services/FileOperationServiceTests.cs asserts ClearLastOpenFilesList call counts (Times.Never / Times.Once) around lines 803–866 and in the SaveLastOpenFilesList_* tests; those expectations need updating with either fix.
Summary
LastOpenFilesListis only cleared inside one branch ofLoadStartupFiles. Two common startup paths skip that clear, after which every application close appends the current tabs to the stale list instead of replacing it. The list grows without bound, and once it is read again the user gets tabs they closed sessions ago, opened before the current ones.Steps to reproduce
a.logandb.log, close the app.c.login Explorer (i.e. with a command-line file argument). Close the app.Expected: only
c.logis restored.Actual:
a.log,b.logandc.logare restored, with the stale files first.settings.jsonnow holds five entries for three files.Repeating steps 3–4 keeps growing the list.
The same happens with Open last files disabled: the list is never read and never cleared, so it accumulates silently. Enabling the preference later opens a flood of stale tabs.
Root cause
src/LogExpert.UI/Services/FileOperationService/FileOperationService.csClearLastOpenFilesList()is called from exactly one place — line 353, inside theif (_configManager.Settings.Preferences.OpenLastFiles)branch ofLoadStartupFiles, after the reopen loop:SaveLastOpenFilesList(line 330) only ever callsAdd, so it depends on that clear having happened:It is invoked unconditionally from
OnLogTabWindowFormClosing(src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs:1759), so save and clear are not symmetric.Duplicate entries do not create duplicate tabs —
AddFileTabresolves an existing window by normalized full path (line 66) and activates it instead — so the visible symptoms are unwanted tabs and an ever-growing settings list, not duplicated tabs.Suggested fix
Make the save total rather than additive, so it no longer depends on a clear elsewhere:
Alternative: move
ClearLastOpenFilesList()inLoadStartupFilesso it runs on every path including the command-line early return. The first option is preferable — it makes the method self-contained and idempotent regardless of how startup went.Notes
src/LogExpert.Tests/Services/FileOperationServiceTests.csassertsClearLastOpenFilesListcall counts (Times.Never/Times.Once) around lines 803–866 and in theSaveLastOpenFilesList_*tests; those expectations need updating with either fix.