fix: apply label instead of bib title name in at completion (#485)

* fix: apply label instead of bib title name in `at` completion

* test: snapshot testing for #483

* test: add more label-related snapshot testings

---------

Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
This commit is contained in:
Zike Xu 2024-08-04 23:33:02 +08:00 committed by GitHub
parent 859fb468e2
commit 60f3200088
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 283 additions and 9 deletions

View file

@ -320,6 +320,20 @@ mod tests {
let mut includes = HashSet::new();
let mut excludes = HashSet::new();
let must_compile = properties
.get("compile")
.map(|v| v.trim() == "true")
.unwrap_or(false);
let doc = if must_compile {
let doc = typst::compile(ctx.world(), &mut Default::default()).unwrap();
Some(VersionedDocument {
version: 0,
document: Arc::new(doc),
})
} else {
None
};
for kk in properties.get("contains").iter().flat_map(|v| v.split(',')) {
// split first char
let (kind, item) = kk.split_at(1);
@ -369,7 +383,7 @@ mod tests {
position: ctx.to_lsp_pos(s, &source),
explicit: false,
};
results.push(request.request(ctx, None).map(|resp| {
results.push(request.request(ctx, doc.clone()).map(|resp| {
// CompletionResponse::Array(items)
match resp {
CompletionResponse::List(l) => CompletionResponse::List(CompletionList {