File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Text . Json ;
56
67namespace Prowl . Editor . Projects ;
@@ -50,9 +51,21 @@ public static void AddRecent(string path, string name)
5051 LastOpened = DateTime . UtcNow
5152 } ) ;
5253
53- // Trim
54- if ( _entries . Count > MaxRecent )
55- _entries . RemoveRange ( MaxRecent , _entries . Count - MaxRecent ) ;
54+ // Trim the non-favorite tail to MaxRecent entries. Favorites are never evicted regardless
55+ // of count or age - starring a project is meant to pin it in this list permanently.
56+ int nonFavoriteCount = _entries . Count ( e => ! e . Favorite ) ;
57+ if ( nonFavoriteCount > MaxRecent )
58+ {
59+ int toRemove = nonFavoriteCount - MaxRecent ;
60+ for ( int i = _entries . Count - 1 ; i >= 0 && toRemove > 0 ; i -- )
61+ {
62+ if ( ! _entries [ i ] . Favorite )
63+ {
64+ _entries . RemoveAt ( i ) ;
65+ toRemove -- ;
66+ }
67+ }
68+ }
5669
5770 Save ( ) ;
5871 }
You can’t perform that action at this time.
0 commit comments