@@ -276,7 +276,7 @@ public int GridViewSize
276276 public event EventHandler < GroupOption > GroupOptionPreferenceUpdated ;
277277
278278 public event EventHandler < SortDirection > SortDirectionPreferenceUpdated ;
279-
279+
280280 public event EventHandler < bool > SortDirectoriesAlongsideFilesPreferenceUpdated ;
281281
282282 public SortOption DirectorySortOption
@@ -330,8 +330,8 @@ public bool SortDirectoriesAlongsideFiles
330330 {
331331 if ( SetProperty ( ref LayoutPreference . SortDirectoriesAlongsideFiles , value , nameof ( SortDirectoriesAlongsideFiles ) ) )
332332 {
333- LayoutPreferencesUpdateRequired ? . Invoke ( this , new LayoutPreferenceEventArgs ( LayoutPreference ) ) ;
334- SortDirectoriesAlongsideFilesPreferenceUpdated ? . Invoke ( this , SortDirectoriesAlongsideFiles ) ;
333+ LayoutPreferencesUpdateRequired ? . Invoke ( this , new LayoutPreferenceEventArgs ( LayoutPreference ) ) ;
334+ SortDirectoriesAlongsideFilesPreferenceUpdated ? . Invoke ( this , SortDirectoriesAlongsideFiles ) ;
335335 }
336336 }
337337 }
@@ -351,8 +351,11 @@ public static LayoutPreferences GetLayoutPreferencesForPath(string folderPath)
351351 IUserSettingsService userSettingsService = Ioc . Default . GetService < IUserSettingsService > ( ) ;
352352 if ( userSettingsService . PreferencesSettingsService . AreLayoutPreferencesPerFolder )
353353 {
354- var layoutPrefs = ReadLayoutPreferencesFromAds ( folderPath . TrimEnd ( '\\ ' ) ) ;
355- return layoutPrefs ?? ReadLayoutPreferencesFromSettings ( folderPath . TrimEnd ( '\\ ' ) . Replace ( '\\ ' , '_' ) ) ;
354+ folderPath = folderPath . TrimEnd ( '\\ ' ) ;
355+ var layoutPrefs = ReadLayoutPreferencesFromAds ( folderPath ) ;
356+ return layoutPrefs ??
357+ ReadLayoutPreferencesFromSettings ( folderPath . Replace ( '\\ ' , '_' ) ) ??
358+ GetDefaultPreferences ( folderPath ) ;
356359 }
357360
358361 return LayoutPreferences . DefaultLayoutPreferences ;
@@ -428,15 +431,21 @@ private static LayoutPreferences ReadLayoutPreferencesFromSettings(string folder
428431 return LayoutPreferences . DefaultLayoutPreferences ;
429432 }
430433
431- IUserSettingsService userSettingsService = Ioc . Default . GetService < IUserSettingsService > ( ) ;
432434 ApplicationDataContainer dataContainer = localSettings . CreateContainer ( "LayoutModeContainer" , ApplicationDataCreateDisposition . Always ) ;
433435 folderPath = new string ( folderPath . TakeLast ( 254 ) . ToArray ( ) ) ;
434436 if ( dataContainer . Values . ContainsKey ( folderPath ) )
435437 {
436438 ApplicationDataCompositeValue adcv = ( ApplicationDataCompositeValue ) dataContainer . Values [ folderPath ] ;
437439 return LayoutPreferences . FromCompositeValue ( adcv ) ;
438440 }
439- else if ( folderPath == CommonPaths . DownloadsPath )
441+
442+ return null ;
443+ }
444+
445+ private static LayoutPreferences GetDefaultPreferences ( string folderPath )
446+ {
447+ IUserSettingsService userSettingsService = Ioc . Default . GetService < IUserSettingsService > ( ) ;
448+ if ( folderPath == CommonPaths . DownloadsPath )
440449 {
441450 // Default for downloads folder is to group by date created
442451 return new LayoutPreferences
0 commit comments