fix: stop mention insert from breaking compose cursor and keyboard#485
Merged
fix: stop mention insert from breaking compose cursor and keyboard#485
Conversation
Mentions used to be stored in the text field as raw nostr:nprofile URIs rendered as @name via an OutputTransformation. The visual/underlying offset mismatch made the cursor jump, the IME desync on rapid typing, forced a trailing space after every mention (so '@name's' was impossible), and turned a single backspace into a silent delete of the whole mention. Store '@name' directly in the text field and track mention ranges out-of-band in the ViewModel; splice nostr:nprofile URIs back in at publish time. Editing is now plain text — identity offset mapping, no forced space, and breaking a mention drops only that mention, not the surrounding text.
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
@Namein the compose text field; ranges are tracked out-of-band inComposeViewModeland spliced back tonostr:nprofile…URIs at publish and draft-save time@alice'sworks, and stops backspace from silently wiping an entire mention — one backspace deletes one char and the mention is dropped when its range is brokenMentionOutputTransformationloses itsnpub1/nprofile1branches (no longer needed);note1/nevent1chips stay for pasted quote URIsTest plan
@ali, pick a candidate → cursor sits immediately after@Alice, no trailing space's thoughtsright after → reads@Alice's thoughts, mention tag fires on publishnostr:nprofile1…, aptag is present@Alice→ deletese, mention is dropped, no atomic wipe@Alice and @Bob) → both publish correctly with twoptagssavedStateHandlenostr:nprofile…URI (still publishable)