Skip to content

Commit

Permalink
fix(term): handle too small width case
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed May 4, 2024
1 parent 466368f commit 62b5b33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions crates/synd_term/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ pub struct Entry {

impl Entry {
pub fn summary_text(&self, width: usize) -> Option<String> {
self.summary
.as_deref()
.map(|summary| html2text::from_read(summary.as_bytes(), width))
self.summary.as_deref().map(|summary| {
html2text::config::plain()
.string_from_read(summary.as_bytes(), width)
.unwrap_or_default()
})
}

pub fn requirement(&self) -> Requirement {
Expand Down
7 changes: 5 additions & 2 deletions crates/synd_term/src/ui/components/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,13 @@ impl Filter {
}
spans.push(label);

Line::from(spans).render(area, buf);
let search = Line::from(spans);
let margin = search.width() + 1;
search.render(area, buf);

let prompt_area = Rect {
x: area.x + 22, // TODO: handle edge case
#[allow(clippy::cast_possible_truncation)]
x: area.x + margin as u16,
..area
};
let render_cursor = if self.state == State::SearchFiltering {
Expand Down
2 changes: 1 addition & 1 deletion crates/synd_term/src/ui/components/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Tabs {
pub fn render(&self, area: Rect, buf: &mut Buffer, cx: &Context<'_>) {
let area = Rect {
x: area.x + 3,
width: area.width - 5,
width: area.width.saturating_sub(5),
..area
};
// left padding * 2 + len("Entries" + "Feeds") = 20
Expand Down

0 comments on commit 62b5b33

Please sign in to comment.