feat: line-range @mention via Option+K and Shift+drop#526
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…F line endings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also exposes attachFile() as a public method on FileContextManager so the shortcut handler can register the file in the chip strip alongside the line-range whitelist entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to attachLineRangeMention Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…geContext to pass through Shift+drop
859eb04 to
a8cdbce
Compare
|
current selection indicator already supports selected content as well as line number, and it's all automatic. what's new in this pr? |
|
Thanks for the context! Here's what's new: Inspiration: This is modeled after the Claude Code VS Code extension's line-range mention feature (https://code.claude.com/docs/en/vs-code). What's different from the existing selection indicator: The existing selection indicator automatically captures the current active editor selection — which is great, but it's limited to a single selection at a time and is replaced whenever the selection changes. This PR adds:
The key difference: the existing indicator is ephemeral and single-selection. This lets you deliberately pin multiple ranges before hitting send. |
|
i like the idea about the multi selection insertion, but i think the file-drag feature is not aligned with current design, the chip is to "link" a session to a note, not to display all the files that has been mentioned. if i were to support multi-line selection, i will simply create a new hotkey to insert the selected content path and line number, plain and simple. |
Summary
@filename#startLine-endLineinto the chat input. At send time, the referenced lines are read from the vault and injected as<editor_selection path="..." lines="...">XML into the prompt.<editor_selection>block.@filepathinto the input (without opening the file).Technical Notes
documentcapture-phase listeners for Shift+drop to intercept before Obsidian's own drop handler.e.code === 'KeyK'(note.key) for Option+K to work correctly on macOS where Option+K produces the composed character˚.InputController.sendMessage(async) beforeruntime.prepareTurn, keepingprepareTurnsynchronous.@file#lineis never resolved — only shortcut-inserted mentions are whitelisted viaFileContextState.attachLineRangeMention.Test Plan
@filename#start-endinserted in input<editor_selection>XML with correct line content appears in prompt<editor_selection>block inlined directly@filepathinserted@file#1-5→ send → verify no XML injection🤖 Generated with Claude Code