Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
goulvenclech committed Dec 19, 2024
1 parent 18b602f commit 1b5f0d8
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/csslsrs/src/features/document_symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn extract_document_symbols(
Range::new(
position(
line_index,
// We need to include the `@` symbol in the selection range.
token.text_trimmed_range().start() - TextSize::from(1),
encoding,
)
Expand Down
123 changes: 123 additions & 0 deletions crates/csslsrs/tests/document_symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,126 @@ fn test_css_variables() {
],
);
}

#[test]
fn test_at_rule_with_nested_properties() {
let mut ls = LanguageService::default();

assert_document_symbols(
&mut ls,
"@font-palette-values --my-palette {\n font-family: Bixa;\n base-palette: 1;\n override-colors: 0 #ff0000;\n}",
vec![DocumentSymbol {
name: "@font-palette-values".to_string(),
detail: None,
kind: SymbolKind::NAMESPACE,
tags: None,
deprecated: None,
range: Range {
start: Position {
line: 0,
character: 0,
},
end: Position {
line: 4,
character: 1,
},
},
selection_range: Range {
start: Position {
line: 0,
character: 0,
},
end: Position {
line: 0,
character: 20,
},
},
children: Some(vec![
DocumentSymbol {
name: "font-family".to_string(),
detail: None,
kind: SymbolKind::PROPERTY,
tags: None,
deprecated: None,
range: Range {
start: Position {
line: 1,
character: 2,
},
end: Position {
line: 1,
character: 19,
},
},
selection_range: Range {
start: Position {
line: 1,
character: 2,
},
end: Position {
line: 1,
character: 13,
},
},
children: None,
},
DocumentSymbol {
name: "base-palette".to_string(),
detail: None,
kind: SymbolKind::PROPERTY,
tags: None,
deprecated: None,
range: Range {
start: Position {
line: 2,
character: 2,
},
end: Position {
line: 2,
character: 17,
},
},
selection_range: Range {
start: Position {
line: 2,
character: 2,
},
end: Position {
line: 2,
character: 14,
},
},
children: None,
},
DocumentSymbol {
name: "override-colors".to_string(),
detail: None,
kind: SymbolKind::PROPERTY,
tags: None,
deprecated: None,
range: Range {
start: Position {
line: 3,
character: 2,
},
end: Position {
line: 3,
character: 28,
},
},
selection_range: Range {
start: Position {
line: 3,
character: 2,
},
end: Position {
line: 3,
character: 17,
},
},
children: None,
},
]),
}],
);
}

0 comments on commit 1b5f0d8

Please sign in to comment.