Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/DiffEngineViewer.Windows.Tests/QueueTipsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,43 @@ public async Task ForgettingLetsTheSameRowChange()
using var tips = new QueueTips();

tips.Apply(owner, 3, "before");
tips.Forget();
tips.Forget(owner);
tips.Apply(owner, 3, null);
await Assert.That(tips.Current(owner)).IsEmpty();
}

/// <summary>
/// The reported bug reached the other way round: the cursor leaves the queue column for the
/// diff panes, which is a Forget - from the mouse leaving, or from the screen being redrawn -
/// followed by a row of -1.
/// <para>
/// Both set the row to -1, so Apply had nothing to do and returned, and the caption for the
/// row last hovered stayed registered on the whole canvas. Resting anywhere brought it back,
/// over the panes.
/// </para>
/// </summary>
[Test]
public async Task ForgettingBeforeLeavingTheColumnLeavesNothingRegistered()
{
using var owner = new Control();
using var tips = new QueueTips();

tips.Apply(owner, 2, "SolutionA/Tests/ATests.cs:6");
tips.Forget(owner);
tips.Apply(owner, -1, null);

await Assert.That(tips.Current(owner)).IsEmpty();
}

[Test]
public async Task ForgettingClearsTheText()
{
using var owner = new Control();
using var tips = new QueueTips();

tips.Apply(owner, 2, "SolutionA/Tests/ATests.cs:6");
tips.Forget(owner);

await Assert.That(tips.Current(owner)).IsEmpty();
}
}
12 changes: 11 additions & 1 deletion src/DiffEngineViewer.Windows/QueueTips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ public void Apply(Control owner, int queueRow, string? text)
/// <summary>
/// Forgets which row is described, so the next move re-applies. For a new screen, which
/// renumbers the rows under a cursor that has not moved, and for the cursor leaving.
/// <para>
/// The caption goes with it. Resetting only the row left the last row's text registered on the
/// whole canvas, and <see cref="Apply" />'s own early return then kept it there: a cursor on
/// the canvas but not on a queue row arrives as row -1, which is the row this just set. So the
/// tip popped up over the diff panes, which is the thing this type exists to prevent.
/// </para>
/// </summary>
public void Forget() =>
public void Forget(Control owner)
{
row = -1;
tip.Hide(owner);
tip.SetToolTip(owner, null);
}

/// <summary>
/// What would be shown, which is what the tests assert on: the bug this type exists to prevent
Expand Down
4 changes: 2 additions & 2 deletions src/DiffEngineViewer.Windows/ViewerCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void Draw(Screen value)
{
screen = value;
// A new screen renumbers the rows, so a kept index would describe a different entry.
tips.Forget();
tips.Forget(this);
Invalidate();
}

Expand Down Expand Up @@ -498,7 +498,7 @@ protected override void OnMouseLeave(EventArgs e)
Cursor = Cursors.Default;
}

tips.Forget();
tips.Forget(this);
}

protected override void OnMouseWheel(MouseEventArgs e)
Expand Down
Loading