Skip to main content

detect_trigger

Function detect_trigger 

Source
pub fn detect_trigger(text: &str, cursor: usize) -> Option<TriggerContext>
Expand description

Inspect text at cursor (a byte offset) and decide whether an autocomplete popup should be active.

Returns Some(TriggerContext) when the cursor sits inside an open wikilink target ([[…|) or an open hashtag word (#…). Returns None otherwise — including when the cursor is inside a code span, fenced block, frontmatter, or already-closed wikilink/markdown link (delegated to kimun_core::note::scan::is_inside_exclusion_zone).

Disambiguation rules in play:

  • Hashtag vs. Markdown header: a # at the start of a line only triggers the popup once the user has typed the next character AND that character is not a space (a space means # Heading).
  • Wikilink target vs. alias: in [[target|alias]], only the target portion triggers; the cursor crossing the | deactivates the popup.