Skip to content

fix(rename): say which copy the extension answered about - #157

Open
BartvHelvert wants to merge 1 commit into
masterfrom
fix/rename-host-version-logging
Open

BartvHelvert wants to merge 1 commit into
masterfrom
fix/rename-host-version-logging

Conversation

@BartvHelvert

Copy link
Copy Markdown
Owner

What this changes

Refs #136, which is reopened: an extension's rename edit still lands on the wrong characters with
3f721a1 and e908d3e both in place.

CodeBridgeRename logs nothing today, so the failures leave no way to tell which text the
extension worked its edit out against. This records the host's document version at the three
moments that matter — before the wait, once the host holds the editor's text, and once it has
answered — because the host's text provably cannot distinguish them.

Why the text cannot

edits() waits with awaitMirrored(file, text, …), and that is a string comparison:

while (mirrored[file] != text) { … }

text is the document after the template put the old name back — which is the same string as the
document before the template started. So a host copy that has seen neither the typing nor the
reverting is byte-identical to one that has seen both, and the wait returns at once for either.

That is consistent with the failure in
run 42891176101: the
observed let renamed; is the original line with [4,11) replaced, and [4,11) is exactly where
the identifier sits in the typed text let renamed=1;, not in the text the edit was applied to.
The arithmetic is on the issue. A host that was still working through the queued typing when it
was asked would answer in precisely those coordinates.

It is also consistent with e908d3e's unit test passing: that checks the host's copy is the
editor's when the edit is asked for, which is true of a stale copy too.

What this does not do

No behaviour changes, and no fix. The version is read, logged, and otherwise unused.

The fix this points at is to wait on the host's version rather than its text, but I would rather
see one CI failure carrying these three numbers before changing what the wait means — a
version-based wait that is too strict refuses renames that would have worked, and the mirroring
may coalesce edits in ways that are easier to confirm than to reason about.

mirroredVersion is the host's own document version, which ExtensionHostDocuments already keeps
and reportEdit already prints every so often.

How it was tested

  • :backend:compileKotlin and :backend:compileTestKotlin pass.
  • HostedWorkerHostsTest still passes, run through the JUnit platform launcher against the
    module's classpath.
  • Gradle's :backend:test cannot run on this machine — the IntelliJ Platform plugin probes the
    downloaded JBR, which NixOS cannot execute — so the rename unit tests were not run. They do not
    touch the changed lines: nothing here alters a decision, only what is written to the log.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test. Diagnostics for an open bug.
  • No internal, override-only, obsolete or deprecated platform API.
  • docs/ is updated where behaviour changed, docs/status.md especially. No behaviour change.
  • Third-party material keeps its notice and is listed in NOTICE.md. None added.

`CodeBridgeRename` logged nothing, so a rename that replaced the wrong
characters left no way to tell which text the extension had worked its
edit out against.

Record the host's version where its text cannot say: before the wait,
once it holds the editor's text, and once it has answered. What the
template puts back is the text that was there before it, so a copy that
has seen neither the typing nor the reverting reads to `awaitMirrored`
as one that is caught up -- the two are the same string. A version that
moves between the wait and the answer is a host that was still applying
the typing while it worked the edit out.

`mirroredVersion` is the host's own document version, which it already
keeps and already reports every so often as edits are mirrored.

Refs #136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant