summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/completion/user_command.rs
blob: 26708e69ecab9af8e03d4e791d2c519208683b69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use base_db::DocumentData;

use crate::util::cursor::CursorContext;

use super::builder::CompletionBuilder;

pub fn complete<'db>(
    context: &'db CursorContext,
    builder: &mut CompletionBuilder<'db>,
) -> Option<()> {
    let range = context.cursor.command_range(context.offset)?;

    for document in &context.project.documents {
        let DocumentData::Tex(data) = &document.data else { continue };
        for (_, name) in data.semantics.commands.iter().filter(|(r, _)| *r != range) {
            builder.user_command(range, name);
        }
    }

    Some(())
}