blob: 99d9883ee91657c25210be9707532ea3d74ad361 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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)?;
let token = context.cursor.as_tex()?;
let db = context.db;
for document in context.related() {
if let Some(data) = document.parse(db).as_tex() {
let text = document.contents(db).text(db);
for name in data
.analyze(db)
.command_name_ranges(db)
.iter()
.copied()
.filter(|range| *range != token.text_range())
.map(|range| &text[std::ops::Range::<usize>::from(range)])
{
builder.user_command(range, name);
}
}
}
Some(())
}
|