mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: extends highlight area of selected/detected chunk to line number area
This commit is contained in:
parent
1bff77cfcf
commit
aae1c41dcd
1 changed files with 7 additions and 49 deletions
|
@ -391,19 +391,13 @@ namespace SourceGit.Views
|
||||||
base.Render(context);
|
base.Render(context);
|
||||||
|
|
||||||
var chunk = SelectedChunk;
|
var chunk = SelectedChunk;
|
||||||
if (chunk == null || (!chunk.Combined && chunk.IsOldSide != IsOld) || chunk.Height == 0)
|
if (chunk == null || (!chunk.Combined && chunk.IsOldSide != IsOld))
|
||||||
return;
|
|
||||||
|
|
||||||
var view = TextArea.TextView;
|
|
||||||
if (view == null || !view.VisualLinesValid)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var color = (Color)this.FindResource("SystemAccentColor");
|
var color = (Color)this.FindResource("SystemAccentColor");
|
||||||
var brush = new SolidColorBrush(color, 0.1);
|
var brush = new SolidColorBrush(color, 0.1);
|
||||||
var pen = new Pen(color.ToUInt32());
|
var pen = new Pen(color.ToUInt32());
|
||||||
|
var rect = new Rect(0, chunk.Y, Bounds.Width, chunk.Height);
|
||||||
var x = ((Point)view.TranslatePoint(new Point(0, 0), this)).X;
|
|
||||||
var rect = new Rect(x - 4, chunk.Y, view.Bounds.Width + 7, chunk.Height);
|
|
||||||
|
|
||||||
context.DrawRectangle(brush, null, rect);
|
context.DrawRectangle(brush, null, rect);
|
||||||
context.DrawLine(pen, rect.TopLeft, rect.TopRight);
|
context.DrawLine(pen, rect.TopLeft, rect.TopRight);
|
||||||
|
@ -683,28 +677,12 @@ namespace SourceGit.Views
|
||||||
var lastLineIdx = view.VisualLines[^1].FirstDocumentLine.LineNumber - 1;
|
var lastLineIdx = view.VisualLines[^1].FirstDocumentLine.LineNumber - 1;
|
||||||
if (endIdx < firstLineIdx)
|
if (endIdx < firstLineIdx)
|
||||||
{
|
{
|
||||||
TrySetChunk(new TextDiffViewChunk()
|
TrySetChunk(null);
|
||||||
{
|
|
||||||
Y = 0,
|
|
||||||
Height = 0,
|
|
||||||
StartIdx = startIdx,
|
|
||||||
EndIdx = endIdx,
|
|
||||||
Combined = true,
|
|
||||||
IsOldSide = false,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (startIdx > lastLineIdx)
|
else if (startIdx > lastLineIdx)
|
||||||
{
|
{
|
||||||
TrySetChunk(new TextDiffViewChunk()
|
TrySetChunk(null);
|
||||||
{
|
|
||||||
Y = 0,
|
|
||||||
Height = 0,
|
|
||||||
StartIdx = startIdx,
|
|
||||||
EndIdx = endIdx,
|
|
||||||
Combined = true,
|
|
||||||
IsOldSide = false,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,32 +855,12 @@ namespace SourceGit.Views
|
||||||
var lastLineIdx = view.VisualLines[^1].FirstDocumentLine.LineNumber - 1;
|
var lastLineIdx = view.VisualLines[^1].FirstDocumentLine.LineNumber - 1;
|
||||||
if (endIdx < firstLineIdx)
|
if (endIdx < firstLineIdx)
|
||||||
{
|
{
|
||||||
diff.ConvertsToCombinedRange(parent.DataContext as Models.TextDiff, ref startIdx, ref endIdx, IsOld);
|
TrySetChunk(null);
|
||||||
|
|
||||||
TrySetChunk(new TextDiffViewChunk()
|
|
||||||
{
|
|
||||||
Y = 0,
|
|
||||||
Height = 0,
|
|
||||||
StartIdx = startIdx,
|
|
||||||
EndIdx = endIdx,
|
|
||||||
Combined = false,
|
|
||||||
IsOldSide = IsOld,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (startIdx > lastLineIdx)
|
else if (startIdx > lastLineIdx)
|
||||||
{
|
{
|
||||||
diff.ConvertsToCombinedRange(parent.DataContext as Models.TextDiff, ref startIdx, ref endIdx, IsOld);
|
TrySetChunk(null);
|
||||||
|
|
||||||
TrySetChunk(new TextDiffViewChunk()
|
|
||||||
{
|
|
||||||
Y = 0,
|
|
||||||
Height = 0,
|
|
||||||
StartIdx = startIdx,
|
|
||||||
EndIdx = endIdx,
|
|
||||||
Combined = false,
|
|
||||||
IsOldSide = IsOld,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1079,7 @@ namespace SourceGit.Views
|
||||||
SelectedChunkProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
SelectedChunkProperty.Changed.AddClassHandler<TextDiffView>((v, _) =>
|
||||||
{
|
{
|
||||||
var chunk = v.SelectedChunk;
|
var chunk = v.SelectedChunk;
|
||||||
if (chunk == null || chunk.Height == 0)
|
if (chunk == null)
|
||||||
{
|
{
|
||||||
v.Popup.IsVisible = false;
|
v.Popup.IsVisible = false;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue