Skip to content

fix(completion): stop callout completions recurring over block-quote prose - #3

Open
Feel-ix-343 wants to merge 1 commit into
mainfrom
devin/1781922832-callout-completion-suppress
Open

fix(completion): stop callout completions recurring over block-quote prose#3
Feel-ix-343 wants to merge 1 commit into
mainfrom
devin/1781922832-callout-completion-suppress

Conversation

@Feel-ix-343

Copy link
Copy Markdown

Summary

Callout (admonition) completions kept popping up over ordinary prose inside a block quote — e.g. typing > We're going to have to decide re-showed the full [!note]/[!warning]/… list on every keystroke. They should only appear where an Obsidian callout could actually be typed (right after the > marker), not after a word is written.

Root cause in CalloutCompleter::construct: it matched the whole line against ^(> *)+, ignoring the cursor and anything after the prefix. Since the server registers " " and ">" as completion trigger characters (main.rs), every space inside a block quote re-fired the completer and it unconditionally returned all 27 callouts.

Fix: slice the line to the cursor (mirroring link_completer's line_to_cursor) and only fire when the text after the (> *)+ prefix is empty or a partial callout opener:

// before: matched the entire line, cursor-blind
Regex::new(r"^(?<preceding>(> *)+)").captures(&whole_line)?

// after: cursor-aware; must end right after a partial opener
let line_to_cursor = line_chars.get(0..character)?;
Regex::new(r"^(?<preceding>(> *)+)\[?!?[\w-]*$").captures(line_to_cursor)?

So completions still fire at > , > [, > [!, > [!no, and bare > no, but are suppressed once a space, apostrophe, or finished word appears (> note , > We're …). Nested block quotes (>> ) and the existing nested_level / preceding_text behavior are unchanged. The trigger test is extracted into a pure callout_trigger(line_to_cursor) helper with unit tests.

Test plan

  • cargo test — 78 passing, incl. 4 new callout_completer tests (marker fires; opener-typing fires; prose/space/apostrophe suppressed; non-blockquote rejected).
  • cargo fmt --all -- --check clean; cargo build --locked succeeds.

Link to Devin session: https://app.devin.ai/sessions/cd5d29cf010f4708bdf1a5146f8f3665
Requested by: @Feel-ix-343

…prose

The callout completer matched any line starting with the (> *)+ prefix
against the whole line, ignoring the cursor. Since " " and ">" are
completion trigger characters, every space typed inside a block quote
re-popped all callout completions over prose.

Slice the line to the cursor and only fire when the text after the
block-quote prefix is empty or a partial callout opener ([?!?[\w-]*),
mirroring link_completer's cursor-aware matching. Add unit tests.

Co-Authored-By: Felix Zeller <felixazeller@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant