Skip to content

Commit 2e34aca

Browse files
authored
DYN-9191: RecentFiles bug fix (DynamoDS#16394)
1 parent 165f1d2 commit 2e34aca

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/DynamoCore/Configuration/PreferenceSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,13 @@ public static PreferenceSettings Load(string filePath)
11701170
settings.BackupInterval = DefaultBackupInterval;
11711171
}
11721172

1173+
//Do not add invalid paths for recent files list
1174+
var recentFiles = settings?.RecentFiles;
1175+
if (recentFiles != null)
1176+
{
1177+
settings.RecentFiles = recentFiles.Where(path => !string.IsNullOrEmpty(path) && DynamoUtilities.PathHelper.IsValidPath(path)).ToList();
1178+
}
1179+
11731180
fs.Close(); // Release file lock
11741181
}
11751182
}

src/DynamoCoreWpf/Controls/StartPage.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,11 @@ private void OnRecentFilesChanged(object sender, NotifyCollectionChangedEventArg
419419
}
420420
else if (e.Action == NotifyCollectionChangedAction.Remove)
421421
{
422-
recentFiles.RemoveRange(e.OldStartingIndex, recentFiles.Count - e.OldStartingIndex);
422+
var removedItemsCount = e.OldItems?.Count ?? 0;
423+
if (recentFiles.Count > e.OldStartingIndex && recentFiles.Count >= removedItemsCount)
424+
{
425+
recentFiles.RemoveRange(e.OldStartingIndex, removedItemsCount);
426+
}
423427
}
424428
else
425429
{

0 commit comments

Comments
 (0)