Skip to content

Commit

Permalink
interpreter: Find more elements in source code
Browse files Browse the repository at this point in the history
Elements of the form `component Foo { ... }` contain
no `QualifiedName`, so they were ignored. Use the 
`{` as the seelction range for those elements.
  • Loading branch information
hunger committed Nov 8, 2024
1 parent a765da3 commit fc01c54
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions internal/interpreter/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,23 @@ fn find_element_node_at_source_code_position(
if elem.borrow().repeated.is_some() {
return;
}
for (index, node) in elem
.borrow()
.debug
.iter()
.enumerate()
.filter_map(|(i, n)| n.node.QualifiedName().map(|n| (i, n)))
for (index, node_path, node_range) in
elem.borrow().debug.iter().enumerate().map(|(i, n)| {
let text_range = n
.node
.QualifiedName()
.map(|n| n.text_range())
.or_else(|| {
n.node
.child_token(i_slint_compiler::parser::SyntaxKind::LBrace)
.map(|n| n.text_range())
})
.expect("A Element must contain a LBrace somewhere pretty early");

(i, n.node.source_file.path(), text_range)
})
{
if node.source_file.path() == path && node.text_range().contains(offset.into()) {
if node_path == path && node_range.contains(offset.into()) {
result.push((elem.clone(), index));
}
}
Expand Down

0 comments on commit fc01c54

Please sign in to comment.