Skip to content

Commit

Permalink
refactor: flattened was renamed to node
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed May 14, 2024
1 parent 6167722 commit d2b86dc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ where
let mut current_height = 0;
let has_selection = !state.selected.is_empty();
#[allow(clippy::cast_possible_truncation)]
for flattened in visible.iter().skip(state.offset).take(end - start) {
for node in visible.iter().skip(state.offset).take(end - start) {
let x = area.x;
let y = area.y + current_height;
let height = flattened.height as u16;
let height = node.height as u16;
current_height += height;

let area = Rect {
Expand All @@ -249,7 +249,7 @@ where
height,
};

let is_selected = state.selected == flattened.identifier;
let is_selected = state.selected == node.identifier;
let after_highlight_symbol_x = if has_selection {
let symbol = if is_selected {
self.highlight_symbol
Expand All @@ -263,17 +263,17 @@ where
};

let after_depth_x = {
let indent_width = flattened.depth() * 2;
let indent_width = node.depth() * 2;
let (after_indent_x, _) = buf.set_stringn(
after_highlight_symbol_x,
y,
" ".repeat(indent_width),
indent_width,
Style::new(),
);
let symbol = if !flattened.has_children {
let symbol = if !node.has_children {
self.node_no_children_symbol
} else if state.open.contains(&flattened.identifier) {
} else if state.open.contains(&node.identifier) {
self.node_open_symbol
} else {
self.node_closed_symbol
Expand All @@ -289,7 +289,7 @@ where
width: area.width.saturating_sub(after_depth_x - x),
..area
};
self.data.render(&flattened.identifier, text_area, buf);
self.data.render(&node.identifier, text_area, buf);

if is_selected {
buf.set_style(area, self.highlight_style);
Expand Down

0 comments on commit d2b86dc

Please sign in to comment.