Repository navigation
Conversation
`hit(_:at:)` took the character under the click, else the one before the caret — whatever the point. Past the end of a line the caret goes before the line's break, so a link ending its line was opened from the empty room after it. That room is where a note read back differs from what was typed: the space typed after a link is not saved, so a note ending on an address came back with a click past it opening the address. The fallback to the character before the caret stays, for a click on its right half, but only when the point is over that character's own room. A hidden one's room is the kern the styling gives it, where its chip is drawn; the height is the line's, so a task's box, drawn larger than its characters, still takes a click.
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.
The bug
A link at the end of a line opens when clicked in the empty space after it, instead of putting the caret there.
EditorTextView.hit(_:at:)took the character under the click, else the one before the caret, whatever the point was:Past the end of a line the caret goes before the line's break, so that fallback landed on the link's last character. The room on the right of a line is where a note read back differs from what was typed: the space typed after a link is not saved, so a note ending on
https://example.comcomes back with the address flush to the line's end, and a click past it opened the address.The fix
The fallback stays, for a click on a character's right half, but only when the point is actually over that character's own room. Two details make it safe:
Verification
Ten checks against real TextKit, with the shipping
hit/covers/rect/lineBox/segmentscompiled verbatim from the source and the pre-fix lookup beside them:App/Tests/MarkdownEditorTests/LinkClickTests.swiftholds the regression tests, in the offscreen-window style the other editor tests use.Also
One line under
## Unreleased, as a user-visible fix.