mirror of
https://github.com/atuinsh/atuin.git
synced 2025-08-19 19:26:33 +02:00
fix: multiline command does not honour max_preview_height (#2624)
Resolves #2610
This commit is contained in:
@@ -540,8 +540,27 @@ impl State {
|
|||||||
&& !results.is_empty()
|
&& !results.is_empty()
|
||||||
{
|
{
|
||||||
let length_current_cmd = results[selected].command.len() as u16;
|
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
|
// 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(
|
std::cmp::min(
|
||||||
settings.max_preview_height,
|
settings.max_preview_height,
|
||||||
(length_current_cmd + preview_width - 1 - border_size)
|
(length_current_cmd + preview_width - 1 - border_size)
|
||||||
|
Reference in New Issue
Block a user