code_style: general cleanup (#1415)

* code_style:  general cleanup

* code_style: whitespace cleanup
This commit is contained in:
Nathan Baulch 2025-06-12 11:35:37 +10:00 committed by GitHub
parent 35eda489be
commit ffac71b15f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
89 changed files with 161 additions and 243 deletions

View file

@ -100,7 +100,7 @@ dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _ dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
# use accessibility modifiers # use accessibility modifiers
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

View file

@ -301,7 +301,7 @@ namespace SourceGit
return await clipboard.GetTextAsync(); return await clipboard.GetTextAsync();
} }
} }
return default; return null;
} }
public static string Text(string key, params object[] args) public static string Text(string key, params object[] args)
@ -323,8 +323,7 @@ namespace SourceGit
icon.Height = 12; icon.Height = 12;
icon.Stretch = Stretch.Uniform; icon.Stretch = Stretch.Uniform;
var geo = Current?.FindResource(key) as StreamGeometry; if (Current?.FindResource(key) is StreamGeometry geo)
if (geo != null)
icon.Data = geo; icon.Data = geo;
return icon; return icon;
@ -682,8 +681,7 @@ namespace SourceGit
} }
var name = sb.ToString(); var name = sb.ToString();
var idx = name.IndexOf('#'); if (name.Contains('#'))
if (idx >= 0)
{ {
if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) && if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) &&
!name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal)) !name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal))

View file

@ -51,7 +51,7 @@ namespace SourceGit.Commands
private void ParseLine(string line) private void ParseLine(string line)
{ {
if (line.IndexOf('\0', StringComparison.Ordinal) >= 0) if (line.Contains('\0', StringComparison.Ordinal))
{ {
_result.IsBinary = true; _result.IsBinary = true;
_result.LineInfos.Clear(); _result.LineInfos.Clear();

View file

@ -194,7 +194,7 @@ namespace SourceGit.Commands
private void HandleOutput(string line, List<string> errs) private void HandleOutput(string line, List<string> errs)
{ {
line = line ?? string.Empty; line ??= string.Empty;
Log?.AppendLine(line); Log?.AppendLine(line);
// Lines to hide in error message. // Lines to hide in error message.

View file

@ -34,6 +34,6 @@ namespace SourceGit.Commands
return succ; return succ;
} }
private string _tmpFile = string.Empty; private readonly string _tmpFile;
} }
} }

View file

@ -10,7 +10,7 @@ namespace SourceGit.Commands
[GeneratedRegex(@"^(.+)\s+([\w.]+)\s+\w+:(\d+)$")] [GeneratedRegex(@"^(.+)\s+([\w.]+)\s+\w+:(\d+)$")]
private static partial Regex REG_LOCK(); private static partial Regex REG_LOCK();
class SubCmd : Command private class SubCmd : Command
{ {
public SubCmd(string repo, string args, Models.ICommandLog log) public SubCmd(string repo, string args, Models.ICommandLog log)
{ {

View file

@ -90,6 +90,6 @@ namespace SourceGit.Commands
private List<Models.InteractiveCommit> _commits = []; private List<Models.InteractiveCommit> _commits = [];
private Models.InteractiveCommit _current = null; private Models.InteractiveCommit _current = null;
private string _boundary = ""; private readonly string _boundary;
} }
} }

View file

@ -16,9 +16,6 @@ namespace SourceGit.Commands
public long Result() public long Result()
{ {
if (_result != 0)
return _result;
var rs = ReadToEnd(); var rs = ReadToEnd();
if (rs.IsSuccess) if (rs.IsSuccess)
{ {
@ -29,7 +26,5 @@ namespace SourceGit.Commands
return 0; return 0;
} }
private readonly long _result = 0;
} }
} }

View file

@ -23,13 +23,11 @@ namespace SourceGit.Commands
_patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append(c.DataForAmend.ObjectHash);
_patchBuilder.Append("\t"); _patchBuilder.Append("\t");
_patchBuilder.Append(c.OriginalPath); _patchBuilder.Append(c.OriginalPath);
_patchBuilder.Append("\n");
} }
else if (c.Index == Models.ChangeState.Added) else if (c.Index == Models.ChangeState.Added)
{ {
_patchBuilder.Append("0 0000000000000000000000000000000000000000\t"); _patchBuilder.Append("0 0000000000000000000000000000000000000000\t");
_patchBuilder.Append(c.Path); _patchBuilder.Append(c.Path);
_patchBuilder.Append("\n");
} }
else if (c.Index == Models.ChangeState.Deleted) else if (c.Index == Models.ChangeState.Deleted)
{ {
@ -37,7 +35,6 @@ namespace SourceGit.Commands
_patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append(c.DataForAmend.ObjectHash);
_patchBuilder.Append("\t"); _patchBuilder.Append("\t");
_patchBuilder.Append(c.Path); _patchBuilder.Append(c.Path);
_patchBuilder.Append("\n");
} }
else else
{ {
@ -46,8 +43,9 @@ namespace SourceGit.Commands
_patchBuilder.Append(c.DataForAmend.ObjectHash); _patchBuilder.Append(c.DataForAmend.ObjectHash);
_patchBuilder.Append("\t"); _patchBuilder.Append("\t");
_patchBuilder.Append(c.Path); _patchBuilder.Append(c.Path);
_patchBuilder.Append("\n");
} }
_patchBuilder.Append("\n");
} }
} }

View file

@ -38,7 +38,7 @@ namespace SourceGit.Models
[GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@.+\.github\.com$")] [GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@.+\.github\.com$")]
private static partial Regex REG_GITHUB_USER_EMAIL(); private static partial Regex REG_GITHUB_USER_EMAIL();
private object _synclock = new object(); private readonly Lock _synclock = new();
private string _storePath; private string _storePath;
private List<IAvatarHost> _avatars = new List<IAvatarHost>(); private List<IAvatarHost> _avatars = new List<IAvatarHost>();
private Dictionary<string, Bitmap> _resources = new Dictionary<string, Bitmap>(); private Dictionary<string, Bitmap> _resources = new Dictionary<string, Bitmap>();
@ -144,8 +144,7 @@ namespace SourceGit.Models
if (_defaultAvatars.Contains(email)) if (_defaultAvatars.Contains(email))
return null; return null;
if (_resources.ContainsKey(email)) _resources.Remove(email);
_resources.Remove(email);
var localFile = Path.Combine(_storePath, GetEmailHash(email)); var localFile = Path.Combine(_storePath, GetEmailHash(email));
if (File.Exists(localFile)) if (File.Exists(localFile))
@ -179,8 +178,7 @@ namespace SourceGit.Models
lock (_synclock) lock (_synclock)
{ {
if (!_requesting.Contains(email)) _requesting.Add(email);
_requesting.Add(email);
} }
return null; return null;
@ -200,10 +198,7 @@ namespace SourceGit.Models
if (image == null) if (image == null)
return; return;
if (_resources.ContainsKey(email)) _resources[email] = image;
_resources[email] = image;
else
_resources.Add(email, image);
_requesting.Remove(email); _requesting.Remove(email);

View file

@ -19,7 +19,7 @@ namespace SourceGit.Models
public class Commit public class Commit
{ {
// As retrieved by: git mktree </dev/null // As retrieved by: git mktree </dev/null
public static readonly string EmptyTreeSHA1 = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"; public const string EmptyTreeSHA1 = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
public static double OpacityForNotMerged public static double OpacityForNotMerged
{ {

View file

@ -4,7 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.Models namespace SourceGit.Models
{ {
public partial class CommitTemplate : ObservableObject public class CommitTemplate : ObservableObject
{ {
public string Name public string Name
{ {

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Globalization;
namespace SourceGit.Models namespace SourceGit.Models
{ {

View file

@ -287,9 +287,8 @@ namespace SourceGit.Models
return false; return false;
} }
for (int i = 0; i < HistoriesFilters.Count; i++) foreach (var filter in HistoriesFilters)
{ {
var filter = HistoriesFilters[i];
if (filter.Type != type) if (filter.Type != type)
continue; continue;

View file

@ -402,7 +402,7 @@ namespace SourceGit.Models
sb.AppendJoin(", ", paths); sb.AppendJoin(", ", paths);
if (max < context.changes.Count) if (max < context.changes.Count)
sb.AppendFormat(" and {0} other files", context.changes.Count - max); sb.Append($" and {context.changes.Count - max} other files");
return sb.ToString(); return sb.ToString();
} }

View file

@ -9,7 +9,7 @@ namespace SourceGit.Models
public int AddedStart { get; set; } public int AddedStart { get; set; }
public int AddedCount { get; set; } public int AddedCount { get; set; }
class Chunk private class Chunk
{ {
public int Hash; public int Hash;
public bool Modified; public bool Modified;
@ -25,7 +25,7 @@ namespace SourceGit.Models
} }
} }
enum Edit private enum Edit
{ {
None, None,
DeletedRight, DeletedRight,
@ -34,7 +34,7 @@ namespace SourceGit.Models
AddedLeft, AddedLeft,
} }
class EditResult private class EditResult
{ {
public Edit State; public Edit State;
public int DeleteStart; public int DeleteStart;
@ -204,11 +204,10 @@ namespace SourceGit.Models
for (int i = 0; i <= half; i++) for (int i = 0; i <= half; i++)
{ {
for (int j = -i; j <= i; j += 2) for (int j = -i; j <= i; j += 2)
{ {
var idx = j + half; var idx = j + half;
int o, n; int o;
if (j == -i || (j != i && forward[idx - 1] < forward[idx + 1])) if (j == -i || (j != i && forward[idx - 1] < forward[idx + 1]))
{ {
o = forward[idx + 1]; o = forward[idx + 1];
@ -220,7 +219,7 @@ namespace SourceGit.Models
rs.State = Edit.DeletedRight; rs.State = Edit.DeletedRight;
} }
n = o - j; var n = o - j;
var startX = o; var startX = o;
var startY = n; var startY = n;
@ -258,7 +257,7 @@ namespace SourceGit.Models
for (int j = -i; j <= i; j += 2) for (int j = -i; j <= i; j += 2)
{ {
var idx = j + half; var idx = j + half;
int o, n; int o;
if (j == -i || (j != i && reverse[idx + 1] <= reverse[idx - 1])) if (j == -i || (j != i && reverse[idx + 1] <= reverse[idx - 1]))
{ {
o = reverse[idx + 1] - 1; o = reverse[idx + 1] - 1;
@ -270,7 +269,7 @@ namespace SourceGit.Models
rs.State = Edit.AddedLeft; rs.State = Edit.AddedLeft;
} }
n = o - (j + delta); var n = o - (j + delta);
var endX = o; var endX = o;
var endY = n; var endY = n;
@ -312,8 +311,7 @@ namespace SourceGit.Models
private static void AddChunk(List<Chunk> chunks, Dictionary<string, int> hashes, string data, int start) private static void AddChunk(List<Chunk> chunks, Dictionary<string, int> hashes, string data, int start)
{ {
int hash; if (hashes.TryGetValue(data, out var hash))
if (hashes.TryGetValue(data, out hash))
{ {
chunks.Add(new Chunk(hash, start, data.Length)); chunks.Add(new Chunk(hash, start, data.Length));
} }

View file

@ -26,11 +26,7 @@ namespace SourceGit.Models
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj == null || !(obj is User)) return obj is User other && Name == other.Name && Email == other.Email;
return false;
var other = obj as User;
return Name == other.Name && Email == other.Email;
} }
public override int GetHashCode() public override int GetHashCode()

View file

@ -246,7 +246,7 @@ namespace SourceGit.Models
private long _updateStashes = 0; private long _updateStashes = 0;
private long _updateTags = 0; private long _updateTags = 0;
private object _lockSubmodule = new object(); private readonly Lock _lockSubmodule = new();
private List<string> _submodules = new List<string>(); private List<string> _submodules = new List<string>();
} }
} }

View file

@ -128,7 +128,7 @@ namespace SourceGit.Native
Microsoft.Win32.RegistryView.Registry64); Microsoft.Win32.RegistryView.Registry64);
var git = reg.OpenSubKey("SOFTWARE\\GitForWindows"); var git = reg.OpenSubKey("SOFTWARE\\GitForWindows");
if (git != null && git.GetValue("InstallPath") is string installPath) if (git?.GetValue("InstallPath") is string installPath)
{ {
return Path.Combine(installPath, "bin", "git.exe"); return Path.Combine(installPath, "bin", "git.exe");
} }
@ -181,7 +181,7 @@ namespace SourceGit.Native
break; break;
case "cmd": case "cmd":
return "C:\\Windows\\System32\\cmd.exe"; return @"C:\Windows\System32\cmd.exe";
case "wt": case "wt":
var wtFinder = new StringBuilder("wt.exe", 512); var wtFinder = new StringBuilder("wt.exe", 512);
if (PathFindOnPath(wtFinder, null)) if (PathFindOnPath(wtFinder, null))
@ -199,8 +199,8 @@ namespace SourceGit.Native
finder.VSCode(FindVSCode); finder.VSCode(FindVSCode);
finder.VSCodeInsiders(FindVSCodeInsiders); finder.VSCodeInsiders(FindVSCodeInsiders);
finder.VSCodium(FindVSCodium); finder.VSCodium(FindVSCodium);
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe"); finder.Fleet(() => $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Programs\Fleet\Fleet.exe");
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\JetBrains\\Toolbox"); finder.FindJetBrainsFromToolbox(() => $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\JetBrains\Toolbox");
finder.SublimeText(FindSublimeText); finder.SublimeText(FindSublimeText);
finder.TryAdd("Visual Studio", "vs", FindVisualStudio, GenerateCommandlineArgsForVisualStudio); finder.TryAdd("Visual Studio", "vs", FindVisualStudio, GenerateCommandlineArgsForVisualStudio);
return finder.Founded; return finder.Founded;

View file

@ -16,7 +16,7 @@
<Style.Resources> <Style.Resources>
<x:Double x:Key="ScrollBarSize">12</x:Double> <x:Double x:Key="ScrollBarSize">12</x:Double>
</Style.Resources> </Style.Resources>
<Setter Property="ShowDelay" Value="0:0:0.1"/> <Setter Property="ShowDelay" Value="0:0:0.1"/>
<Setter Property="HideDelay" Value="0:0:0.2"/> <Setter Property="HideDelay" Value="0:0:0.2"/>
</Style> </Style>
@ -38,7 +38,7 @@
<Setter Property="BorderThickness" Value="0"/> <Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/> <Setter Property="Padding" Value="0"/>
</Style> </Style>
<Style Selector="Window[WindowState=Maximized].fix_maximized_padding"> <Style Selector="Window[WindowState=Maximized].fix_maximized_padding">
<Setter Property="Padding" Value="8,6,8,8"/> <Setter Property="Padding" Value="8,6,8,8"/>
</Style> </Style>
@ -206,7 +206,7 @@
<DropShadowEffect OffsetX="0" OffsetY="0" BlurRadius="4" Color="Black" Opacity=".6"/> <DropShadowEffect OffsetX="0" OffsetY="0" BlurRadius="4" Color="Black" Opacity=".6"/>
</Border.Effect> </Border.Effect>
</Border> </Border>
<Border Name="LayoutRoot" <Border Name="LayoutRoot"
Margin="4" Margin="4"
Padding="12" Padding="12"
@ -318,7 +318,7 @@
<Setter Property="Foreground" Value="DarkOrange"/> <Setter Property="Foreground" Value="DarkOrange"/>
<Setter Property="TextDecorations" Value="Underline"/> <Setter Property="TextDecorations" Value="Underline"/>
</Style> </Style>
<Style Selector="SelectableTextBlock"> <Style Selector="SelectableTextBlock">
<Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
@ -336,7 +336,7 @@
<Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/> <Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/>
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="{DynamicResource Text.CopyAllText}" <MenuItem Header="{DynamicResource Text.CopyAllText}"
Command="{x:Static s:App.CopyTextBlockCommand}" Command="{x:Static s:App.CopyTextBlockCommand}"
CommandParameter="{Binding $parent[SelectableTextBlock]}"> CommandParameter="{Binding $parent[SelectableTextBlock]}">
@ -524,7 +524,7 @@
<Style Selector="Button.flat.primary ToolTip TextBlock"> <Style Selector="Button.flat.primary ToolTip TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/> <Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
</Style> </Style>
<Style Selector="SplitButton"> <Style Selector="SplitButton">
<Setter Property="MinHeight" Value="24"/> <Setter Property="MinHeight" Value="24"/>
<Setter Property="Template"> <Setter Property="Template">
@ -569,17 +569,17 @@
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^:disabled /template/ Button"> <Style Selector="^:disabled /template/ Button">
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border2}"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush.Border2}"/>
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
</Style> </Style>
<Style Selector="^:disabled TextBlock"> <Style Selector="^:disabled TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/> <Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
</Style> </Style>
<Style Selector="^:disabled Path"> <Style Selector="^:disabled Path">
<Setter Property="Fill" Value="{DynamicResource Brush.FG2}"/> <Setter Property="Fill" Value="{DynamicResource Brush.FG2}"/>
</Style> </Style>
@ -737,7 +737,7 @@
<Setter Property="Background" Value="{DynamicResource Brush.Accent}" /> <Setter Property="Background" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Opacity" Value=".8"/> <Setter Property="Opacity" Value=".8"/>
</Style> </Style>
</Style> </Style>
<Style Selector="ContextMenu"> <Style Selector="ContextMenu">
<Setter Property="HorizontalOffset" Value="-4"/> <Setter Property="HorizontalOffset" Value="-4"/>
@ -849,7 +849,7 @@
</DataTemplate> </DataTemplate>
</ContentPresenter.DataTemplates> </ContentPresenter.DataTemplates>
</ContentPresenter> </ContentPresenter>
<TextBlock x:Name="PART_InputGestureText" <TextBlock x:Name="PART_InputGestureText"
Grid.Column="2" Grid.Column="2"
Classes="CaptionTextBlockStyle" Classes="CaptionTextBlockStyle"
@ -871,7 +871,7 @@
Foreground="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}" Foreground="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}"
FontSize="11" FontSize="11"
IsVisible="{TemplateBinding (v:MenuItemExtension.Command), Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> IsVisible="{TemplateBinding (v:MenuItemExtension.Command), Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
<Path Name="PART_ChevronPath" <Path Name="PART_ChevronPath"
Width="6" Width="6"
Data="M573 512 215 881c-20 20-20 51 0 61l61 61c20 20 51 20 61 0l461-461c10-10 10-20 10-31s0-20-10-31L338 20C317 0 287 0 276 20L215 82c-20 20-20 51 0 61L573 512z" Data="M573 512 215 881c-20 20-20 51 0 61l61 61c20 20 51 20 61 0l461-461c10-10 10-20 10-31s0-20-10-31L338 20C317 0 287 0 276 20L215 82c-20 20-20 51 0 61L573 512z"
@ -914,7 +914,7 @@
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^:icon /template/ ContentControl#PART_IconPresenter"> <Style Selector="^:icon /template/ ContentControl#PART_IconPresenter">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
</Style> </Style>
@ -956,7 +956,7 @@
<Style Selector="MenuItem.filter_mode_switcher"> <Style Selector="MenuItem.filter_mode_switcher">
<Setter Property="Height" Value="48"/> <Setter Property="Height" Value="48"/>
<Setter Property="StaysOpenOnClick" Value="True"/> <Setter Property="StaysOpenOnClick" Value="True"/>
<Style Selector="^:selected"> <Style Selector="^:selected">
<Style Selector="^ /template/ Border#PART_LayoutRoot"> <Style Selector="^ /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
@ -1179,7 +1179,7 @@
<Setter Property="Data" Value="M 0 4 L 8 4 L 4 8 Z" /> <Setter Property="Data" Value="M 0 4 L 8 4 L 4 8 Z" />
</Style> </Style>
</Style> </Style>
<Style Selector="ToggleButton.folder"> <Style Selector="ToggleButton.folder">
<Setter Property="Margin" Value="0" /> <Setter Property="Margin" Value="0" />
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
@ -1252,7 +1252,7 @@
<Style Selector="ToggleButton.toggle_untracked:pointerover /template/ Path#PART_IndicatorIcon"> <Style Selector="ToggleButton.toggle_untracked:pointerover /template/ Path#PART_IndicatorIcon">
<Setter Property="Opacity" Value="1"/> <Setter Property="Opacity" Value="1"/>
</Style> </Style>
<Style Selector="ToggleButton.show_as_tree"> <Style Selector="ToggleButton.show_as_tree">
<Setter Property="Margin" Value="0" /> <Setter Property="Margin" Value="0" />
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>
@ -1284,7 +1284,7 @@
<Setter Property="Opacity" Value="1"/> <Setter Property="Opacity" Value="1"/>
</Style> </Style>
</Style> </Style>
<Style Selector="Slider"> <Style Selector="Slider">
<Style.Resources> <Style.Resources>
<Thickness x:Key="SliderTopHeaderMargin">0,0,0,4</Thickness> <Thickness x:Key="SliderTopHeaderMargin">0,0,0,4</Thickness>

View file

@ -55,7 +55,7 @@
<Color x:Key="Color.InlineCode">#FF383838</Color> <Color x:Key="Color.InlineCode">#FF383838</Color>
</ResourceDictionary> </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries> </ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="Brush.Window" Color="{DynamicResource Color.Window}"/> <SolidColorBrush x:Key="Brush.Window" Color="{DynamicResource Color.Window}"/>
<SolidColorBrush x:Key="Brush.WindowBorder" Color="{DynamicResource Color.WindowBorder}"/> <SolidColorBrush x:Key="Brush.WindowBorder" Color="{DynamicResource Color.WindowBorder}"/>
<SolidColorBrush x:Key="Brush.TitleBar" Color="{DynamicResource Color.TitleBar}"/> <SolidColorBrush x:Key="Brush.TitleBar" Color="{DynamicResource Color.TitleBar}"/>

View file

@ -115,7 +115,7 @@ namespace SourceGit.ViewModels
break; break;
} }
} }
} }
} }
private void SetBlameData(string commitSHA) private void SetBlameData(string commitSHA)
@ -145,7 +145,7 @@ namespace SourceGit.ViewModels
} }
}); });
}, token); }, token);
} }
Task.Run(() => Task.Run(() =>
{ {

View file

@ -9,7 +9,7 @@ namespace SourceGit.ViewModels
get; get;
} }
public Models.Branch RemoteBrach public Models.Branch RemoteBranch
{ {
get; get;
} }
@ -35,7 +35,7 @@ namespace SourceGit.ViewModels
{ {
_repo = repo; _repo = repo;
LocalBranch = localBranch; LocalBranch = localBranch;
RemoteBrach = remoteBranch; RemoteBranch = remoteBranch;
} }
public override Task<bool> Sure() public override Task<bool> Sure()
@ -54,7 +54,7 @@ namespace SourceGit.ViewModels
if (DiscardLocalChanges) if (DiscardLocalChanges)
{ {
succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBrach.Head, true, true); succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBranch.Head, true, true);
} }
else else
{ {
@ -72,7 +72,7 @@ namespace SourceGit.ViewModels
needPopStash = true; needPopStash = true;
} }
succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBrach.Head, false, true); succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(LocalBranch.Name, RemoteBranch.Head, false, true);
} }
if (succ) if (succ)

View file

@ -569,14 +569,14 @@ namespace SourceGit.ViewModels
if (!token.IsCancellationRequested) if (!token.IsCancellationRequested)
Dispatcher.UIThread.Invoke(() => FullMessage = new Models.CommitFullMessage { Message = message, Inlines = inlines }); Dispatcher.UIThread.Invoke(() => FullMessage = new Models.CommitFullMessage { Message = message, Inlines = inlines });
}); }, token);
Task.Run(() => Task.Run(() =>
{ {
var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA, !_repo.HasAllowedSignersFile).Result(); var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA, !_repo.HasAllowedSignersFile).Result();
if (!token.IsCancellationRequested) if (!token.IsCancellationRequested)
Dispatcher.UIThread.Invoke(() => SignInfo = signInfo); Dispatcher.UIThread.Invoke(() => SignInfo = signInfo);
}); }, token);
if (Preferences.Instance.ShowChildren) if (Preferences.Instance.ShowChildren)
{ {
@ -587,7 +587,7 @@ namespace SourceGit.ViewModels
var children = cmd.Result(); var children = cmd.Result();
if (!token.IsCancellationRequested) if (!token.IsCancellationRequested)
Dispatcher.UIThread.Post(() => Children = children); Dispatcher.UIThread.Post(() => Children = children);
}); }, token);
} }
Task.Run(() => Task.Run(() =>
@ -617,7 +617,7 @@ namespace SourceGit.ViewModels
SelectedChanges = null; SelectedChanges = null;
}); });
} }
}); }, token);
} }
private Models.InlineElementCollector ParseInlinesInMessage(string message) private Models.InlineElementCollector ParseInlinesInMessage(string message)

View file

@ -29,8 +29,7 @@ namespace SourceGit.ViewModels
public ConfigureWorkspace() public ConfigureWorkspace()
{ {
Workspaces = new AvaloniaList<Workspace>(); Workspaces = new AvaloniaList<Workspace>(Preferences.Instance.Workspaces);
Workspaces.AddRange(Preferences.Instance.Workspaces);
} }
public void Add() public void Add()

View file

@ -65,8 +65,7 @@ namespace SourceGit.ViewModels
public static ValidationResult ValidateTagName(string name, ValidationContext ctx) public static ValidationResult ValidateTagName(string name, ValidationContext ctx)
{ {
var creator = ctx.ObjectInstance as CreateTag; if (ctx.ObjectInstance is CreateTag creator)
if (creator != null)
{ {
var found = creator._repo.Tags.Find(x => x.Name == name); var found = creator._repo.Tags.Find(x => x.Name == name);
if (found != null) if (found != null)

View file

@ -244,7 +244,7 @@ namespace SourceGit.ViewModels
return; return;
} }
} }
if (firstRemoteBranch == null) if (firstRemoteBranch == null)
firstRemoteBranch = remoteBranch; firstRemoteBranch = remoteBranch;
} }
@ -347,7 +347,7 @@ namespace SourceGit.ViewModels
log = _repo.CreateLog("Save as Patch"); log = _repo.CreateLog("Save as Patch");
var folder = picker[0]; var folder = picker[0];
var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString(); var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder.Path.ToString();
var succ = false; var succ = false;
for (var i = 0; i < selected.Count; i++) for (var i = 0; i < selected.Count; i++)
{ {
@ -707,7 +707,7 @@ namespace SourceGit.ViewModels
log = _repo.CreateLog("Save as Patch"); log = _repo.CreateLog("Save as Patch");
var folder = selected[0]; var folder = selected[0];
var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString(); var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder.Path.ToString();
var saveTo = GetPatchFileName(folderPath, commit); var saveTo = GetPatchFileName(folderPath, commit);
var succ = await Task.Run(() => new Commands.FormatPatch(_repo.FullPath, commit.SHA, saveTo).Use(log).Exec()); var succ = await Task.Run(() => new Commands.FormatPatch(_repo.FullPath, commit.SHA, saveTo).Use(log).Exec());
if (succ) if (succ)

View file

@ -4,7 +4,7 @@ namespace SourceGit.ViewModels
{ {
public abstract class InProgressContext public abstract class InProgressContext
{ {
public InProgressContext(string repo, string cmd) protected InProgressContext(string repo, string cmd)
{ {
_repo = repo; _repo = repo;
_cmd = cmd; _cmd = cmd;

View file

@ -106,7 +106,7 @@ namespace SourceGit.ViewModels
set set
{ {
if (SetProperty(ref _selectedItem, value)) if (SetProperty(ref _selectedItem, value))
DetailContext.Commit = value != null ? value.Commit : null; DetailContext.Commit = value?.Commit;
} }
} }

View file

@ -298,15 +298,10 @@ namespace SourceGit.ViewModels
if (removeIdx == activeIdx) if (removeIdx == activeIdx)
{ {
ActivePage = Pages[removeIdx > 0 ? removeIdx - 1 : removeIdx + 1]; ActivePage = Pages[removeIdx > 0 ? removeIdx - 1 : removeIdx + 1];
CloseRepositoryInTab(page);
Pages.RemoveAt(removeIdx);
}
else
{
CloseRepositoryInTab(page);
Pages.RemoveAt(removeIdx);
} }
CloseRepositoryInTab(page);
Pages.RemoveAt(removeIdx);
GC.Collect(); GC.Collect();
} }

View file

@ -71,12 +71,10 @@ namespace SourceGit.ViewModels
} }
else if (t is Models.Commit commit) else if (t is Models.Commit commit)
{ {
var d = commit.Decorators.Find(x => var d = commit.Decorators.Find(x => x.Type is
{ Models.DecoratorType.LocalBranchHead or
return x.Type == Models.DecoratorType.LocalBranchHead || Models.DecoratorType.RemoteBranchHead or
x.Type == Models.DecoratorType.RemoteBranchHead || Models.DecoratorType.Tag);
x.Type == Models.DecoratorType.Tag;
});
if (d != null) if (d != null)
ret.Add(d.Name); ret.Add(d.Name);

View file

@ -736,11 +736,8 @@ namespace SourceGit.ViewModels
{ {
menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(new MenuItem() { Header = "-" });
foreach (var url in urls) foreach (var (name, addr) in urls)
{ {
var name = url.Key;
var addr = url.Value;
var item = new MenuItem(); var item = new MenuItem();
item.Header = App.Text("Repository.Visit", name); item.Header = App.Text("Repository.Visit", name);
item.Icon = App.CreateMenuIcon("Icons.Remotes"); item.Icon = App.CreateMenuIcon("Icons.Remotes");
@ -1342,7 +1339,7 @@ namespace SourceGit.ViewModels
{ {
foreach (var b in _branches) foreach (var b in _branches)
{ {
if (b.IsLocal && if (b.IsLocal &&
b.Upstream.Equals(branch.FullName, StringComparison.Ordinal) && b.Upstream.Equals(branch.FullName, StringComparison.Ordinal) &&
b.TrackStatus.Ahead.Count == 0) b.TrackStatus.Ahead.Count == 0)
{ {
@ -2468,7 +2465,7 @@ namespace SourceGit.ViewModels
public ContextMenu CreateContextMenuForTagSortMode() public ContextMenu CreateContextMenuForTagSortMode()
{ {
var mode = _settings.TagSortMode; var mode = _settings.TagSortMode;
var changeMode = new Action<Models.TagSortMode>((m) => var changeMode = new Action<Models.TagSortMode>(m =>
{ {
if (_settings.TagSortMode != m) if (_settings.TagSortMode != m)
{ {
@ -2746,10 +2743,7 @@ namespace SourceGit.ViewModels
{ {
foreach (var node in nodes) foreach (var node in nodes)
{ {
if (filters.TryGetValue(node.Path, out var value)) node.FilterMode = filters.GetValueOrDefault(node.Path, Models.FilterMode.None);
node.FilterMode = value;
else
node.FilterMode = Models.FilterMode.None;
if (!node.IsBranch) if (!node.IsBranch)
UpdateBranchTreeFilterMode(node.Children, filters); UpdateBranchTreeFilterMode(node.Children, filters);
@ -2760,10 +2754,7 @@ namespace SourceGit.ViewModels
{ {
foreach (var tag in _tags) foreach (var tag in _tags)
{ {
if (filters.TryGetValue(tag.Name, out var value)) tag.FilterMode = filters.GetValueOrDefault(tag.Name, Models.FilterMode.None);
tag.FilterMode = value;
else
tag.FilterMode = Models.FilterMode.None;
} }
} }
@ -2952,7 +2943,7 @@ namespace SourceGit.ViewModels
private List<string> _matchedFilesForSearching = null; private List<string> _matchedFilesForSearching = null;
private string _filter = string.Empty; private string _filter = string.Empty;
private object _lockRemotes = new object(); private readonly Lock _lockRemotes = new();
private List<Models.Remote> _remotes = new List<Models.Remote>(); private List<Models.Remote> _remotes = new List<Models.Remote>();
private List<Models.Branch> _branches = new List<Models.Branch>(); private List<Models.Branch> _branches = new List<Models.Branch>();
private Models.Branch _currentBranch = null; private Models.Branch _currentBranch = null;

View file

@ -156,7 +156,7 @@ namespace SourceGit.ViewModels
foreach (var service in Preferences.Instance.OpenAIServices) foreach (var service in Preferences.Instance.OpenAIServices)
AvailableOpenAIServices.Add(service.Name); AvailableOpenAIServices.Add(service.Name);
if (AvailableOpenAIServices.IndexOf(PreferredOpenAIService) == -1) if (!AvailableOpenAIServices.Contains(PreferredOpenAIService))
PreferredOpenAIService = "---"; PreferredOpenAIService = "---";
_cached = new Commands.Config(repo.FullPath).ListAll(); _cached = new Commands.Config(repo.FullPath).ListAll();

View file

@ -128,14 +128,14 @@ namespace SourceGit.ViewModels
private RepositoryNode FindOrCreateGroupRecursive(List<RepositoryNode> collection, string path) private RepositoryNode FindOrCreateGroupRecursive(List<RepositoryNode> collection, string path)
{ {
var idx = path.IndexOf('/'); RepositoryNode node = null;
if (idx < 0) foreach (var name in path.Split('/'))
return FindOrCreateGroup(collection, path); {
node = FindOrCreateGroup(collection, name);
collection = node.SubNodes;
}
var name = path.Substring(0, idx); return node;
var tail = path.Substring(idx + 1);
var parent = FindOrCreateGroup(collection, name);
return FindOrCreateGroupRecursive(parent.SubNodes, tail);
} }
private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string name) private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string name)

View file

@ -62,7 +62,6 @@
</Button> </Button>
</StackPanel> </StackPanel>
<TextBlock x:Name="TxtCopyright" Margin="0,40,0,0" Foreground="{DynamicResource Brush.FG2}"/> <TextBlock x:Name="TxtCopyright" Margin="0,40,0,0" Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

View file

@ -10,4 +10,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -66,7 +66,7 @@
<Grid Height="26" ColumnDefinitions="26,*,30"> <Grid Height="26" ColumnDefinitions="26,*,30">
<Path Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" HorizontalAlignment="Center" Data="{StaticResource Icons.File}"/> <Path Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" HorizontalAlignment="Center" Data="{StaticResource Icons.File}"/>
<Border Grid.Column="1" Margin="4,0" ClipToBounds="True"> <Border Grid.Column="1" Margin="4,0" ClipToBounds="True">
<TextBlock Grid.Column="1" Text="{Binding}" HorizontalAlignment="Left"/> <TextBlock Text="{Binding}" HorizontalAlignment="Left"/>
</Border> </Border>
<Button Grid.Column="2" Classes="icon_button" Click="OnRemoveButtonClicked"> <Button Grid.Column="2" Classes="icon_button" Click="OnRemoveButtonClicked">
<Path Width="14" Height="14" Data="{StaticResource Icons.Clear}"/> <Path Width="14" Height="14" Data="{StaticResource Icons.Clear}"/>

View file

@ -187,7 +187,7 @@ namespace SourceGit.Views
if (storageFile != null) if (storageFile != null)
{ {
var saveTo = storageFile.Path.LocalPath; var saveTo = storageFile.Path.LocalPath;
using (var writer = File.OpenWrite(saveTo)) await using (var writer = File.OpenWrite(saveTo))
{ {
if (_img != null) if (_img != null)
{ {
@ -201,7 +201,7 @@ namespace SourceGit.Views
using (var rt = new RenderTargetBitmap(pixelSize, dpi)) using (var rt = new RenderTargetBitmap(pixelSize, dpi))
using (var ctx = rt.CreateDrawingContext()) using (var ctx = rt.CreateDrawingContext())
{ {
this.Render(ctx); Render(ctx);
rt.Save(writer); rt.Save(writer);
} }
} }

View file

@ -48,7 +48,7 @@
<Path Grid.Column="0" <Path Grid.Column="0"
Width="14" Height="14" Width="14" Height="14"
Data="{StaticResource Icons.File}"/> Data="{StaticResource Icons.File}"/>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
Margin="4,0,0,0" Margin="4,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -61,7 +61,7 @@
Command="{Binding Back}"> Command="{Binding Back}">
<Path Width="12" Height="12" Data="{StaticResource Icons.TriangleLeft}"/> <Path Width="12" Height="12" Data="{StaticResource Icons.TriangleLeft}"/>
</Button> </Button>
<Button Grid.Column="3" <Button Grid.Column="3"
Classes="icon_button" Classes="icon_button"
IsEnabled="{Binding CanForward}" IsEnabled="{Binding CanForward}"
@ -77,10 +77,10 @@
Margin="0,0,6,0" Margin="0,0,6,0"
Text="{Binding Revision.SHA, Converter={x:Static c:StringConverters.ToShortSHA}, Mode=OneWay}"/> Text="{Binding Revision.SHA, Converter={x:Static c:StringConverters.ToShortSHA}, Mode=OneWay}"/>
<TextBlock Grid.Column="2" <TextBlock Grid.Column="1"
Text="{Binding Revision.Subject}" Text="{Binding Revision.Subject}"
TextTrimming="CharacterEllipsis"/> TextTrimming="CharacterEllipsis"/>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>

View file

@ -102,9 +102,8 @@ namespace SourceGit.Views
var info = _editor.BlameData.LineInfos[lineNumber - 1]; var info = _editor.BlameData.LineInfos[lineNumber - 1];
if (calculated.Contains(info.CommitSHA)) if (!calculated.Add(info.CommitSHA))
continue; continue;
calculated.Add(info.CommitSHA);
var x = 0.0; var x = 0.0;
var shaLink = new FormattedText( var shaLink = new FormattedText(

View file

@ -96,4 +96,3 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
</UserControl> </UserControl>

View file

@ -479,12 +479,12 @@ namespace SourceGit.Views
if (branches.Find(x => x.IsCurrent) != null) if (branches.Find(x => x.IsCurrent) != null)
return; return;
if (branches.Count == 1) if (branches.Count == 1)
repo.DeleteBranch(branches[0]); repo.DeleteBranch(branches[0]);
else else
repo.DeleteMultipleBranches(branches, branches[0].IsLocal); repo.DeleteMultipleBranches(branches, branches[0].IsLocal);
e.Handled = true; e.Handled = true;
} }
@ -537,4 +537,3 @@ namespace SourceGit.Views
private bool _disableSelectionChangingEvent = false; private bool _disableSelectionChangingEvent = false;
} }
} }

View file

@ -47,7 +47,7 @@
Text="{DynamicResource Text.Checkout.WithFastForward.Upstream}"/> Text="{DynamicResource Text.Checkout.WithFastForward.Upstream}"/>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal"> <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
<Path Width="14" Height="14" Margin="4,0" Data="{StaticResource Icons.Branch}"/> <Path Width="14" Height="14" Margin="4,0" Data="{StaticResource Icons.Branch}"/>
<TextBlock Text="{Binding RemoteBrach.FriendlyName}"/> <TextBlock Text="{Binding RemoteBranch.FriendlyName}"/>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="2" Grid.Column="0" <TextBlock Grid.Row="2" Grid.Column="0"

View file

@ -76,8 +76,7 @@
<Border Grid.Column="1" <Border Grid.Column="1"
Background="Transparent" Background="Transparent"
ToolTip.Tip="{DynamicResource Text.CherryPick.Mainline.Tips}"> ToolTip.Tip="{DynamicResource Text.CherryPick.Mainline.Tips}">
<Path Grid.Column="1" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.Info}"/> Data="{StaticResource Icons.Info}"/>
</Border> </Border>
</Grid> </Grid>

View file

@ -19,7 +19,7 @@ namespace SourceGit.Views
} }
// Values are copied from Avalonia: src/Avalonia.Controls.ColorPicker/ColorPalettes/FluentColorPalette.cs // Values are copied from Avalonia: src/Avalonia.Controls.ColorPicker/ColorPalettes/FluentColorPalette.cs
private static readonly Color[,] COLOR_TABLE = new Color[,] private static readonly Color[,] COLOR_TABLE = new[,]
{ {
{ {
Color.FromArgb(255, 255, 67, 67), /* #FF4343 */ Color.FromArgb(255, 255, 67, 67), /* #FF4343 */

View file

@ -61,7 +61,7 @@ namespace SourceGit.Views
private void StopTimer() private void StopTimer()
{ {
if (_refreshTimer is { }) if (_refreshTimer is not null)
{ {
_refreshTimer.Dispose(); _refreshTimer.Dispose();
_refreshTimer = null; _refreshTimer = null;

View file

@ -120,7 +120,7 @@
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/> <Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
</MultiBinding> </MultiBinding>
</ToolTip.IsOpen> </ToolTip.IsOpen>
<TextBlock.DataTemplates> <TextBlock.DataTemplates>
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<StackPanel MinWidth="400" Orientation="Vertical"> <StackPanel MinWidth="400" Orientation="Vertical">
@ -165,7 +165,7 @@
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/> <Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
</MultiBinding> </MultiBinding>
</ToolTip.IsOpen> </ToolTip.IsOpen>
<TextBlock.DataTemplates> <TextBlock.DataTemplates>
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<StackPanel MinWidth="400" Orientation="Vertical"> <StackPanel MinWidth="400" Orientation="Vertical">
@ -209,7 +209,7 @@
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/> <Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
</MultiBinding> </MultiBinding>
</ToolTip.IsOpen> </ToolTip.IsOpen>
<v:CommitMessagePresenter.DataTemplates> <v:CommitMessagePresenter.DataTemplates>
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<StackPanel MinWidth="400" Orientation="Vertical"> <StackPanel MinWidth="400" Orientation="Vertical">

View file

@ -264,8 +264,7 @@ namespace SourceGit.Views
if (currentParent is { DataContext: ViewModels.CommitDetail currentDetail } && if (currentParent is { DataContext: ViewModels.CommitDetail currentDetail } &&
currentDetail.Commit.SHA == lastDetailCommit) currentDetail.Commit.SHA == lastDetailCommit)
{ {
if (!_inlineCommits.ContainsKey(sha)) _inlineCommits.TryAdd(sha, c);
_inlineCommits.Add(sha, c);
// Make sure user still hovers the target SHA. // Make sure user still hovers the target SHA.
if (_lastHover == link && c != null) if (_lastHover == link && c != null)

View file

@ -67,7 +67,7 @@
<Grid ColumnDefinitions="Auto,Auto,Auto,Auto,*" Margin="0,4"> <Grid ColumnDefinitions="Auto,Auto,Auto,Auto,*" Margin="0,4">
<Button Grid.Column="0" <Button Grid.Column="0"
Classes="icon_button" Classes="icon_button"
Width="24" Width="24"
Margin="0,0,4,0" Padding="0" Margin="0,0,4,0" Padding="0"
Click="OnOpenCommitMessagePicker" Click="OnOpenCommitMessagePicker"
IsVisible="{Binding #ThisControl.ShowAdvancedOptions}" IsVisible="{Binding #ThisControl.ShowAdvancedOptions}"
@ -120,4 +120,3 @@
</Grid> </Grid>
</Border> </Border>
</UserControl> </UserControl>

View file

@ -35,7 +35,7 @@ namespace SourceGit.Views
set => SetValue(BehindBrushProperty, value); set => SetValue(BehindBrushProperty, value);
} }
enum Status private enum Status
{ {
Normal, Normal,
Ahead, Ahead,

View file

@ -121,7 +121,7 @@
<Grid RowDefinitions="30,32,30,32,30,Auto,32"> <Grid RowDefinitions="30,32,30,32,30,Auto,32">
<TextBlock Grid.Row="0" Margin="0,0,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Name}" VerticalAlignment="Bottom"/> <TextBlock Grid.Row="0" Margin="0,0,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Name}" VerticalAlignment="Bottom"/>
<TextBox Grid.Row="1" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/> <TextBox Grid.Row="1" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" Margin="0,0,0,4" Text="{DynamicResource Text.Preferences.Git.DefaultCloneDir}" VerticalAlignment="Bottom"/> <TextBlock Grid.Row="2" Margin="0,0,0,4" Text="{DynamicResource Text.Preferences.Git.DefaultCloneDir}" VerticalAlignment="Bottom"/>
<TextBox Grid.Row="3" CornerRadius="3" Height="28" Text="{Binding DefaultCloneDir, Mode=TwoWay}"> <TextBox Grid.Row="3" CornerRadius="3" Height="28" Text="{Binding DefaultCloneDir, Mode=TwoWay}">
<TextBox.InnerRightContent> <TextBox.InnerRightContent>
@ -130,10 +130,10 @@
</Button> </Button>
</TextBox.InnerRightContent> </TextBox.InnerRightContent>
</TextBox> </TextBox>
<TextBlock Grid.Row="4" Margin="0,0,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Color}" VerticalAlignment="Bottom"/> <TextBlock Grid.Row="4" Margin="0,0,0,4" Text="{DynamicResource Text.ConfigureWorkspace.Color}" VerticalAlignment="Bottom"/>
<v:ColorPicker Grid.Row="5" HorizontalAlignment="Left" Value="{Binding Color, Mode=TwoWay}"/> <v:ColorPicker Grid.Row="5" HorizontalAlignment="Left" Value="{Binding Color, Mode=TwoWay}"/>
<CheckBox Grid.Row="6" <CheckBox Grid.Row="6"
Content="{DynamicResource Text.ConfigureWorkspace.Restore}" Content="{DynamicResource Text.ConfigureWorkspace.Restore}"
IsChecked="{Binding RestoreOnStartup, Mode=TwoWay}"/> IsChecked="{Binding RestoreOnStartup, Mode=TwoWay}"/>

View file

@ -14,15 +14,15 @@
<StackPanel Orientation="Vertical" IsVisible="{Binding !IsResolved}"> <StackPanel Orientation="Vertical" IsVisible="{Binding !IsResolved}">
<Path Width="64" Height="64" Data="{StaticResource Icons.Conflict}" Fill="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/> <Path Width="64" Height="64" Data="{StaticResource Icons.Conflict}" Fill="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<TextBlock Margin="0,16" FontSize="20" FontWeight="Bold" Text="{DynamicResource Text.WorkingCopy.Conflicts}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/> <TextBlock Margin="0,16" FontSize="20" FontWeight="Bold" Text="{DynamicResource Text.WorkingCopy.Conflicts}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,8"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,8">
<Border Height="16" VerticalAlignment="Center" Background="Red" CornerRadius="8"> <Border Height="16" VerticalAlignment="Center" Background="Red" CornerRadius="8">
<TextBlock Classes="primary" Text="{Binding Marker}" Foreground="White" FontWeight="Bold" Margin="8,0" FontSize="10"/> <TextBlock Classes="primary" Text="{Binding Marker}" Foreground="White" FontWeight="Bold" Margin="8,0" FontSize="10"/>
</Border> </Border>
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center" Text="{Binding Description}"/> <TextBlock Margin="8,0,0,0" VerticalAlignment="Center" Text="{Binding Description}"/>
</StackPanel> </StackPanel>
<Border Margin="16,0" Padding="8" CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"> <Border Margin="16,0" Padding="8" CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<Border.DataTemplates> <Border.DataTemplates>
<DataTemplate DataType="vm:ConflictSourceBranch"> <DataTemplate DataType="vm:ConflictSourceBranch">
@ -96,7 +96,7 @@
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</Border.DataTemplates> </Border.DataTemplates>
<Border.IsVisible> <Border.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}"> <MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="Theirs" Converter="{x:Static ObjectConverters.IsNotNull}"/> <Binding Path="Theirs" Converter="{x:Static ObjectConverters.IsNotNull}"/>

View file

@ -56,11 +56,11 @@
<TextBlock Text="{Binding Name}" Margin="0,0,8,0"/> <TextBlock Text="{Binding Name}" Margin="0,0,8,0"/>
<Border Height="16" CornerRadius="8" Padding="8,0" VerticalAlignment="Center" Background="Green"> <Border Height="16" CornerRadius="8" Padding="8,0" VerticalAlignment="Center" Background="Green">
<TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/> <TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/>
</Border> </Border>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ComboBox.SelectionBoxItemTemplate> </ComboBox.SelectionBoxItemTemplate>
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="m:ConventionalCommitType"> <DataTemplate DataType="m:ConventionalCommitType">
<Grid Height="22"> <Grid Height="22">

View file

@ -10,4 +10,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -51,7 +51,7 @@ namespace SourceGit.Views
options.DefaultExtension = ".patch"; options.DefaultExtension = ".patch";
options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }]; options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
var storageFile = await this.StorageProvider.SaveFilePickerAsync(options); var storageFile = await StorageProvider.SaveFilePickerAsync(options);
if (storageFile != null) if (storageFile != null)
await compare.SaveAsPatch(storageFile.Path.LocalPath); await compare.SaveAsPatch(storageFile.Path.LocalPath);

View file

@ -163,5 +163,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -133,7 +133,7 @@
AheadBrush="{DynamicResource Brush.Accent}" AheadBrush="{DynamicResource Brush.Accent}"
BehindBrush="{DynamicResource Brush.FG1}" BehindBrush="{DynamicResource Brush.FG1}"
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
<v:BisectStateIndicator Grid.Column="1" <v:BisectStateIndicator Grid.Column="1"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"

View file

@ -141,7 +141,7 @@ namespace SourceGit.Views
if (DataContext is ViewModels.Histories) if (DataContext is ViewModels.Histories)
{ {
var list = CommitListContainer; var list = CommitListContainer;
if (list != null && list.SelectedItems.Count == 1) if (list is { SelectedItems.Count: 1 })
list.ScrollIntoView(list.SelectedIndex); list.ScrollIntoView(list.SelectedIndex);
} }
} }
@ -170,7 +170,7 @@ namespace SourceGit.Views
private void OnCommitListContextRequested(object sender, ContextRequestedEventArgs e) private void OnCommitListContextRequested(object sender, ContextRequestedEventArgs e)
{ {
if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: > 0 } } list) if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems.Count: > 0 } list)
{ {
var menu = histories.MakeContextMenu(list); var menu = histories.MakeContextMenu(list);
menu?.Open(list); menu?.Open(list);
@ -180,7 +180,7 @@ namespace SourceGit.Views
private void OnCommitListDoubleTapped(object sender, TappedEventArgs e) private void OnCommitListDoubleTapped(object sender, TappedEventArgs e)
{ {
if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: 1 } }) if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems.Count: 1 })
{ {
var source = e.Source as Control; var source = e.Source as Control;
var item = source.FindAncestorOfType<ListBoxItem>(); var item = source.FindAncestorOfType<ListBoxItem>();

View file

@ -69,10 +69,10 @@
<TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/> <TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/>
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" /> <TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" />
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+P, macOS=⌘+⇧+P}"/> <TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+P, macOS=⌘+⇧+P}"/>
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchWorkspace}" /> <TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchWorkspace}" />
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+P, macOS=⌘+P}"/> <TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+P, macOS=⌘+P}"/>
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchTab}" /> <TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchTab}" />
</Grid> </Grid>

View file

@ -102,7 +102,7 @@
</DataTemplate> </DataTemplate>
</ContentControl.DataTemplates> </ContentControl.DataTemplates>
</ContentControl> </ContentControl>
<!-- Workspace/Pages Switcher --> <!-- Workspace/Pages Switcher -->
<Border Grid.Row="0" Grid.RowSpan="2" <Border Grid.Row="0" Grid.RowSpan="2"
Background="Transparent" Background="Transparent"
@ -115,7 +115,7 @@
<DataTemplate DataType="vm:WorkspaceSwitcher"> <DataTemplate DataType="vm:WorkspaceSwitcher">
<v:WorkspaceSwitcher/> <v:WorkspaceSwitcher/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="vm:LauncherPageSwitcher"> <DataTemplate DataType="vm:LauncherPageSwitcher">
<v:LauncherPageSwitcher/> <v:LauncherPageSwitcher/>
</DataTemplate> </DataTemplate>

View file

@ -13,7 +13,7 @@
Text="{DynamicResource Text.Launcher.Pages}" Text="{DynamicResource Text.Launcher.Pages}"
FontWeight="Bold" FontWeight="Bold"
HorizontalAlignment="Center"/> HorizontalAlignment="Center"/>
<TextBox Grid.Row="1" <TextBox Grid.Row="1"
Height="24" Height="24"
Margin="4,8,4,0" Margin="4,8,4,0"

View file

@ -46,4 +46,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -80,7 +80,7 @@
VerticalAlignment="Center" VerticalAlignment="Center"
IsVisible="{Binding DirtyBrush, Converter={x:Static ObjectConverters.IsNotNull}}" IsVisible="{Binding DirtyBrush, Converter={x:Static ObjectConverters.IsNotNull}}"
Fill="{Binding DirtyBrush}"/> Fill="{Binding DirtyBrush}"/>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
Classes="primary" Classes="primary"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -89,7 +89,7 @@
Text="{Binding Node.Name}" Text="{Binding Node.Name}"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
</Grid> </Grid>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
Classes="primary" Classes="primary"
HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center"
@ -98,7 +98,7 @@
Text="{DynamicResource Text.PageTabBar.Welcome.Title}" Text="{DynamicResource Text.PageTabBar.Welcome.Title}"
IsVisible="{Binding !Node.IsRepository}" IsVisible="{Binding !Node.IsRepository}"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<Button Grid.Column="2" <Button Grid.Column="2"
Classes="icon_button" Classes="icon_button"
Width="16" Height="16" Margin="12,0" Width="16" Height="16" Margin="12,0"

View file

@ -98,7 +98,6 @@ namespace SourceGit.Views
ctx.BeginFigure(new Point(x, y), true); ctx.BeginFigure(new Point(x, y), true);
y = 1; y = 1;
ctx.LineTo(new Point(x, y)); ctx.LineTo(new Point(x, y));
x = drawRightX - 6;
} }
else else
{ {
@ -112,9 +111,10 @@ namespace SourceGit.Views
x += 6; x += 6;
y = 1; y = 1;
ctx.ArcTo(new Point(x, y), new Size(6, 6), angle, false, SweepDirection.Clockwise); ctx.ArcTo(new Point(x, y), new Size(6, 6), angle, false, SweepDirection.Clockwise);
x = drawRightX - 6;
} }
x = drawRightX - 6;
if (drawRightX <= LauncherTabsScroller.Bounds.Right) if (drawRightX <= LauncherTabsScroller.Bounds.Right)
{ {
ctx.LineTo(new Point(x, y)); ctx.LineTo(new Point(x, y));

View file

@ -10,5 +10,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -95,20 +95,15 @@ namespace SourceGit.Views
normalTypeface, normalTypeface,
FontSize, FontSize,
Foreground); Foreground);
context.DrawText(formatted, new Point(offsetX, 0));
if (isName) if (isName)
{ {
var lineY = formatted.Baseline + 2; var lineY = formatted.Baseline + 2;
context.DrawText(formatted, new Point(offsetX, 0));
context.DrawLine(underlinePen, new Point(offsetX, lineY), new Point(offsetX + formatted.Width, lineY)); context.DrawLine(underlinePen, new Point(offsetX, lineY), new Point(offsetX + formatted.Width, lineY));
offsetX += formatted.WidthIncludingTrailingWhitespace;
}
else
{
context.DrawText(formatted, new Point(offsetX, 0));
offsetX += formatted.WidthIncludingTrailingWhitespace;
} }
offsetX += formatted.WidthIncludingTrailingWhitespace;
isName = !isName; isName = !isName;
} }
} }

View file

@ -178,7 +178,7 @@ namespace SourceGit.Views
SetIfChanged(config, "user.name", DefaultUser, ""); SetIfChanged(config, "user.name", DefaultUser, "");
SetIfChanged(config, "user.email", DefaultEmail, ""); SetIfChanged(config, "user.email", DefaultEmail, "");
SetIfChanged(config, "user.signingkey", GPGUserKey, ""); SetIfChanged(config, "user.signingkey", GPGUserKey, "");
SetIfChanged(config, "core.autocrlf", CRLFMode != null ? CRLFMode.Value : null, null); SetIfChanged(config, "core.autocrlf", CRLFMode?.Value, null);
SetIfChanged(config, "fetch.prune", EnablePruneOnFetch ? "true" : "false", "false"); SetIfChanged(config, "fetch.prune", EnablePruneOnFetch ? "true" : "false", "false");
SetIfChanged(config, "commit.gpgsign", EnableGPGCommitSigning ? "true" : "false", "false"); SetIfChanged(config, "commit.gpgsign", EnableGPGCommitSigning ? "true" : "false", "false");
SetIfChanged(config, "tag.gpgsign", EnableGPGTagSigning ? "true" : "false", "false"); SetIfChanged(config, "tag.gpgsign", EnableGPGTagSigning ? "true" : "false", "false");

View file

@ -769,7 +769,7 @@
Click="OnBisectCommand" Click="OnBisectCommand"
Tag="reset"/> Tag="reset"/>
</Grid> </Grid>
<Border Grid.Row="2" Background="{DynamicResource Brush.ToolBar}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"> <Border Grid.Row="2" Background="{DynamicResource Brush.ToolBar}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}">
<Border.IsVisible> <Border.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}"> <MultiBinding Converter="{x:Static BoolConverters.And}">

View file

@ -208,7 +208,7 @@ namespace SourceGit.Views
private void OnWorktreeListPropertyChanged(object _, AvaloniaPropertyChangedEventArgs e) private void OnWorktreeListPropertyChanged(object _, AvaloniaPropertyChangedEventArgs e)
{ {
if (e.Property == ListBox.ItemsSourceProperty || e.Property == ListBox.IsVisibleProperty) if (e.Property == ItemsControl.ItemsSourceProperty || e.Property == IsVisibleProperty)
UpdateLeftSidebarLayout(); UpdateLeftSidebarLayout();
} }
@ -221,7 +221,7 @@ namespace SourceGit.Views
private void UpdateLeftSidebarLayout() private void UpdateLeftSidebarLayout()
{ {
var vm = DataContext as ViewModels.Repository; var vm = DataContext as ViewModels.Repository;
if (vm == null || vm.Settings == null) if (vm?.Settings == null)
return; return;
if (!IsLoaded) if (!IsLoaded)

View file

@ -102,7 +102,7 @@
<Button Classes="icon_button" Width="32" Margin="8,0,0,0" Command="{Binding Cleanup}" ToolTip.Tip="{DynamicResource Text.Repository.Clean}"> <Button Classes="icon_button" Width="32" Margin="8,0,0,0" Command="{Binding Cleanup}" ToolTip.Tip="{DynamicResource Text.Repository.Clean}">
<Path Width="14" Height="14" Margin="0,1,0,0" Data="{StaticResource Icons.Clean}"/> <Path Width="14" Height="14" Margin="0,1,0,0" Data="{StaticResource Icons.Clean}"/>
</Button> </Button>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,4,0"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,4,0">
@ -132,4 +132,3 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -152,4 +152,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -45,7 +45,7 @@
KeyDown="OnResetModeKeyDown"> KeyDown="OnResetModeKeyDown">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="m:ResetMode"> <DataTemplate DataType="m:ResetMode">
<Grid ColumnDefinitions="16,60,*"> <Grid ColumnDefinitions="16,60,*,*">
<Ellipse Grid.Column="0" Width="12" Height="12" Fill="{Binding Color}"/> <Ellipse Grid.Column="0" Width="12" Height="12" Fill="{Binding Color}"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2,0,0,0"/> <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2,0,0,0"/>
<TextBlock Grid.Column="2" Text="{Binding Desc}" Margin="2,0,16,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/> <TextBlock Grid.Column="2" Text="{Binding Desc}" Margin="2,0,16,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>

View file

@ -97,4 +97,3 @@
</DataTemplate> </DataTemplate>
</UserControl.DataTemplates> </UserControl.DataTemplates>
</UserControl> </UserControl>

View file

@ -163,4 +163,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -157,7 +157,7 @@ namespace SourceGit.Views
else else
{ {
var vm = DataContext as ViewModels.CommitDetail; var vm = DataContext as ViewModels.CommitDetail;
if (vm == null || vm.Commit == null) if (vm?.Commit == null)
return; return;
var objects = vm.GetRevisionFilesUnderFolder(file); var objects = vm.GetRevisionFilesUnderFolder(file);
@ -254,7 +254,7 @@ namespace SourceGit.Views
_searchResult.Clear(); _searchResult.Clear();
var vm = DataContext as ViewModels.CommitDetail; var vm = DataContext as ViewModels.CommitDetail;
if (vm == null || vm.Commit == null) if (vm?.Commit == null)
{ {
GC.Collect(); GC.Collect();
return; return;

View file

@ -144,7 +144,7 @@
</ToggleButton> </ToggleButton>
</Grid> </Grid>
</Border> </Border>
<v:RevisionFileContentViewer Grid.Row="1" Content="{Binding ViewRevisionFileContent}"/> <v:RevisionFileContentViewer Grid.Row="1" Content="{Binding ViewRevisionFileContent}"/>
</Grid> </Grid>
</Border> </Border>

View file

@ -25,7 +25,6 @@ namespace SourceGit.Views
TextArea.TextView.Margin = new Thickness(4, 0); TextArea.TextView.Margin = new Thickness(4, 0);
TextArea.TextView.Options.EnableHyperlinks = false; TextArea.TextView.Options.EnableHyperlinks = false;
TextArea.TextView.Options.EnableEmailHyperlinks = false; TextArea.TextView.Options.EnableEmailHyperlinks = false;
} }
protected override void OnLoaded(RoutedEventArgs e) protected override void OnLoaded(RoutedEventArgs e)

View file

@ -203,7 +203,7 @@
</Grid> </Grid>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Grid ColumnDefinitions="16,*,Auto" Margin="8,0,0,0" VerticalAlignment="Center"> <Grid ColumnDefinitions="16,*,Auto" Margin="8,0,0,0" VerticalAlignment="Center">
<Path Grid.Column="0" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Submodule}"/> <Path Grid.Column="0" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Submodule}"/>
<TextBlock Grid.Column="1" Text="{Binding Path}" ClipToBounds="True" Classes="primary" TextTrimming="CharacterEllipsis"/> <TextBlock Grid.Column="1" Text="{Binding Path}" ClipToBounds="True" Classes="primary" TextTrimming="CharacterEllipsis"/>

View file

@ -41,7 +41,7 @@
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListBox.DataTemplates> </ListBox.DataTemplates>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate DataType="vm:TagTreeNode"> <DataTemplate DataType="vm:TagTreeNode">
<Border Height="24" <Border Height="24"
@ -50,7 +50,7 @@
DoubleTapped="OnItemDoubleTapped" DoubleTapped="OnItemDoubleTapped"
ContextRequested="OnItemContextRequested" ContextRequested="OnItemContextRequested"
ToolTip.Tip="{Binding ToolTip}" ToolTip.Tip="{Binding ToolTip}"
ToolTip.Placement="Right"> ToolTip.Placement="Right">
<Grid ColumnDefinitions="16,Auto,*,Auto" <Grid ColumnDefinitions="16,Auto,*,Auto"
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}" Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
VerticalAlignment="Center"> VerticalAlignment="Center">
@ -111,7 +111,7 @@
<TextBlock Text="{Binding Message}" IsVisible="{Binding Message, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> <TextBlock Text="{Binding Message}" IsVisible="{Binding Message, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel> </StackPanel>
</ToolTip.Tip> </ToolTip.Tip>
<Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center"> <Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center">
<Path Grid.Column="0" <Path Grid.Column="0"
Margin="8,0,0,0" Margin="8,0,0,0"
@ -133,4 +133,3 @@
</DataTemplate> </DataTemplate>
</UserControl.DataTemplates> </UserControl.DataTemplates>
</UserControl> </UserControl>

View file

@ -230,4 +230,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -765,12 +765,10 @@ namespace SourceGit.Views
} }
else if (change.Property == BlockNavigationProperty) else if (change.Property == BlockNavigationProperty)
{ {
var oldValue = change.OldValue as ViewModels.BlockNavigation; if (change.OldValue is ViewModels.BlockNavigation oldValue)
if (oldValue != null)
oldValue.PropertyChanged -= OnBlockNavigationPropertyChanged; oldValue.PropertyChanged -= OnBlockNavigationPropertyChanged;
var newValue = change.NewValue as ViewModels.BlockNavigation; if (change.NewValue is ViewModels.BlockNavigation newValue)
if (newValue != null)
newValue.PropertyChanged += OnBlockNavigationPropertyChanged; newValue.PropertyChanged += OnBlockNavigationPropertyChanged;
TextArea?.TextView?.Redraw(); TextArea?.TextView?.Redraw();
@ -1251,8 +1249,7 @@ namespace SourceGit.Views
{ {
base.OnDataContextChanged(e); base.OnDataContextChanged(e);
var textDiff = DataContext as Models.TextDiff; if (DataContext is Models.TextDiff textDiff)
if (textDiff != null)
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
foreach (var line in textDiff.Lines) foreach (var line in textDiff.Lines)
@ -1410,8 +1407,7 @@ namespace SourceGit.Views
return; return;
} }
var textDiff = this.FindAncestorOfType<TextDiffView>()?.DataContext as Models.TextDiff; if (this.FindAncestorOfType<TextDiffView>()?.DataContext is Models.TextDiff textDiff)
if (textDiff != null)
{ {
var lineIdx = -1; var lineIdx = -1;
foreach (var line in view.VisualLines) foreach (var line in view.VisualLines)
@ -1537,7 +1533,7 @@ namespace SourceGit.Views
private void DirectSyncScrollOffset() private void DirectSyncScrollOffset()
{ {
if (_scrollViewer is { } && DataContext is ViewModels.TwoSideTextDiff diff) if (_scrollViewer is not null && DataContext is ViewModels.TwoSideTextDiff diff)
diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero; diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero;
} }

View file

@ -44,7 +44,7 @@
<ColumnDefinition Width="4"/> <ColumnDefinition Width="4"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ListBox Grid.Column="0" <ListBox Grid.Column="0"
Padding="4" Padding="4"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
@ -84,14 +84,14 @@
Width="14" Height="14" Width="14" Height="14"
Margin="4,0,4,0" Margin="4,0,4,0"
IsVisible="{Binding !IsComplete}"/> IsVisible="{Binding !IsComplete}"/>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
Classes="primary" Classes="primary"
Margin="4,0,0,0" Margin="4,0,0,0"
Text="{Binding Name}" Text="{Binding Name}"
VerticalAlignment="Center" VerticalAlignment="Center"
TextTrimming="CharacterEllipsis"/> TextTrimming="CharacterEllipsis"/>
<v:CommandLogTime Grid.Column="2" <v:CommandLogTime Grid.Column="2"
Classes="primary" Classes="primary"
Margin="4,0" Margin="4,0"

View file

@ -14,7 +14,7 @@
<ColumnDefinition Width="2*" MinWidth="600"/> <ColumnDefinition Width="2*" MinWidth="600"/>
<ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Managed Repositories --> <!-- Managed Repositories -->
<Grid Grid.Row="0" Grid.Column="1" Margin="8" RowDefinitions="Auto,*"> <Grid Grid.Row="0" Grid.Column="1" Margin="8" RowDefinitions="Auto,*">
<!-- Search Box --> <!-- Search Box -->

View file

@ -215,16 +215,8 @@ namespace SourceGit.Views
if (to == null) if (to == null)
return; return;
if (to.IsRepository) e.DragEffects = to.IsRepository ? DragDropEffects.None : DragDropEffects.Move;
{ e.Handled = true;
e.DragEffects = DragDropEffects.None;
e.Handled = true;
}
else
{
e.DragEffects = DragDropEffects.Move;
e.Handled = true;
}
} }
} }

View file

@ -32,4 +32,3 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -50,4 +50,3 @@ namespace SourceGit.Views
} }
} }
} }

View file

@ -168,7 +168,7 @@
ViewMode="{Binding Source={x:Static vm:Preferences.Instance}, Path=StagedChangeViewMode, Mode=TwoWay}"/> ViewMode="{Binding Source={x:Static vm:Preferences.Instance}, Path=StagedChangeViewMode, Mode=TwoWay}"/>
</Grid> </Grid>
</Border> </Border>
<!-- Staged Changes --> <!-- Staged Changes -->
<v:ChangeCollectionView Grid.Row="1" <v:ChangeCollectionView Grid.Row="1"
x:Name="StagedChangesView" x:Name="StagedChangesView"
@ -357,7 +357,7 @@
<Binding Path="CommitMessage" Converter="{x:Static c:StringConverters.IsNotNullOrWhitespace}"/> <Binding Path="CommitMessage" Converter="{x:Static c:StringConverters.IsNotNullOrWhitespace}"/>
</MultiBinding> </MultiBinding>
</Button.IsEnabled> </Button.IsEnabled>
<Button.IsVisible> <Button.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}"> <MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="HasRemotes"/> <Binding Path="HasRemotes"/>

View file

@ -12,7 +12,7 @@
Text="{DynamicResource Text.Launcher.Workspaces}" Text="{DynamicResource Text.Launcher.Workspaces}"
FontWeight="Bold" FontWeight="Bold"
HorizontalAlignment="Center"/> HorizontalAlignment="Center"/>
<TextBox Grid.Row="1" <TextBox Grid.Row="1"
Height="24" Height="24"
Margin="4,8,4,0" Margin="4,8,4,0"
@ -108,4 +108,3 @@
</ListBox> </ListBox>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -46,4 +46,3 @@ namespace SourceGit.Views
} }
} }
} }