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

🚧 fix: inputs get messed up when a line overflows #36

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roele
Copy link
Collaborator

@roele roele commented Jan 31, 2024

overflowing lines need to be calculated seperately of height so we can move the cursor accordingly before clearing. for selects this is much more involved since capacity of options also need to be calculated based on title,description and help which all might be overflowing.

@roele roele linked an issue Jan 31, 2024 that may be closed by this pull request
@roele roele changed the title fix: inputs get messed up when a line overflows 🚧 fix: inputs get messed up when a line overflows Feb 1, 2024
// calculate potential overflow of lines overflowing terminal width
let overflow = output
.lines()
.map(|l| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. I feel like maybe with "fold" or "reduce" you could make it a tiny bit more concise but honestly I'd probably just do it the way you did

src/confirm.rs Outdated
@@ -193,7 +195,15 @@ impl<'a> Confirm<'a> {
Ok(std::str::from_utf8(out.as_slice()).unwrap().to_string())
}

fn set_height(&mut self, output: String) -> io::Result<()> {
let height = common::get_height(&self.term, output);
Copy link
Owner

@jdx jdx Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let height = common::get_height(&self.term, output);
let (h, o) = common::get_height(&self.term, output);

@jdx
Copy link
Owner

jdx commented Feb 1, 2024

this looks like the right approach to me—definitely tough to review this kind of code though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inputs get messed up when a line overflows
2 participants