Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Aug 5, 2024
1 parent 7c389c5 commit a15187b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions promkit/src/core/json/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ impl State {
StyledGraphemes::from_iter([
StyledGraphemes::from(" ".repeat(self.indent_level(kind))),
self.gen_syntax_style(kind)
.apply_attribute(self.active_item_attribute),
.apply_attribute(self.active_item_attribute),
])
} else {
StyledGraphemes::from_iter([
StyledGraphemes::from(" ".repeat(self.indent_level(kind))),
self.gen_syntax_style(kind),
])
.apply_attribute(self.inactive_item_attribute)
.apply_attribute(self.inactive_item_attribute)
}
})
.collect()
.collect()
}

pub fn json_str(&self) -> String {
Expand All @@ -198,28 +198,27 @@ impl State {
.collect::<Vec<String>>()
.join("\n")
}

}

impl PaneFactory for State {

fn create_pane(&self, width: u16, height: u16) -> Pane {
let height = match self.lines {
Some(lines) => lines.min(height as usize),
None => height as usize,
};

let styled_json = self.styled_json();
let matrix = styled_json
.into_iter()
.enumerate()
.fold((vec![], 0), |(mut acc, pos), (_, item)| {
let rows = item.matrixify(width as usize, height, 0).0;
if pos < self.stream.cursor.cross_contents_position() + height {
acc.extend(rows);
}
(acc, pos + 1)
});
let matrix =
styled_json
.into_iter()
.enumerate()
.fold((vec![], 0), |(mut acc, pos), (_, item)| {
let rows = item.matrixify(width as usize, height, 0).0;
if pos < self.stream.cursor.cross_contents_position() + height {
acc.extend(rows);
}
(acc, pos + 1)
});

Pane::new(matrix.0, 0)
}
Expand Down

0 comments on commit a15187b

Please sign in to comment.