Skip to content

Commit 593c605

Browse files
committed
fix: moving buttons
1 parent b9f14a7 commit 593c605

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

src/Views/MergeConflictEditor.axaml.cs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,20 +355,50 @@ private void OnTextViewPointerMoved(object sender, PointerEventArgs e)
355355
var startVisualLine = textView.GetVisualLine(startLine);
356356
var endVisualLine = textView.GetVisualLine(endLine);
357357

358-
if (startVisualLine == null || endVisualLine == null)
359-
continue;
358+
// Handle partially visible conflicts (same pattern as UpdateSelectedChunkPosition)
359+
double viewportY, height;
360+
bool isWithinRegion;
360361

361-
var regionStartY = startVisualLine.GetTextLineVisualYPosition(
362-
startVisualLine.TextLines[0], VisualYPosition.LineTop);
363-
var regionEndY = endVisualLine.GetTextLineVisualYPosition(
364-
endVisualLine.TextLines[^1], VisualYPosition.LineBottom);
362+
if (startVisualLine != null && endVisualLine != null)
363+
{
364+
// Both lines visible
365+
var regionStartY = startVisualLine.GetTextLineVisualYPosition(
366+
startVisualLine.TextLines[0], VisualYPosition.LineTop);
367+
var regionEndY = endVisualLine.GetTextLineVisualYPosition(
368+
endVisualLine.TextLines[^1], VisualYPosition.LineBottom);
369+
370+
isWithinRegion = y >= regionStartY && y <= regionEndY;
371+
viewportY = regionStartY - textView.VerticalOffset;
372+
height = regionEndY - regionStartY;
373+
}
374+
else if (startVisualLine == null && endVisualLine != null)
375+
{
376+
// Start scrolled out, end visible - clamp to top
377+
var regionEndY = endVisualLine.GetTextLineVisualYPosition(
378+
endVisualLine.TextLines[^1], VisualYPosition.LineBottom);
365379

366-
if (y >= regionStartY && y <= regionEndY)
380+
isWithinRegion = y <= regionEndY;
381+
viewportY = 0;
382+
height = regionEndY - textView.VerticalOffset;
383+
}
384+
else if (startVisualLine != null && endVisualLine == null)
385+
{
386+
// Start visible, end scrolled out - clamp to bottom
387+
var regionStartY = startVisualLine.GetTextLineVisualYPosition(
388+
startVisualLine.TextLines[0], VisualYPosition.LineTop);
389+
390+
isWithinRegion = y >= regionStartY;
391+
viewportY = regionStartY - textView.VerticalOffset;
392+
height = textView.Bounds.Height - viewportY;
393+
}
394+
else
367395
{
368-
// Calculate position relative to the viewport
369-
var viewportY = regionStartY - textView.VerticalOffset;
370-
var height = regionEndY - regionStartY;
396+
// Both scrolled out - conflict not visible
397+
continue;
398+
}
371399

400+
if (isWithinRegion)
401+
{
372402
var newChunk = new ViewModels.MergeConflictSelectedChunk(
373403
viewportY, height, i, PanelType);
374404

0 commit comments

Comments
 (0)