Don't complete in comments

This commit is contained in:
Laurenz 2023-02-24 14:22:34 +01:00
parent 7726e8aa4d
commit 151765bb3e

View File

@ -23,7 +23,8 @@ pub fn autocomplete(
) -> Option<(usize, Vec<Completion>)> {
let mut ctx = CompletionContext::new(world, source, cursor, explicit)?;
let _ = complete_field_accesses(&mut ctx)
let _ = complete_comments(&mut ctx)
|| complete_field_accesses(&mut ctx)
|| complete_imports(&mut ctx)
|| complete_rules(&mut ctx)
|| complete_params(&mut ctx)
@ -67,6 +68,11 @@ pub enum CompletionKind {
Symbol(char),
}
/// Complete in comments. Or rather, don't!
fn complete_comments(ctx: &mut CompletionContext) -> bool {
matches!(ctx.leaf.kind(), SyntaxKind::LineComment | SyntaxKind::BlockComment)
}
/// Complete in markup mode.
fn complete_markup(ctx: &mut CompletionContext) -> bool {
// Bail if we aren't even in markup.