Add a .tag inline-selection kind for #tag autocomplete#94
Open
ChristineTham wants to merge 1 commit into
Open
Conversation
Adds a `.tag` InlineSelectionKind and caret-scan detection: when the caret is inside a `#tag` (≥1 body char, `#` at a whitespace/line boundary so headings and mid-word `#` don't match, not in code), the engine fires onInlineSelectionChange(.tag) with the tag text + a caret rect, mirroring how it drives wiki-link autocomplete. Also adds an `isLiteralMode` to InlineReplacementRequest so a host can commit a plain `#tag ` verbatim (caret at end) without wiki-link `[[Name|id]]` parsing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds #tag-aware inline selection handling so embedders can drive tag autocomplete using the same inline-selection callback mechanism as wiki-link completion, and extends inline replacement to support verbatim (non–wiki-link-parsed) insertions.
Changes:
- Introduces
InlineSelectionKind.tagand a caret-scan (tagContext) to detect#tagcontexts outside code. - Emits
onInlineSelectionChange(.tag)+ caret rect when typing inside a tag. - Adds
isLiteralModetoInlineReplacementRequestto support inserting plain literal fragments and placing the caret at the end.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/MarkdownEngine/TextView/NativeTextViewSelectionTypes.swift | Adds .tag inline selection kind and isLiteralMode on inline replacement requests. |
| Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+TextDelegate.swift | Triggers .tag inline selection + caret rect when typing inside a detected tag. |
| Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+Restyling.swift | Supports literal-mode replacement insertion and caret placement. |
| Sources/MarkdownEngine/TextView/Coordinator/NativeTextViewCoordinator+InlineSelection.swift | Implements #tag detection logic (tagContext) with code-block exclusion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| let undoActionName = request.isImageEmbedMode ? "Insert Image Embed" : "Insert Link" | ||
| let undoActionName = request.isLiteralMode ? "Insert Tag" : "Insert Link" |
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.
What
Adds a
.tagInlineSelectionKindand caret-scan detection: when the caret is inside a#tag(≥1 body char,#at a whitespace/line boundary so headings and mid-word#don't match, not inside code), the engine firesonInlineSelectionChange(.tag)with the tag text + a caret rect — mirroring how it drives wiki-link autocomplete.Also adds an
isLiteralModeflag toInlineReplacementRequestso a host can commit a plain#tagverbatim (caret at end) without wiki-link[[Name|id]]parsing.This lets embedders reuse their existing wiki-link completion UI to offer tag suggestions — the engine previously emitted inline-token callbacks and a caret rect only for
[[wiki-links]]/![[embeds]].Context: extracted from the ChristineTham/swift-markdown-engine fork used by HelloNotes. Rebased onto current
main(the inline-replacement path was unified upstream since the fork's base; the literal branch is layered on top).