diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-29 00:48:10 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-29 00:48:10 +0300 |
| commit | 324e625c60658ab0de46928be300fc1804af48df (patch) | |
| tree | 4cafa5c8f6794c64863cd1755d93010875af68d3 /src/ui.rs | |
| parent | 1bb2676388a3541360ca106354075d67376a6843 (diff) | |
fix: wrap update preview copy
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 93 |
1 files changed, 4 insertions, 89 deletions
@@ -40,8 +40,8 @@ use self::onboarding::render_onboarding_overlay; use self::panes::{compute_pane_infos, render_panes, resize_tab_panes}; pub(crate) use self::release_notes::{ product_announcement_display_lines, release_notes_close_button_rect, - release_notes_display_lines, release_notes_sections, PRODUCT_ANNOUNCEMENT_MODAL_SIZE, - RELEASE_NOTES_MODAL_SIZE, + release_notes_display_lines, release_notes_sections, release_notes_wrapped_line_count, + PRODUCT_ANNOUNCEMENT_MODAL_SIZE, RELEASE_NOTES_MODAL_SIZE, }; use self::release_notes::{render_product_announcement_overlay, render_release_notes_overlay}; pub(crate) use self::scrollbar::{ @@ -472,16 +472,11 @@ fn _build_hints(items: &[(&str, &str)], key_style: Style, dim_style: Style) -> V #[cfg(test)] mod tests { use super::keybind_help::keybind_help_groups; - use super::release_notes::{release_notes_lines, release_notes_preview_lines}; use super::scrollbar::scrollbar_thumb; use super::*; - use crate::{ - app::state::{Palette, ViewLayout}, - layout::PaneInfo, - workspace::Workspace, - }; + use crate::{app::state::ViewLayout, layout::PaneInfo, workspace::Workspace}; + use ratatui::style::Color; use ratatui::{backend::TestBackend, Terminal}; - use ratatui::{style::Color, text::Line}; #[tokio::test] async fn focused_pane_cursor_wins_during_terminal_render() { @@ -961,13 +956,6 @@ mod tests { assert_eq!(scrollbar_offset_from_drag_row(metrics, track, row, grab), 7); } - fn line_text(line: &Line<'_>) -> String { - line.spans - .iter() - .map(|span| span.content.as_ref()) - .collect::<String>() - } - fn buffer_row_text(buffer: &ratatui::buffer::Buffer, area: Rect, row: u16) -> String { (area.x..area.x + area.width) .map(|x| buffer[(x, row)].symbol()) @@ -992,79 +980,6 @@ mod tests { } #[test] - fn release_notes_inline_code_spans_are_styled_without_backticks() { - let palette = Palette::catppuccin(); - let lines = release_notes_lines("- `herdr pane run ...` now works", &palette); - - assert_eq!(lines.len(), 1); - assert_eq!(line_text(&lines[0].1), " • herdr pane run ... now works"); - assert_eq!(lines[0].1.spans[1].content.as_ref(), "herdr pane run ..."); - assert_eq!(lines[0].1.spans[1].style.fg, Some(palette.accent)); - assert_eq!(lines[0].1.spans[1].style.bg, Some(palette.surface0)); - } - - #[test] - fn release_notes_config_inline_code_uses_nonbreaking_spaces() { - let palette = Palette::catppuccin(); - let lines = release_notes_lines("- After: `new_tab = \"prefix+c\"`", &palette); - - assert_eq!(lines.len(), 1); - assert_eq!( - lines[0].1.spans[2].content.as_ref(), - "new_tab\u{00a0}=\u{00a0}\"prefix+c\"" - ); - assert_eq!( - line_text(&lines[0].1).replace('\u{00a0}', " "), - " • After: new_tab = \"prefix+c\"" - ); - } - - #[test] - fn release_notes_preview_lines_show_update_steps() { - let palette = Palette::catppuccin(); - let lines = release_notes_preview_lines("0.5.0", "herdr update", &palette); - - assert_eq!(lines.len(), 2); - assert_eq!(line_text(&lines[0]), "● update ready"); - assert_eq!( - line_text(&lines[1]), - "detach from this session, then run herdr update in your shell" - ); - assert_eq!(lines[0].spans[0].style.fg, Some(palette.accent)); - assert_eq!(lines[0].spans[1].style.fg, Some(palette.text)); - } - - #[test] - fn release_notes_fenced_code_blocks_render_as_preformatted_lines() { - let palette = Palette::catppuccin(); - let lines = release_notes_lines( - "### Fixed\n```bash\njust check\n- not a bullet\n```\n- after", - &palette, - ); - - assert_eq!(lines.len(), 4); - assert_eq!(line_text(&lines[0].1), " FIXED"); - assert_eq!(line_text(&lines[1].1), "▏ just check"); - assert_eq!(line_text(&lines[2].1), "▏ - not a bullet"); - assert_eq!(line_text(&lines[3].1), " • after"); - assert_eq!(lines[1].1.spans[0].style.fg, Some(palette.accent)); - assert_eq!(lines[1].1.spans[0].style.bg, Some(palette.surface1)); - assert_eq!(lines[1].1.spans[1].style.bg, Some(palette.surface1)); - assert_eq!(lines[1].1.spans[2].style.bg, Some(palette.surface1)); - } - - #[test] - fn release_notes_fenced_code_blocks_preserve_blank_lines() { - let palette = Palette::catppuccin(); - let lines = release_notes_lines("```\nfirst\n\nsecond\n```", &palette); - - assert_eq!(lines.len(), 3); - assert_eq!(line_text(&lines[0].1), "▏ first"); - assert_eq!(line_text(&lines[1].1), "▏ "); - assert_eq!(line_text(&lines[2].1), "▏ second"); - } - - #[test] fn prefix_mode_renders_prefix_indicator() { let mut app = crate::app::state::AppState::test_new(); app.mode = Mode::Prefix; |
