aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorMatthew Berryman <matthew@acrossthecloud.net>2025-03-12 20:53:48 +1030
committerGitHub <noreply@github.com>2025-03-12 10:23:48 +0000
commita56d0cfd5ecdc5e47dffa88a22083fe0f04abc25 (patch)
treef3f0d52d1cc494317a318ef903f86b6d19ff1546 /crates
parentchore(release): prepare for release 18.5.0-beta.1 (#2622) (diff)
downloadatuin-a56d0cfd5ecdc5e47dffa88a22083fe0f04abc25.zip
fix: multiline command does not honour max_preview_height (#2624)
Resolves #2610
Diffstat (limited to 'crates')
-rw-r--r--crates/atuin/src/command/client/search/interactive.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
index 4b672705..3c63dc70 100644
--- a/crates/atuin/src/command/client/search/interactive.rs
+++ b/crates/atuin/src/command/client/search/interactive.rs
@@ -540,8 +540,27 @@ impl State {
&& !results.is_empty()
{
let length_current_cmd = results[selected].command.len() as u16;
+ // calculate the number of newlines in the command
+ let num_newlines = results[selected]
+ .command
+ .chars()
+ .filter(|&c| c == '\n')
+ .count() as u16;
+ if num_newlines > 0 {
+ std::cmp::min(
+ settings.max_preview_height,
+ results[selected]
+ .command
+ .split('\n')
+ .map(|line| {
+ (line.len() as u16 + preview_width - 1 - border_size)
+ / (preview_width - border_size)
+ })
+ .sum(),
+ ) + border_size * 2
+ }
// The '- 19' takes the characters before the command (duration and time) into account
- if length_current_cmd > preview_width - 19 {
+ else if length_current_cmd > preview_width - 19 {
std::cmp::min(
settings.max_preview_height,
(length_current_cmd + preview_width - 1 - border_size)