From 7cc82e4003719b395614d976cc2df7b3d7b42b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20B=C3=A1lint=20Hunor?= Date: Tue, 6 Oct 2026 11:08:11 +0300 Subject: [PATCH] Fix Details rows rendering empty after reloading folder layout preferences The Linux layout database serialized DetailsLayoutColumnItem.UserLength, a GridLength that System.Text.Json cannot read back. On load it was written after UserLengthPixels and reset every column width to 0, so Details rows showed only the icon and a clipped name, and the zero widths were saved again. Persist the width only through UserLengthPixels and restore non-positive widths already saved by earlier builds to the default column widths. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LeKXJc3DnK3PzAqwgA72NY --- .../Data/Items/DetailsLayoutColumnItem.cs | 3 +- .../Layout/LayoutPreferencesDatabase.Linux.cs | 36 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Data/Items/DetailsLayoutColumnItem.cs b/src/Files.App/Data/Items/DetailsLayoutColumnItem.cs index 76f080a3b99c..48178354fcd5 100644 --- a/src/Files.App/Data/Items/DetailsLayoutColumnItem.cs +++ b/src/Files.App/Data/Items/DetailsLayoutColumnItem.cs @@ -88,7 +88,8 @@ public double NormalMinLength private GridLength _UserLength = new(200, GridUnitType.Pixel); - [RegistryIgnore] + // Persisted through UserLengthPixels: JSON can't read a GridLength back and would reset the width to 0 + [RegistryIgnore, JsonIgnore] public GridLength UserLength { get => _UserLength; diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesDatabase.Linux.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesDatabase.Linux.cs index a4ea595cb4f9..0c6a5e0f7e41 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesDatabase.Linux.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesDatabase.Linux.cs @@ -75,8 +75,11 @@ public void Import(string json) var entries = new List(); foreach (var item in items ?? []) { - if (!string.IsNullOrEmpty(item.FilePath)) - entries.Add(new LayoutPreferencesFileEntry { FilePath = item.FilePath, FileId = GetId(item.FilePath), Preferences = item.LayoutPreferencesManager }); + if (string.IsNullOrEmpty(item.FilePath)) + continue; + + RepairColumnWidths(item.LayoutPreferencesManager); + entries.Add(new LayoutPreferencesFileEntry { FilePath = item.FilePath, FileId = GetId(item.FilePath), Preferences = item.LayoutPreferencesManager }); } Save(entries); @@ -140,6 +143,9 @@ private List Load() var path = DatabasePath; if (File.Exists(path)) entries = JsonSerializer.Deserialize(File.ReadAllText(path), AppJsonSerializerContext.Default.ListLayoutPreferencesFileEntry) ?? entries; + + foreach (var entry in entries) + RepairColumnWidths(entry.Preferences); } catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Text.Json.JsonException) { @@ -149,6 +155,32 @@ private List Load() return _entries = entries; } + // Earlier builds saved every column width as 0 (the GridLength round trip), which renders Details rows empty. + // Widths of 0 are never valid, since hidden columns are tracked separately, so they fall back to the default width. + private static void RepairColumnWidths(LayoutPreferencesItem? preferences) + { + if (preferences?.ColumnsViewModel is not { } columns) + return; + + var stored = Columns(columns); + if (stored.All(column => column.UserLengthPixels > 0)) + return; + + var defaults = Columns(new LayoutPreferencesItem().ColumnsViewModel); + for (var i = 0; i < stored.Length; i++) + { + if (!(stored[i].UserLengthPixels > 0)) + stored[i].UserLengthPixels = defaults[i].UserLengthPixels; + } + + static DetailsLayoutColumnItem[] Columns(ColumnsViewModel c) => + [ + c.IconColumn, c.GitStatusColumn, c.GitLastCommitDateColumn, c.GitLastCommitMessageColumn, c.GitCommitAuthorColumn, + c.GitLastCommitShaColumn, c.TagColumn, c.NameColumn, c.StatusColumn, c.DateModifiedColumn, c.PathColumn, + c.OriginalPathColumn, c.ItemTypeColumn, c.DateDeletedColumn, c.DateCreatedColumn, c.SizeColumn, + ]; + } + private void Save(List entries) { _entries = entries;