diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 04103d68..cb9e6a18 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -129,7 +129,7 @@ namespace SourceGit.Commands _oldLine = int.Parse(match.Groups[1].Value); _newLine = int.Parse(match.Groups[2].Value); _result.TextDiff.Lines.Add(new Models.TextDiffLine(Models.TextDiffLineType.Indicator, line, 0, 0)); - } + } } else { diff --git a/src/Commands/ExecuteCustomAction.cs b/src/Commands/ExecuteCustomAction.cs index f5fec82c..4981b2f9 100644 --- a/src/Commands/ExecuteCustomAction.cs +++ b/src/Commands/ExecuteCustomAction.cs @@ -44,7 +44,7 @@ namespace SourceGit.Commands { outputHandler?.Invoke(e.Data); builder.AppendLine(e.Data); - } + } }; try diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index e56ea3fd..71b9ddb6 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -118,7 +118,7 @@ namespace SourceGit.ViewModels var trimmedUrl = url; if (url.EndsWith(".git")) trimmedUrl = url.Substring(0, url.Length - 4); - + if (url.StartsWith("https://github.com/", StringComparison.Ordinal)) WebLinks.Add(new Models.CommitLink() { Name = $"Github ({trimmedUrl.Substring(19)})", URLPrefix = $"{url}/commit/" }); else if (url.StartsWith("https://gitlab.", StringComparison.Ordinal)) diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 9f436346..85092b64 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -192,35 +192,26 @@ namespace SourceGit.Views if (string.IsNullOrEmpty(subject)) return; - var offset = 0; var keywordMatch = REG_KEYWORD_FORMAT1().Match(subject); if (!keywordMatch.Success) keywordMatch = REG_KEYWORD_FORMAT2().Match(subject); - if (keywordMatch.Success) - { - var keyword = new Run(subject.Substring(0, keywordMatch.Length)); - keyword.FontWeight = FontWeight.Bold; - Inlines.Add(keyword); - - offset = keywordMatch.Length; - subject = subject.Substring(offset); - } - - var rules = IssueTrackerRules; - if (rules == null || rules.Count == 0) - { - Inlines.Add(new Run(subject)); - return; - } - + var rules = IssueTrackerRules ?? []; var matches = new List(); foreach (var rule in rules) rule.Matches(matches, subject); if (matches.Count == 0) { - Inlines.Add(new Run(subject)); + if (keywordMatch.Success) + { + Inlines.Add(new Run(subject.Substring(0, keywordMatch.Length)) { FontWeight = FontWeight.Bold }); + Inlines.Add(new Run(subject.Substring(keywordMatch.Length))); + } + else + { + Inlines.Add(new Run(subject)); + } return; } @@ -232,18 +223,44 @@ namespace SourceGit.Views foreach (var match in matches) { if (match.Start > pos) - inlines.Add(new Run(subject.Substring(pos, match.Start - pos))); + { + if (keywordMatch.Success && pos < keywordMatch.Length) + { + if (keywordMatch.Length < match.Start) + { + inlines.Add(new Run(subject.Substring(pos, keywordMatch.Length - pos)) { FontWeight = FontWeight.Bold }); + inlines.Add(new Run(subject.Substring(keywordMatch.Length, match.Start - keywordMatch.Length))); + } + else + { + inlines.Add(new Run(subject.Substring(pos, match.Start - pos)) { FontWeight = FontWeight.Bold }); + } + } + else + { + inlines.Add(new Run(subject.Substring(pos, match.Start - pos))); + } + } var link = new Run(subject.Substring(match.Start, match.Length)); link.Classes.Add("issue_link"); inlines.Add(link); pos = match.Start + match.Length; - match.Start += offset; // Because we use this index of whole subject to detect mouse event. } if (pos < subject.Length) - inlines.Add(new Run(subject.Substring(pos))); + { + if (keywordMatch.Success && pos < keywordMatch.Length) + { + inlines.Add(new Run(subject.Substring(pos, keywordMatch.Length - pos)) { FontWeight = FontWeight.Bold }); + inlines.Add(new Run(subject.Substring(keywordMatch.Length))); + } + else + { + inlines.Add(new Run(subject.Substring(pos))); + } + } Inlines.AddRange(inlines); } diff --git a/src/Views/RepositoryToolbar.axaml.cs b/src/Views/RepositoryToolbar.axaml.cs index e2c7df8c..afc8ac5a 100644 --- a/src/Views/RepositoryToolbar.axaml.cs +++ b/src/Views/RepositoryToolbar.axaml.cs @@ -52,7 +52,7 @@ namespace SourceGit.Views var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); if (!startDirectly && OperatingSystem.IsMacOS()) startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); - + repo.Fetch(startDirectly); e.Handled = true; } @@ -66,7 +66,7 @@ namespace SourceGit.Views var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); if (!startDirectly && OperatingSystem.IsMacOS()) startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); - + repo.Pull(startDirectly); e.Handled = true; } @@ -80,7 +80,7 @@ namespace SourceGit.Views var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); if (!startDirectly && OperatingSystem.IsMacOS()) startDirectly = launcher.HasKeyModifier(KeyModifiers.Meta); - + repo.Push(startDirectly); e.Handled = true; }