From 7de5991ecb4a392ae57bdab3bf4703590e4cf6fa Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 12 Jun 2025 09:50:37 +0800 Subject: [PATCH] code_review: PR #1415 - Column for hotkey in `Reset` popup should use `Auto` for width - Add `SelectionBoxItemTemplate` for current selected mode in `Reset` popup Signed-off-by: leo --- src/App.axaml.cs | 2 +- src/Native/Windows.cs | 22 +--------------------- src/ViewModels/ConfigureWorkspace.cs | 2 +- src/ViewModels/Launcher.cs | 2 -- src/ViewModels/ScanRepositories.cs | 3 +-- src/Views/Reset.axaml | 12 +++++++++++- 6 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 94bcb7ef..8e579373 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -681,7 +681,7 @@ namespace SourceGit } var name = sb.ToString(); - if (name.Contains('#')) + if (name.Contains('#', StringComparison.Ordinal)) { if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) && !name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal)) diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index 8042ac47..07cf51fb 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -127,23 +127,17 @@ namespace SourceGit.Native Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); - var git = reg.OpenSubKey("SOFTWARE\\GitForWindows"); + var git = reg.OpenSubKey(@"SOFTWARE\GitForWindows"); if (git?.GetValue("InstallPath") is string installPath) - { return Path.Combine(installPath, "bin", "git.exe"); - } var builder = new StringBuilder("git.exe", 259); if (!PathFindOnPath(builder, null)) - { return null; - } var exePath = builder.ToString(); if (!string.IsNullOrEmpty(exePath)) - { return exePath; - } return null; } @@ -299,9 +293,7 @@ namespace SourceGit.Native // VSCode (system) var systemVScode = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1"); if (systemVScode != null) - { return systemVScode.GetValue("DisplayIcon") as string; - } var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey( Microsoft.Win32.RegistryHive.CurrentUser, @@ -310,9 +302,7 @@ namespace SourceGit.Native // VSCode (user) var vscode = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1"); if (vscode != null) - { return vscode.GetValue("DisplayIcon") as string; - } return string.Empty; } @@ -326,9 +316,7 @@ namespace SourceGit.Native // VSCode - Insiders (system) var systemVScodeInsiders = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1"); if (systemVScodeInsiders != null) - { return systemVScodeInsiders.GetValue("DisplayIcon") as string; - } var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey( Microsoft.Win32.RegistryHive.CurrentUser, @@ -337,9 +325,7 @@ namespace SourceGit.Native // VSCode - Insiders (user) var vscodeInsiders = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1"); if (vscodeInsiders != null) - { return vscodeInsiders.GetValue("DisplayIcon") as string; - } return string.Empty; } @@ -353,9 +339,7 @@ namespace SourceGit.Native // VSCodium (system) var systemVSCodium = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88DA3577-054F-4CA1-8122-7D820494CFFB}_is1"); if (systemVSCodium != null) - { return systemVSCodium.GetValue("DisplayIcon") as string; - } var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey( Microsoft.Win32.RegistryHive.CurrentUser, @@ -364,9 +348,7 @@ namespace SourceGit.Native // VSCodium (user) var vscodium = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2E1F05D1-C245-4562-81EE-28188DB6FD17}_is1"); if (vscodium != null) - { return vscodium.GetValue("DisplayIcon") as string; - } return string.Empty; } @@ -409,9 +391,7 @@ namespace SourceGit.Native if (launcher.GetValue(string.Empty) is string CLSID && localMachine.OpenSubKey(@$"SOFTWARE\Classes\CLSID\{CLSID}\LocalServer32") is Microsoft.Win32.RegistryKey devenv && devenv.GetValue(string.Empty) is string localServer32) - { return localServer32!.Trim('\"'); - } } return string.Empty; diff --git a/src/ViewModels/ConfigureWorkspace.cs b/src/ViewModels/ConfigureWorkspace.cs index 49cd649b..5be066ae 100644 --- a/src/ViewModels/ConfigureWorkspace.cs +++ b/src/ViewModels/ConfigureWorkspace.cs @@ -29,7 +29,7 @@ namespace SourceGit.ViewModels public ConfigureWorkspace() { - Workspaces = new AvaloniaList(Preferences.Instance.Workspaces); + Workspaces = new(Preferences.Instance.Workspaces); } public void Add() diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index e6c55be2..bb3efd51 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -296,9 +296,7 @@ namespace SourceGit.ViewModels var removeIdx = Pages.IndexOf(page); var activeIdx = Pages.IndexOf(_activePage); if (removeIdx == activeIdx) - { ActivePage = Pages[removeIdx > 0 ? removeIdx - 1 : removeIdx + 1]; - } CloseRepositoryInTab(page); Pages.RemoveAt(removeIdx); diff --git a/src/ViewModels/ScanRepositories.cs b/src/ViewModels/ScanRepositories.cs index 4c7eec4b..4d05a996 100644 --- a/src/ViewModels/ScanRepositories.cs +++ b/src/ViewModels/ScanRepositories.cs @@ -64,7 +64,6 @@ namespace SourceGit.ViewModels } Preferences.Instance.AutoRemoveInvalidNode(); - Preferences.Instance.SortNodes(Preferences.Instance.RepositoryNodes); Preferences.Instance.Save(); Welcome.Instance.Refresh(); @@ -154,8 +153,8 @@ namespace SourceGit.ViewModels IsExpanded = true, }; collection.Add(added); - Preferences.Instance.SortNodes(collection); + Preferences.Instance.SortNodes(collection); return added; } diff --git a/src/Views/Reset.axaml b/src/Views/Reset.axaml index d95f003c..bce9d747 100644 --- a/src/Views/Reset.axaml +++ b/src/Views/Reset.axaml @@ -45,7 +45,7 @@ KeyDown="OnResetModeKeyDown"> - + @@ -53,6 +53,16 @@ + + + + + + + + + +