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

Better behaviour on resize #675

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Comment for known bug
  • Loading branch information
Daniel Somerfield committed Dec 3, 2023
commit 6f1dd80c7eea06dc6a25966557363562308a761a
8 changes: 7 additions & 1 deletion src/painting/painter.rs
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@

/// Returns the available lines from the prompt down
pub fn remaining_lines(&self) -> u16 {
self.screen_height().saturating_sub(self.prompt_start_row)

Check warning on line 85 in src/painting/painter.rs

Codecov / codecov/patch

src/painting/painter.rs#L85

Added line #L85 was not covered by tests
}

/// Sets the prompt origin position and screen size for a new line editor
@@ -406,9 +406,15 @@
// The question is whether we can afford it. If not, perhaps we should use it in some scenarios but not others
// The problem is trying to calculate this internally doesn't seem to be reliable because terminals might
// have additional text in their buffer that messes with the offset on scroll.
// It seems like it _should_ be ok because it only happens on resize
// It seems like it _should_ be ok because it only happens on resize.

// Known bug: on iterm2 and kitty, clearing the screen via CMD-K doesn't reset
// the position. Might need to special-case this.
//
// I assume this is a bug with the position() call but haven't figured that
// out yet.
if let Ok(position) = cursor::position() {
self.prompt_start_row = position.1;

Check warning on line 417 in src/painting/painter.rs

Codecov / codecov/patch

src/painting/painter.rs#L416-L417

Added lines #L416 - L417 were not covered by tests
}
}

Loading