Skip to content

Commit

Permalink
Fix multiline prompt resize issue (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
blindFS authored Oct 9, 2024
1 parent 28aeeda commit 5e556bf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/painting/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct Painter {
terminal_size: (u16, u16),
last_required_lines: u16,
large_buffer: bool,
just_resized: bool,
after_cursor_lines: Option<String>,
}

Expand All @@ -105,6 +106,7 @@ impl Painter {
terminal_size: (0, 0),
last_required_lines: 0,
large_buffer: false,
just_resized: false,
after_cursor_lines: None,
}
}
Expand Down Expand Up @@ -197,6 +199,15 @@ impl Painter {
let screen_width = self.screen_width();
let screen_height = self.screen_height();

// Handle resize for multi line prompt
if self.just_resized {
self.prompt_start_row = self.prompt_start_row.saturating_sub(
(lines.prompt_str_left.matches('\n').count()
+ lines.prompt_indicator.matches('\n').count()) as u16,
);
self.just_resized = false;
}

// Lines and distance parameters
let remaining_lines = self.remaining_lines();
let required_lines = lines.required_lines(screen_width, menu);
Expand Down Expand Up @@ -488,6 +499,7 @@ impl Painter {
// out yet.
if let Ok(position) = cursor::position() {
self.prompt_start_row = position.1;
self.just_resized = true;
}
}

Expand Down

0 comments on commit 5e556bf

Please sign in to comment.