mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: unify selection mode and hunk mode
This commit is contained in:
parent
42f8e41985
commit
9de2853003
7 changed files with 446 additions and 724 deletions
|
@ -69,7 +69,7 @@ namespace SourceGit.Models
|
||||||
public string Repo { get; set; } = null;
|
public string Repo { get; set; } = null;
|
||||||
public DiffOption Option { get; set; } = null;
|
public DiffOption Option { get; set; } = null;
|
||||||
|
|
||||||
public TextDiffSelection MakeSelection(int startLine, int endLine, bool isSideBySide, bool isOldSide)
|
public TextDiffSelection MakeSelection(int startLine, int endLine, bool isCombined, bool isOldSide)
|
||||||
{
|
{
|
||||||
var rs = new TextDiffSelection();
|
var rs = new TextDiffSelection();
|
||||||
rs.StartLine = startLine;
|
rs.StartLine = startLine;
|
||||||
|
@ -95,7 +95,7 @@ namespace SourceGit.Models
|
||||||
var line = Lines[i];
|
var line = Lines[i];
|
||||||
if (line.Type == TextDiffLineType.Added)
|
if (line.Type == TextDiffLineType.Added)
|
||||||
{
|
{
|
||||||
if (!isSideBySide)
|
if (isCombined)
|
||||||
{
|
{
|
||||||
rs.HasChanges = true;
|
rs.HasChanges = true;
|
||||||
break;
|
break;
|
||||||
|
@ -111,7 +111,7 @@ namespace SourceGit.Models
|
||||||
}
|
}
|
||||||
else if (line.Type == TextDiffLineType.Deleted)
|
else if (line.Type == TextDiffLineType.Deleted)
|
||||||
{
|
{
|
||||||
if (!isSideBySide)
|
if (isCombined)
|
||||||
{
|
{
|
||||||
rs.HasChanges = true;
|
rs.HasChanges = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -307,9 +307,9 @@
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">Find next match</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">Find next match</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">Find previous match</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">Find previous match</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">Open search panel</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">Open search panel</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">Stage Hunk</x:String>
|
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">Stage</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">Unstage Hunk</x:String>
|
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">Unstage</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">Discard Hunk</x:String>
|
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">Discard</x:String>
|
||||||
<x:String x:Key="Text.Init" xml:space="preserve">Initialize Repository</x:String>
|
<x:String x:Key="Text.Init" xml:space="preserve">Initialize Repository</x:String>
|
||||||
<x:String x:Key="Text.Init.Path" xml:space="preserve">Path:</x:String>
|
<x:String x:Key="Text.Init.Path" xml:space="preserve">Path:</x:String>
|
||||||
<x:String x:Key="Text.Init.Tip" xml:space="preserve">Invalid repository detected. Run `git init` under this path?</x:String>
|
<x:String x:Key="Text.Init.Tip" xml:space="preserve">Invalid repository detected. Run `git init` under this path?</x:String>
|
||||||
|
|
|
@ -310,9 +310,9 @@
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">定位到下一个匹配搜索的位置</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">定位到下一个匹配搜索的位置</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">定位到上一个匹配搜索的位置</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">定位到上一个匹配搜索的位置</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">打开搜索</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">打开搜索</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">暂存片断</x:String>
|
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">暂存</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">移出暂存区</x:String>
|
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">移出暂存区</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">丢弃片断</x:String>
|
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">丢弃</x:String>
|
||||||
<x:String x:Key="Text.Init" xml:space="preserve">初始化新仓库</x:String>
|
<x:String x:Key="Text.Init" xml:space="preserve">初始化新仓库</x:String>
|
||||||
<x:String x:Key="Text.Init.Path" xml:space="preserve">路径 :</x:String>
|
<x:String x:Key="Text.Init.Path" xml:space="preserve">路径 :</x:String>
|
||||||
<x:String x:Key="Text.Init.Tip" xml:space="preserve">选择目录不是有效的Git仓库。是否需要在此目录执行`git init`操作?</x:String>
|
<x:String x:Key="Text.Init.Tip" xml:space="preserve">选择目录不是有效的Git仓库。是否需要在此目录执行`git init`操作?</x:String>
|
||||||
|
|
|
@ -310,9 +310,9 @@
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">定位到下一個匹配搜尋的位置</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoNextMatch" xml:space="preserve">定位到下一個匹配搜尋的位置</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">定位到上一個匹配搜尋的位置</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.GotoPrevMatch" xml:space="preserve">定位到上一個匹配搜尋的位置</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">開啟搜尋</x:String>
|
<x:String x:Key="Text.Hotkeys.TextEditor.Search" xml:space="preserve">開啟搜尋</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">暫存片斷</x:String>
|
<x:String x:Key="Text.Hunk.Stage" xml:space="preserve">暫存</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">移出暫存區</x:String>
|
<x:String x:Key="Text.Hunk.Unstage" xml:space="preserve">移出暫存區</x:String>
|
||||||
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">丟棄片斷</x:String>
|
<x:String x:Key="Text.Hunk.Discard" xml:space="preserve">丟棄</x:String>
|
||||||
<x:String x:Key="Text.Init" xml:space="preserve">初始化新倉庫</x:String>
|
<x:String x:Key="Text.Init" xml:space="preserve">初始化新倉庫</x:String>
|
||||||
<x:String x:Key="Text.Init.Path" xml:space="preserve">路徑 :</x:String>
|
<x:String x:Key="Text.Init.Path" xml:space="preserve">路徑 :</x:String>
|
||||||
<x:String x:Key="Text.Init.Tip" xml:space="preserve">選擇目錄不是有效的Git倉庫。是否需要在此目錄執行`git init`操作?</x:String>
|
<x:String x:Key="Text.Init.Tip" xml:space="preserve">選擇目錄不是有效的Git倉庫。是否需要在此目錄執行`git init`操作?</x:String>
|
||||||
|
|
|
@ -58,11 +58,11 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public void ConvertsToCombinedRange(Models.TextDiff combined, ref int startLine, ref int endLine, bool isOldSide)
|
public void ConvertsToCombinedRange(Models.TextDiff combined, ref int startLine, ref int endLine, bool isOldSide)
|
||||||
{
|
{
|
||||||
endLine = Math.Min(endLine, combined.Lines.Count);
|
endLine = Math.Min(endLine, combined.Lines.Count - 1);
|
||||||
|
|
||||||
var oneSide = isOldSide ? Old : New;
|
var oneSide = isOldSide ? Old : New;
|
||||||
var firstContentLine = -1;
|
var firstContentLine = -1;
|
||||||
for (int i = startLine - 1; i < endLine; i++)
|
for (int i = startLine; i <= endLine; i++)
|
||||||
{
|
{
|
||||||
var line = oneSide[i];
|
var line = oneSide[i];
|
||||||
if (line.Type != Models.TextDiffLineType.None)
|
if (line.Type != Models.TextDiffLineType.None)
|
||||||
|
@ -76,7 +76,7 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var endContentLine = -1;
|
var endContentLine = -1;
|
||||||
for (int i = Math.Min(endLine - 1, oneSide.Count - 1); i >= startLine - 1; i--)
|
for (int i = Math.Min(endLine, oneSide.Count - 1); i >= startLine; i--)
|
||||||
{
|
{
|
||||||
var line = oneSide[i];
|
var line = oneSide[i];
|
||||||
if (line.Type != Models.TextDiffLineType.None)
|
if (line.Type != Models.TextDiffLineType.None)
|
||||||
|
@ -91,8 +91,8 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
var firstContent = oneSide[firstContentLine];
|
var firstContent = oneSide[firstContentLine];
|
||||||
var endContent = oneSide[endContentLine];
|
var endContent = oneSide[endContentLine];
|
||||||
startLine = combined.Lines.IndexOf(firstContent) + 1;
|
startLine = combined.Lines.IndexOf(firstContent);
|
||||||
endLine = combined.Lines.IndexOf(endContent) + 1;
|
endLine = combined.Lines.IndexOf(endContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillEmptyLines()
|
private void FillEmptyLines()
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
||||||
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
||||||
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
||||||
HighlightChunk="{Binding #ThisControl.HighlightChunk, Mode=TwoWay}"/>
|
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate DataType="vm:TwoSideTextDiff">
|
<DataTemplate DataType="vm:TwoSideTextDiff">
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
||||||
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
||||||
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
||||||
HighlightChunk="{Binding #ThisControl.HighlightChunk, Mode=TwoWay}"/>
|
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
|
||||||
|
|
||||||
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
|
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
|
||||||
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
|
||||||
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
|
||||||
HighlightChunk="{Binding #ThisControl.HighlightChunk, Mode=TwoWay}"/>
|
SelectedChunk="{Binding #ThisControl.SelectedChunk, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentControl.DataTemplates>
|
</ContentControl.DataTemplates>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue