Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix multiline prompt resize issue #841

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading