Skip to content

Anchor a retire to the snapshot it was sent for - #784

Merged
SimonCropp merged 5 commits into
mainfrom
fix-patcher-remove-ignores-anchor
Aug 22, 2026
Merged

Anchor a retire to the snapshot it was sent for#784
SimonCropp merged 5 commits into
mainfrom
fix-patcher-remove-ignores-anchor

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

Set and Append locate the call by content, and say why: the same literal is just
as likely to sit in another test, in a comment, or in the verify call on the
same line, so rewriting whichever call the hint lands on leaves the wrong
snapshot changed. Remove had exactly that problem with none of the protection -
it took the nearest call to the recorded line and deleted it, ignoring the
anchor entirely.

The recorded line stops being true as soon as anything above it is edited, which
is the ordinary state of a source file between a test run and a retire. So a
stale hint retired the snapshot in the test next door and reported Applied, and
the snapshot that should have gone was still there.

TryFindAnchoredCall matches on the expected argument the way the Set path does,
by expression where there is one and by parsed value otherwise, and falls back
to nearest-to-the-hint only when no anchor was sent at all - which is what a
producer whose language withholds CallerArgumentExpression and sends no value
either can offer. An anchor that matches nothing is now reported rather than
resolved to something else.

Set and Append locate the call by content, and say why: the same literal is just
as likely to sit in another test, in a comment, or in the verify call on the
same line, so rewriting whichever call the hint lands on leaves the wrong
snapshot changed. Remove had exactly that problem with none of the protection -
it took the nearest call to the recorded line and deleted it, ignoring the
anchor entirely.

The recorded line stops being true as soon as anything above it is edited, which
is the ordinary state of a source file between a test run and a retire. So a
stale hint retired the snapshot in the test next door and reported Applied, and
the snapshot that should have gone was still there.

TryFindAnchoredCall matches on the expected argument the way the Set path does,
by expression where there is one and by parsed value otherwise, and falls back
to nearest-to-the-hint only when no anchor was sent at all - which is what a
producer whose language withholds CallerArgumentExpression and sends no value
either can offer. An anchor that matches nothing is now reported rather than
resolved to something else.
…nores-anchor

# Conflicts:
#	src/DiffEngine.Tests/InlinePatcherTests.cs
…nores-anchor

# Conflicts:
#	src/DiffEngine.Tests/InlinePatcherTests.cs
…nores-anchor

# Conflicts:
#	src/DiffEngine.Tests/InlinePatcherTests.cs
@SimonCropp
SimonCropp merged commit bb37d2c into main Aug 22, 2026
8 checks passed
@SimonCropp
SimonCropp deleted the fix-patcher-remove-ignores-anchor branch August 22, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant