More robust "recent projects" deduplication

This commit is contained in:
Simon Lübeß
2026-08-23 12:54:18 +02:00
parent c8d63a9c36
commit abf7a01917
3 changed files with 12 additions and 10 deletions
-8
View File
@@ -75,14 +75,6 @@ namespace GlitchyEditor
private float _fixedTimestep = 1.0f / 60.0f; private float _fixedTimestep = 1.0f / 60.0f;
append List<(String Name, String Path)> _recentScenePaths = .() ~ {
for (var item in _)
{
delete item.Name;
delete item.Path;
}
};
private GameTime _simulationGameTime = new .() ~ delete _; private GameTime _simulationGameTime = new .() ~ delete _;
/// Gets or sets the path of the current scene. /// Gets or sets the path of the current scene.
+2
View File
@@ -38,6 +38,8 @@ class Project
{ {
_workspacePath = new String(workspacePath.Length); _workspacePath = new String(workspacePath.Length);
Path.GetFullPath(workspacePath, _workspacePath); Path.GetFullPath(workspacePath, _workspacePath);
if (_workspacePath.EndsWith(Path.DirectorySeparatorChar))
_workspacePath.RemoveFromEnd(1);
_assetsFolder = new String(); _assetsFolder = new String();
PathInProject(_assetsFolder, "Assets"); PathInProject(_assetsFolder, "Assets");
+10 -2
View File
@@ -375,17 +375,25 @@ class EditorSettings
if (_recentProjects == null) if (_recentProjects == null)
_recentProjects = new List<String>(); _recentProjects = new List<String>();
String absolutePath = new String(value.Length);
Path.GetFullPath(value, absolutePath);
if (absolutePath.EndsWith(Path.DirectorySeparatorChar))
absolutePath.RemoveFromEnd(1);
// Remove duplicates // Remove duplicates
for (var entry in _recentProjects) for (var entry in _recentProjects)
{ {
if (entry == value) if (entry.EndsWith(Path.DirectorySeparatorChar))
entry.RemoveFromEnd(1);
if (Path.Equals(entry, absolutePath))
{ {
delete entry; delete entry;
@entry.Remove(); @entry.Remove();
} }
} }
_recentProjects.Insert(0, new String(value)); _recentProjects.Insert(0, absolutePath);
if (_recentProjects.Count > 10) if (_recentProjects.Count > 10)
{ {