Compare commits

..

No commits in common. "882878dbe5383cc65acd3050af1c4ff955621e1d" and "4b6bb70f20861ac9e52a300767f0d801425a04d7" have entirely different histories.

9 changed files with 51 additions and 191 deletions

View file

@ -32,7 +32,7 @@ jobs:
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 9.0.x dotnet-version: 8.0.x
- name: Configure arm64 packages - name: Configure arm64 packages
if: ${{ matrix.runtime == 'linux-arm64' }} if: ${{ matrix.runtime == 'linux-arm64' }}
run: | run: |

View file

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "9.0.0", "version": "8.0.0",
"rollForward": "latestMajor", "rollForward": "latestMajor",
"allowPrerelease": false "allowPrerelease": false
} }

View file

@ -28,9 +28,9 @@ namespace SourceGit.Commands
Context = repo; Context = repo;
if (ignoreWhitespace) if (ignoreWhitespace)
Args = $"diff --no-ext-diff --patch --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}"; Args = $"diff --patch --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}";
else else
Args = $"diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; Args = $"diff --patch --ignore-cr-at-eol --unified={unified} {opt}";
} }
public Models.DiffResult Result() public Models.DiffResult Result()

View file

@ -152,12 +152,18 @@ namespace SourceGit.Models
set; set;
} = "---"; } = "---";
public Dictionary<string, FilterMode> CollectHistoriesFilters() public FilterMode GetHistoriesFilterMode(string pattern, FilterType type)
{ {
var map = new Dictionary<string, FilterMode>();
foreach (var filter in HistoriesFilters) foreach (var filter in HistoriesFilters)
map.Add(filter.Pattern, filter.Mode); {
return map; if (filter.Type != type)
continue;
if (filter.Pattern.Equals(pattern, StringComparison.Ordinal))
return filter.Mode;
}
return FilterMode.None;
} }
public bool UpdateHistoriesFilter(string pattern, FilterType type, FilterMode mode) public bool UpdateHistoriesFilter(string pattern, FilterType type, FilterMode mode)

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>App.manifest</ApplicationManifest> <ApplicationManifest>App.manifest</ApplicationManifest>
<ApplicationIcon>App.ico</ApplicationIcon> <ApplicationIcon>App.ico</ApplicationIcon>

View file

@ -827,6 +827,9 @@ namespace SourceGit.ViewModels
public void RefreshTags() public void RefreshTags()
{ {
var tags = new Commands.QueryTags(_fullpath).Result(); var tags = new Commands.QueryTags(_fullpath).Result();
foreach (var tag in tags)
tag.FilterMode = _settings.GetHistoriesFilterMode(tag.Name, Models.FilterType.Tag);
Dispatcher.UIThread.Invoke(() => Dispatcher.UIThread.Invoke(() =>
{ {
Tags = tags; Tags = tags;
@ -2032,9 +2035,8 @@ namespace SourceGit.ViewModels
builder.Run(visibles, remotes, true); builder.Run(visibles, remotes, true);
} }
var historiesFilters = _settings.CollectHistoriesFilters(); UpdateBranchTreeFilterMode(builder.Locals, true);
UpdateBranchTreeFilterMode(builder.Locals, historiesFilters); UpdateBranchTreeFilterMode(builder.Remotes, false);
UpdateBranchTreeFilterMode(builder.Remotes, historiesFilters);
return builder; return builder;
} }
@ -2054,8 +2056,7 @@ namespace SourceGit.ViewModels
} }
} }
var historiesFilters = _settings.CollectHistoriesFilters(); UpdateTagFilterMode();
UpdateTagFilterMode(historiesFilters);
return visible; return visible;
} }
@ -2079,36 +2080,32 @@ namespace SourceGit.ViewModels
private void RefreshHistoriesFilters() private void RefreshHistoriesFilters()
{ {
var filters = _settings.CollectHistoriesFilters(); UpdateBranchTreeFilterMode(LocalBranchTrees, true);
UpdateBranchTreeFilterMode(LocalBranchTrees, filters); UpdateBranchTreeFilterMode(RemoteBranchTrees, false);
UpdateBranchTreeFilterMode(RemoteBranchTrees, filters); UpdateTagFilterMode();
UpdateTagFilterMode(filters);
Task.Run(RefreshCommits); Task.Run(RefreshCommits);
} }
private void UpdateBranchTreeFilterMode(List<BranchTreeNode> nodes, Dictionary<string, Models.FilterMode> filters) private void UpdateBranchTreeFilterMode(List<BranchTreeNode> nodes, bool isLocal)
{ {
foreach (var node in nodes) foreach (var node in nodes)
{ {
if (filters.TryGetValue(node.Path, out var value)) if (node.IsBranch)
node.FilterMode = value; {
node.FilterMode = _settings.GetHistoriesFilterMode(node.Path, isLocal ? Models.FilterType.LocalBranch : Models.FilterType.RemoteBranch);
}
else else
node.FilterMode = Models.FilterMode.None; {
node.FilterMode = _settings.GetHistoriesFilterMode(node.Path, isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder);
if (!node.IsBranch) UpdateBranchTreeFilterMode(node.Children, isLocal);
UpdateBranchTreeFilterMode(node.Children, filters); }
} }
} }
private void UpdateTagFilterMode(Dictionary<string, Models.FilterMode> filters) private void UpdateTagFilterMode()
{ {
foreach (var tag in _tags) foreach (var tag in _tags)
{ tag.FilterMode = _settings.GetHistoriesFilterMode(tag.Name, Models.FilterType.Tag);
if (filters.TryGetValue(tag.Name, out var value))
tag.FilterMode = value;
else
tag.FilterMode = Models.FilterMode.None;
}
} }
private void ResetBranchTreeFilterMode(List<BranchTreeNode> nodes) private void ResetBranchTreeFilterMode(List<BranchTreeNode> nodes)

View file

@ -34,24 +34,8 @@
<!-- Toolbar Buttons --> <!-- Toolbar Buttons -->
<StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
<Button Classes="icon_button"
Width="28"
Click="OnGotoPrevChange"
IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.Prev}">
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
</Button>
<Button Classes="icon_button"
Width="28"
Click="OnGotoNextChange"
IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.Next}">
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
</Button>
<Button Classes="icon_button" <Button Classes="icon_button"
Width="28" Width="32"
Command="{Binding IncrUnified}" Command="{Binding IncrUnified}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Incr}"> ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Incr}">
@ -62,7 +46,7 @@
</Button> </Button>
<Button Classes="icon_button" <Button Classes="icon_button"
Width="28" Width="32"
Command="{Binding DecrUnified}" Command="{Binding DecrUnified}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Decr}"> ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Decr}">
@ -76,7 +60,9 @@
</Button> </Button>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Width="32" Height="18"
Background="Transparent"
Padding="9,6"
Command="{Binding ToggleFullTextDiff}" Command="{Binding ToggleFullTextDiff}"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFullTextDiff, Mode=OneWay}" IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFullTextDiff, Mode=OneWay}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
@ -85,8 +71,9 @@
</ToggleButton> </ToggleButton>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Width="32" Height="18"
Background="Transparent" Background="Transparent"
Padding="9,6"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}" IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.SyntaxHighlight}"> ToolTip.Tip="{DynamicResource Text.Diff.SyntaxHighlight}">
@ -94,7 +81,9 @@
</ToggleButton> </ToggleButton>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Width="32" Height="18"
Background="Transparent"
Padding="9,6"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap, Mode=TwoWay}" IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap, Mode=TwoWay}"
ToolTip.Tip="{DynamicResource Text.Diff.ToggleWordWrap}"> ToolTip.Tip="{DynamicResource Text.Diff.ToggleWordWrap}">
<ToggleButton.IsVisible> <ToggleButton.IsVisible>
@ -108,14 +97,14 @@
</ToggleButton> </ToggleButton>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Width="32"
IsChecked="{Binding IgnoreWhitespace, Mode=TwoWay}" IsChecked="{Binding IgnoreWhitespace, Mode=TwoWay}"
ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}"> ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}">
<Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/> <Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/>
</ToggleButton> </ToggleButton>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Width="32"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView, Mode=TwoWay}" IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.ShowHiddenSymbols}"> ToolTip.Tip="{DynamicResource Text.Diff.ShowHiddenSymbols}">
@ -123,14 +112,16 @@
</ToggleButton> </ToggleButton>
<ToggleButton Classes="line_path" <ToggleButton Classes="line_path"
Width="28" Height="18" Width="32" Height="18"
Background="Transparent"
Padding="9,6"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=TwoWay}" IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.SideBySide}"> ToolTip.Tip="{DynamicResource Text.Diff.SideBySide}">
<Path Width="12" Height="12" Data="{StaticResource Icons.LayoutHorizontal}" Margin="0,2,0,0"/> <Path Width="12" Height="12" Data="{StaticResource Icons.LayoutHorizontal}" Margin="0,2,0,0"/>
</ToggleButton> </ToggleButton>
<Button Classes="icon_button" Width="28" Command="{Binding OpenExternalMergeTool}" ToolTip.Tip="{DynamicResource Text.Diff.UseMerger}"> <Button Classes="icon_button" Width="32" Command="{Binding OpenExternalMergeTool}" ToolTip.Tip="{DynamicResource Text.Diff.UseMerger}">
<Path Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.OpenWith}"/> <Path Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.OpenWith}"/>
</Button> </Button>
</StackPanel> </StackPanel>

View file

@ -1,6 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace SourceGit.Views namespace SourceGit.Views
{ {
@ -10,31 +8,5 @@ namespace SourceGit.Views
{ {
InitializeComponent(); InitializeComponent();
} }
private void OnGotoPrevChange(object _, RoutedEventArgs e)
{
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (textDiff == null)
return;
textDiff.GotoPrevChange();
if (textDiff is SingleSideTextDiffPresenter presenter)
presenter.ForceSyncScrollOffset();
e.Handled = true;
}
private void OnGotoNextChange(object _, RoutedEventArgs e)
{
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (textDiff == null)
return;
textDiff.GotoNextChange();
if (textDiff is SingleSideTextDiffPresenter presenter)
presenter.ForceSyncScrollOffset();
e.Handled = true;
}
} }
} }

View file

@ -498,106 +498,6 @@ namespace SourceGit.Views
{ {
} }
public void GotoPrevChange()
{
var view = TextArea.TextView;
var lines = GetLines();
var firstLineIdx = lines.Count;
foreach (var line in view.VisualLines)
{
if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted)
continue;
var index = line.FirstDocumentLine.LineNumber - 1;
if (index >= lines.Count)
continue;
if (firstLineIdx > index)
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;
var isChangePrevLine = prevLineType != Models.TextDiffLineType.Normal && prevLineType != Models.TextDiffLineType.Indicator;
if (isChangeFirstLine && isChangePrevLine)
{
for (var i = firstLineIdx - 2; i >= 0; i--)
{
var prevType = lines[i].Type;
if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator)
{
ScrollToLine(i + 2);
return;
}
}
}
var findChange = false;
for (var i = firstLineIdx - 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;
}
}
}
public void GotoNextChange()
{
var view = TextArea.TextView;
var lines = GetLines();
var lastLineIdx = -1;
foreach (var line in view.VisualLines)
{
if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted)
continue;
var index = line.FirstDocumentLine.LineNumber - 1;
if (index >= lines.Count)
continue;
if (lastLineIdx < index)
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++)
{
var nextType = lines[idx].Type;
if (nextType == Models.TextDiffLineType.None ||
nextType == Models.TextDiffLineType.Added ||
nextType == Models.TextDiffLineType.Deleted)
{
if (findNormalLine)
{
ScrollToLine(idx + 1);
return;
}
}
else if (!findNormalLine)
{
findNormalLine = true;
}
}
}
public override void Render(DrawingContext context) public override void Render(DrawingContext context)
{ {
base.Render(context); base.Render(context);
@ -1068,12 +968,6 @@ namespace SourceGit.Views
TextArea.LeftMargins.Add(new LineModifyTypeMargin()); TextArea.LeftMargins.Add(new LineModifyTypeMargin());
} }
public void ForceSyncScrollOffset()
{
if (DataContext is ViewModels.TwoSideTextDiff diff)
diff.SyncScrollOffset = _scrollViewer.Offset;
}
public override List<Models.TextDiffLine> GetLines() public override List<Models.TextDiffLine> GetLines()
{ {
if (DataContext is ViewModels.TwoSideTextDiff diff) if (DataContext is ViewModels.TwoSideTextDiff diff)