Skip to content

Commit

Permalink
Fix a missing standard token in semantic highlighting
Browse files Browse the repository at this point in the history
That was used as a fallback, causing a panic when the fallback was chosen.

I also made sure this won't happen again by guaranteeing in the macro generating the tokens that they all exist.
  • Loading branch information
ChayimFriedman2 committed Jan 27, 2025
1 parent ad0aea4 commit 86d5e29
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ macro_rules! define_semantic_token_types {
}

pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[
$(SemanticTokenType::$standard,)*
$(self::types::$standard,)*
$(self::types::$custom),*
];

pub(crate) fn standard_fallback_type(token: SemanticTokenType) -> Option<SemanticTokenType> {
use self::types::*;
$(
if token == $custom {
None $(.or(Some(SemanticTokenType::$fallback)))?
None $(.or(Some(self::types::$fallback)))?
} else
)*
{ Some(token )}
Expand Down Expand Up @@ -60,6 +60,7 @@ define_semantic_token_types![
STRUCT,
TYPE_PARAMETER,
VARIABLE,
TYPE,
}

custom {
Expand Down

0 comments on commit 86d5e29

Please sign in to comment.