Allow semantic tokens for strings to be disabled

This commit is contained in:
John Renner
2021-05-10 13:09:38 -07:00
parent ba86203987
commit c3ba1f14fa
4 changed files with 58 additions and 9 deletions

View File

@@ -381,6 +381,7 @@ pub(crate) fn semantic_tokens(
text: &str,
line_index: &LineIndex,
highlights: Vec<HlRange>,
include_strings: bool
) -> lsp_types::SemanticTokens {
let id = TOKEN_RESULT_COUNTER.fetch_add(1, Ordering::SeqCst).to_string();
let mut builder = semantic_tokens::SemanticTokensBuilder::new(id);
@@ -389,8 +390,11 @@ pub(crate) fn semantic_tokens(
if highlight_range.highlight.is_empty() {
continue;
}
let (type_, mods) = semantic_token_type_and_modifiers(highlight_range.highlight);
let token_index = semantic_tokens::type_index(type_);
let (typ, mods) = semantic_token_type_and_modifiers(highlight_range.highlight);
if !include_strings && typ == lsp_types::SemanticTokenType::STRING {
continue;
}
let token_index = semantic_tokens::type_index(typ);
let modifier_bitset = mods.0;
for mut text_range in line_index.index.lines(highlight_range.range) {