Skip to content

Commit 0a08c5b

Browse files
committed
feat(ls): improve code completion for arrays.
Now the completion includes the brackets for indexing the array, which is more useful.
1 parent 7ab9888 commit 0a08c5b

File tree

2 files changed

+405
-0
lines changed

2 files changed

+405
-0
lines changed

ls/src/features/completion.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,16 @@ fn module_suggestions(
483483
})
484484
.collect()
485485
} else {
486+
let insert_text = match &ty {
487+
Type::Array(_) => format!("{name}[${{1}}]${{2}}"),
488+
_ => format!("{name}"),
489+
};
490+
486491
vec![CompletionItem {
487492
label: name.to_string(),
488493
kind: Some(CompletionItemKind::FIELD),
494+
insert_text: Some(insert_text),
495+
insert_text_format: Some(InsertTextFormat::SNIPPET),
489496
label_details: Some(CompletionItemLabelDetails {
490497
description: Some(ty_to_string(&ty)),
491498
..Default::default()

0 commit comments

Comments
 (0)