From 52c7388a38b73ed6ab8862bca4213073dd947f33 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 16 Nov 2024 16:06:30 +0800 Subject: [PATCH 1/2] project: upgrade to .NET 9 (#694) Signed-off-by: leo --- .github/workflows/build.yml | 2 +- global.json | 2 +- src/SourceGit.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad62efb6..d4117364 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Configure arm64 packages if: ${{ matrix.runtime == 'linux-arm64' }} run: | diff --git a/global.json b/global.json index b5b37b60..a27a2b82 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "9.0.0", "rollForward": "latestMajor", "allowPrerelease": false } diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 2fa4eb84..a5a97df9 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -1,7 +1,7 @@  WinExe - net8.0 + net9.0 true App.manifest App.ico From 882878dbe5383cc65acd3050af1c4ff955621e1d Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 16 Nov 2024 18:24:37 +0800 Subject: [PATCH 2/2] refactor: text diff view go to next/prev change Signed-off-by: leo --- src/Views/TextDiffView.axaml.cs | 42 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index fb2693a8..bf4ffe60 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -516,11 +516,16 @@ namespace SourceGit.Views firstLineIdx = index; } + if (firstLineIdx <= 1) + return; + var firstLineType = lines[firstLineIdx].Type; + var prevLineType = lines[firstLineIdx - 1].Type; var isChangeFirstLine = firstLineType != Models.TextDiffLineType.Normal && firstLineType != Models.TextDiffLineType.Indicator; - if (isChangeFirstLine) + var isChangePrevLine = prevLineType != Models.TextDiffLineType.Normal && prevLineType != Models.TextDiffLineType.Indicator; + if (isChangeFirstLine && isChangePrevLine) { - for (var i = firstLineIdx - 1; i >= 0; i--) + for (var i = firstLineIdx - 2; i >= 0; i--) { var prevType = lines[i].Type; if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator) @@ -530,33 +535,23 @@ namespace SourceGit.Views } } } - else + + var findChange = false; + for (var i = firstLineIdx - 1; i >= 0; i--) { - var prevChangeEnd = -1; - for (var i = firstLineIdx - 1; i >= 0; i--) + var prevType = lines[i].Type; + if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator) { - var prevType = lines[i].Type; - if (prevType == Models.TextDiffLineType.None || - prevType == Models.TextDiffLineType.Added || - prevType == Models.TextDiffLineType.Deleted) - { - prevChangeEnd = i; - break; - } - } - - if (prevChangeEnd <= 0) - return; - - for (var i = prevChangeEnd - 1; i >= 0; i--) - { - var prevType = lines[i].Type; - if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator) + if (findChange) { ScrollToLine(i + 2); return; } } + else if (!findChange) + { + findChange = true; + } } } @@ -578,6 +573,9 @@ namespace SourceGit.Views lastLineIdx = index; } + if (lastLineIdx >= lines.Count - 1) + return; + var lastLineType = lines[lastLineIdx].Type; var findNormalLine = lastLineType == Models.TextDiffLineType.Normal || lastLineType == Models.TextDiffLineType.Indicator; for (var idx = lastLineIdx + 1; idx < lines.Count; idx++)