fix(lsp): filter scheme in semantic tokens registration options (#28756)

This commit is contained in:
Nayeem Rahman 2025-04-04 22:27:20 +01:00 committed by GitHub
parent 757ef462f7
commit 37b760e3c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,30 +39,33 @@ fn code_action_capabilities(
pub fn semantic_tokens_registration_options( pub fn semantic_tokens_registration_options(
) -> SemanticTokensRegistrationOptions { ) -> SemanticTokensRegistrationOptions {
const LANGUAGES: [&str; 4] = [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
];
const SCHEMES: [&str; 5] = [
"file",
"untitled",
"deno",
"vscode-notebook-cell",
"deno-notebook-cell",
];
let mut document_filters =
Vec::with_capacity(LANGUAGES.len() * SCHEMES.len());
for language in &LANGUAGES {
for scheme in &SCHEMES {
document_filters.push(DocumentFilter {
language: Some(language.to_string()),
scheme: Some(scheme.to_string()),
pattern: None,
});
}
}
SemanticTokensRegistrationOptions { SemanticTokensRegistrationOptions {
text_document_registration_options: TextDocumentRegistrationOptions { text_document_registration_options: TextDocumentRegistrationOptions {
document_selector: Some(vec![ document_selector: Some(document_filters),
DocumentFilter {
language: Some("javascript".to_string()),
scheme: None,
pattern: None,
},
DocumentFilter {
language: Some("javascriptreact".to_string()),
scheme: None,
pattern: None,
},
DocumentFilter {
language: Some("typescript".to_string()),
scheme: None,
pattern: None,
},
DocumentFilter {
language: Some("typescriptreact".to_string()),
scheme: None,
pattern: None,
},
]),
}, },
semantic_tokens_options: SemanticTokensOptions { semantic_tokens_options: SemanticTokensOptions {
legend: get_legend(), legend: get_legend(),