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

Subshell executions have wrong number of lines #56

Open
EmperorCookie opened this issue Apr 14, 2023 · 9 comments
Open

Subshell executions have wrong number of lines #56

EmperorCookie opened this issue Apr 14, 2023 · 9 comments

Comments

@EmperorCookie
Copy link

EmperorCookie commented Apr 14, 2023

Running ls-interactive in a subshell causes it to default to a certain number of lines.

Repro

  1. Run cd $(ls-interactive)
  2. Observe behavior

Expected
ls-interactive fits to the terminal even when invoked from within a subshell.

@Araxeus
Copy link
Owner

Araxeus commented Apr 14, 2023

What do you mean “default to a certain number of lines” ?

I'm on Windows and can't reproduce this, neither on NuShell / PowerShell / Batch

@EmperorCookie
Copy link
Author

EmperorCookie commented Apr 14, 2023

If my terminal is 10 lines tall, ls-interactive will be 10 lines tall, but cd $(ls-interactive) will be taller than the terminal, so the cursor can go off screen and the header doesn't show.

Left is straight, right is subshell.
image

I'm running bash in Linux, and the screenshot is within tmux but the behavior is identical in regular bash.

@Araxeus
Copy link
Owner

Araxeus commented Apr 14, 2023

Thats very weird since we just write lines to terminal then clear the last lines on refresh

Without more info it would be really hard for me to fix this (since I can't reproduce this on my NuShell terminal)

fn write_formatted_prompt<F: FnOnce(&mut TermRenderer, &mut dyn fmt::Write) -> fmt::Result>(
&mut self,
f: F,
) -> io::Result<()> {
self.write_formatted_line(f)?;
if self.prompts_reset_height {
self.prompt_height = self.height;
self.height = 0;
}
Ok(())
}

pub fn clear(&mut self) -> io::Result<()> {
self.term
.clear_last_lines(self.height + self.prompt_height)?;
self.height = 0;
Ok(())
}

@EmperorCookie
Copy link
Author

I have yet to learn Rust but I have good programming experience, I'll try to clone and setup a dev environment and see if I can whip a PR up.

Disclaimer, I'm not fully taking responsibility for this bugfix and cannot guarantee success 😅

@Araxeus
Copy link
Owner

Araxeus commented Apr 14, 2023

Sure, FYI I just set up WSL2 and ran the program in bash. it ran fine

image

@EmperorCookie
Copy link
Author

Interesting. I tried investigating issues in my setup as well but couldn't find anything. I'll keep searching in that space as well.

@EmperorCookie
Copy link
Author

Thank you for being patient!

Unfortunately I couldn't find the time I would need to get around in Rust.

However, I tested an interactive command substitution in Python and can confirm that the issue doesn't occur there. I'm able to get the correct layout with no difference in my environment other than just running ls-interactive.

@Araxeus
Copy link
Owner

Araxeus commented Apr 21, 2023

I've personally tested Bash + Batch + Powershell + Fish + NuShell (Gnome terminal on Ubuntu + Windows Terminal + WSL)

So my guess is that there is some sort of weird conflict in your bash settings

@EmperorCookie
Copy link
Author

I'm not going to chase this any further I think.

I'll let you figure out if you want to keep this open or close it as could not reproduce.

Thank you for your time!

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

No branches or pull requests

2 participants