summaryrefslogtreecommitdiff
path: root/support/texlab/src/features/completion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/features/completion.rs')
-rw-r--r--support/texlab/src/features/completion.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/support/texlab/src/features/completion.rs b/support/texlab/src/features/completion.rs
index f9ad8554cd..cb6a66f3cd 100644
--- a/support/texlab/src/features/completion.rs
+++ b/support/texlab/src/features/completion.rs
@@ -24,6 +24,7 @@ use std::borrow::Cow;
use cancellation::CancellationToken;
use cstree::TextSize;
use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher};
+use itertools::Itertools;
use lsp_types::{
CompletionItem, CompletionList, CompletionParams, CompletionTextEdit, Documentation,
InsertTextFormat, MarkupContent, MarkupKind, TextEdit,
@@ -159,7 +160,12 @@ fn score(context: &CursorContext<CompletionParams>, items: &mut Vec<InternalComp
}
Cursor::Latex(token) if token.kind() == latex::WORD => {
if let Some(key) = latex::Key::cast(token.parent()) {
- key.to_string().into()
+ key.words()
+ .take_while(|word| word.text_range() != token.text_range())
+ .chain(std::iter::once(token))
+ .filter(|word| word.text_range().start() < context.offset)
+ .join(" ")
+ .into()
} else {
token.text().into()
}