diff --git a/src/Files.App/Services/Windows/WindowsIniService.cs b/src/Files.App/Services/Windows/WindowsIniService.cs index 5151918fa13e..eabf759d7db9 100644 --- a/src/Files.App/Services/Windows/WindowsIniService.cs +++ b/src/Files.App/Services/Windows/WindowsIniService.cs @@ -25,14 +25,13 @@ public List GetData(string filePath) return []; } - // Get sections - var sections = lines - .Where(line => line.StartsWith('[') && line.EndsWith(']')); - - // Get section line indexes + // Get section line indexes directly to handle duplicate section names List sectionLineIndexes = []; - foreach (var section in sections) - sectionLineIndexes.Add(lines.IndexOf(section)); + for (int i = 0; i < lines.Count; i++) + { + if (lines[i].StartsWith('[') && lines[i].EndsWith(']')) + sectionLineIndexes.Add(i); + } List dataItems = []; @@ -42,10 +41,10 @@ public List GetData(string filePath) var count = index + 1 == sectionLineIndexes.Count - ? (lines.Count - 1) - sectionIndex - : sectionLineIndexes[index + 1] - sectionIndex; + ? lines.Count - sectionIndex - 1 + : sectionLineIndexes[index + 1] - sectionIndex - 1; - if (count == 0) + if (count <= 0) continue; var range = lines.GetRange(sectionIndex + 1, count); diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml b/src/Files.App/Views/Shells/ModernShellPage.xaml index afbb5ad7b82c..98b5392ee316 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml @@ -49,7 +49,7 @@