mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
live preview: Insert source code before other elements
... and use that to drop into layouts.
This commit is contained in:
parent
9615fbe4b4
commit
c1707d52e1
6 changed files with 203 additions and 243 deletions
|
@ -49,16 +49,20 @@ impl ElementRcNode {
|
|||
|
||||
Some(Self { element, debug_index })
|
||||
}
|
||||
|
||||
pub fn find_in_or_below(element: ElementRc, path: &std::path::Path, offset: u32) -> Option<Self> {
|
||||
let debug_index = element.borrow().debug.iter().position(|(n, _)| {
|
||||
|
||||
pub fn find_in_or_below(
|
||||
element: ElementRc,
|
||||
path: &std::path::Path,
|
||||
offset: u32,
|
||||
) -> Option<Self> {
|
||||
let debug_index = element.borrow().debug.iter().position(|(n, _)| {
|
||||
u32::from(n.text_range().start()) == offset && n.source_file.path() == path
|
||||
});
|
||||
if let Some(debug_index) = debug_index {
|
||||
Some(Self { element, debug_index })
|
||||
} else {
|
||||
for c in &element.borrow().children {
|
||||
let result = Self::find_in_or_below(c.clone(), path, offset);
|
||||
let result = Self::find_in_or_below(c.clone(), path, offset);
|
||||
if result.is_some() {
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue