mirror of
https://github.com/ratatui/ratatui.git
synced 2025-09-27 04:50:46 +00:00
fix: padding_right()
should set right padding instead of left (#1837)
Fixes https://github.com/ratatui/ratatui/issues/1836
This commit is contained in:
parent
60a81913ed
commit
c238aca83a
@ -347,7 +347,7 @@ impl<'a> Tabs<'a> {
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
self.padding_left = padding.into();
|
||||
self.padding_right = padding.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
@ -553,6 +553,24 @@ mod tests {
|
||||
test_case(tabs, Rect::new(0, 0, 30, 1), &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_left_padding() {
|
||||
let tabs = Tabs::new(vec!["Tab1", "Tab2", "Tab3", "Tab4"]).padding_left("---");
|
||||
let mut expected = Buffer::with_lines(["---Tab1 │---Tab2 │---Tab3 │---Tab4 "]);
|
||||
// first tab selected
|
||||
expected.set_style(Rect::new(3, 0, 4, 1), DEFAULT_HIGHLIGHT_STYLE);
|
||||
test_case(tabs, Rect::new(0, 0, 40, 1), &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_right_padding() {
|
||||
let tabs = Tabs::new(vec!["Tab1", "Tab2", "Tab3", "Tab4"]).padding_right("++");
|
||||
let mut expected = Buffer::with_lines([" Tab1++│ Tab2++│ Tab3++│ Tab4++ "]);
|
||||
// first tab selected
|
||||
expected.set_style(Rect::new(1, 0, 4, 1), DEFAULT_HIGHLIGHT_STYLE);
|
||||
test_case(tabs, Rect::new(0, 0, 40, 1), &expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_more_padding() {
|
||||
let tabs = Tabs::new(vec!["Tab1", "Tab2", "Tab3", "Tab4"]).padding("---", "++");
|
||||
|
Loading…
x
Reference in New Issue
Block a user