mirror of
https://github.com/codewhale-hq/Codewhale.git
synced 2026-11-08 17:10:50 -10:00
Compare commits
1
Commits
main
...
boat/issue-7049
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
458d7e6f2b |
No files matched your search
@@ -69,16 +69,24 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_growth_expands_up_to_the_density_cap() {
|
||||
fn content_growth_expands_past_the_density_cap_up_to_available_room() {
|
||||
// Six content rows + border fits under the Comfortable cap of 9.
|
||||
let height = desired_height(6, 0, 12, ComposerDensity::Comfortable, false);
|
||||
assert_eq!(height, 7, "typed content must grow the composer: {height}");
|
||||
|
||||
// Past the cap the density setting wins, not the content.
|
||||
// Past the cap the content wins, bounded by the room on offer.
|
||||
let capped = desired_height(20, 0, 30, ComposerDensity::Comfortable, false);
|
||||
assert_eq!(capped, 9, "Comfortable caps total rows at 9");
|
||||
assert_eq!(
|
||||
capped, 21,
|
||||
"long content grows past the density cap: {capped}"
|
||||
);
|
||||
let spacious = desired_height(20, 0, 30, ComposerDensity::Spacious, false);
|
||||
assert_eq!(spacious, 12, "Spacious caps total rows at 12");
|
||||
assert_eq!(
|
||||
spacious, 21,
|
||||
"long content grows past the density cap: {spacious}"
|
||||
);
|
||||
let bounded = desired_height(20, 0, 12, ComposerDensity::Comfortable, false);
|
||||
assert_eq!(bounded, 12, "growth stops at the available room: {bounded}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1582,7 +1582,8 @@ pub(crate) fn render(f: &mut Frame, app: &mut App, _config: &Config) -> Option<(
|
||||
.saturating_add(info_height)
|
||||
.saturating_add(top_work_strip_height),
|
||||
)
|
||||
.max(MIN_COMPOSER_HEIGHT);
|
||||
.max(MIN_COMPOSER_HEIGHT)
|
||||
.min((body_height / 2).max(MIN_COMPOSER_HEIGHT));
|
||||
let composer_height = if !pet_main && mini && !mini_cfg.keep_input {
|
||||
0
|
||||
} else {
|
||||
|
||||
@@ -1480,8 +1480,7 @@ impl Renderable for ComposerWidget<'_> {
|
||||
self.render_plan(area, buf);
|
||||
}
|
||||
fn desired_height(&self, width: u16) -> u16 {
|
||||
self.frame()
|
||||
.desired_height(width, self.max_height.min(self.max_height_cap()))
|
||||
self.frame().desired_height(width, self.max_height)
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn cursor_pos(&self, area: Rect) -> Option<(u16, u16)> {
|
||||
@@ -5746,11 +5745,15 @@ mod tests {
|
||||
assert_eq!(measure(&app), (n + 2, n), "{n} typed lines");
|
||||
}
|
||||
|
||||
// Past the cap the density setting wins, not the content.
|
||||
// Past the cap the content wins, bounded by the room the layout
|
||||
// offered (AVAILABLE): 40 input rows + 2 borders, capped at 24.
|
||||
app.clear_input();
|
||||
app.insert_str(&vec!["over"; 40].join("\n"));
|
||||
let cap = composer_max_height(ComposerDensity::Comfortable);
|
||||
assert_eq!(measure(&app), (cap, cap - 2), "content beyond the cap");
|
||||
assert_eq!(
|
||||
measure(&app),
|
||||
(AVAILABLE, AVAILABLE - 2),
|
||||
"long draft grows past the cap"
|
||||
);
|
||||
|
||||
// Submitting returns the composer to its stable density floor.
|
||||
assert!(app.submit_input().is_some());
|
||||
|
||||
@@ -194,10 +194,13 @@ pub fn native_composer_height(
|
||||
} else {
|
||||
usize::from(available >= 2)
|
||||
};
|
||||
rows.max(floor)
|
||||
.saturating_add(menu)
|
||||
.saturating_add(border)
|
||||
.clamp(1, usize::from(available.min(density.max_rows()))) as u16
|
||||
let desired = rows.max(floor).saturating_add(menu).saturating_add(border);
|
||||
let cap = if desired > usize::from(density.max_rows()) {
|
||||
usize::from(available)
|
||||
} else {
|
||||
usize::from(available).min(usize::from(density.max_rows()))
|
||||
};
|
||||
desired.clamp(1, cap) as u16
|
||||
}
|
||||
|
||||
/// Display width after the kit's control/bidi guard; raw source scalars remain
|
||||
|
||||
Reference in new issue
Block a user