fix: open the pair where the caret reaches two inline objects meeting - #415
Merged
Conversation
A caret only ever arrives where two objects meet with one of them already projected, because reaching either object projects it first, and an active session keeps a caret on its own edge: `isRangeInside` is inclusive, so discovery never ran at the one position the pair exists on. The pair was reachable by click and by nothing else. A clean session whose caret sits on its edge now restores onto a plugin-free probe and puts the ordinary precedence to the document it was holding out of view. Where that answers with a range taking in everything the session covers and more, the session gives way where it stands and the pair opens in its place. Asking discovery, rather than asking whether a neighbour is there, keeps the rule adapter-agnostic. Requiring the answer to contain the session is what keeps it from handing the caret sideways: two identical adjacent references are one text node and pair with nothing, so discovery there answers with the neighbour itself, and giving way to it would swap which of the two reads as source and undo an edit to the first. Restricted to a clean session and an empty caret, so reaching an edge neither commits an edit nor disturbs a selection, and a projection whose object has no projectable neighbour keeps the caret exactly where it had it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A caret only ever arrives where two adjacent inline objects meet with one of them already projected, because reaching either object projects it first. An active session keeps a caret that is inside its range, and the session's own edge counts as inside, so target discovery never ran at the one position the pair exists on. The pair #312 opens was reachable by clicking and by nothing else, and under keyboard motion the author still read one neighbour as the file holds it and the other as it renders, decided by the direction of travel.
The issue's first reading of this defect said the caret skipped the meeting place and passed a character over with it. It does not, and the issue has been corrected: that reading came from comparing positions across the projected and canonical documents instead of reading the caret drawn in place. There is one cause, and no document position is skipped.
Related Issue
Closes #413
Verification
Focused tests drive the editor mount the plugin tests use.
Manually verified by sweeping the caret one position at a time across
Z *ab***cd** Z,Z [ab](x)[cd](y) Z,A ©® bandZ *ab* cd Zin both directions, with the caret drawn in place: each press moves one position, the pair opens on the meeting place in both directions for each pair, and the run with a plain-text neighbour is unchanged.The whole frontend suite and the corpus round trips run clean, and the coverage floor holds.
Not verified: the desktop E2E suite, which CI runs as its own job; backend checks, since nothing under
src-tauri/changed.Notes
The changelog entry for the pair is amended rather than given a
Fixedline of its own, because both changes are unreleased and a reader of the release notes should meet one coherent statement rather than a feature followed by a defect in it that never shipped.