atuinsh / atuin

✨ Magical shell history
https://atuin.sh
MIT License
18.61k stars 520 forks source link

In fish with `inline_height` set, the prompt line is intersected by the first line of atuin #1289

Open rmartine-ias opened 9 months ago

rmartine-ias commented 9 months ago

Describe the bug

See below how the green r in ^rmartine and the r in master remain onscreen in the first line of the atuin dialog:

Screen Recording 2023-10-06 at 12 47 27 PM mov

This does not happen for me in zsh. It is not too bad unless I also disable the help bar, then it is much more prominent.

Confirmed this happens in Terminal.app, with starship prompt disabled, outside of tmux, with all custom fish config (config.fish/conf.d) disabled.

To Reproduce Steps to reproduce the behavior:

  1. Install fish, add atuin
  2. Set inline_height to be less than the height of the terminal
  3. Press up-arrow or ctrl-r

Expected behavior Prompt line to not be intersected, the same as zsh.

Error logs Please try and provide error logs where possible

Device (please complete the following information):

conradludgate commented 9 months ago

Thanks for the report, I'll see if I can reproduce it

arcuru commented 8 months ago

I can repro this as well. It also isn't clearing everything from the top line, so anywhere that Atuin paints whitespace are still present when Atuin is up, you can see that in the image above.

To be honest, I'd actually prefer this if it properly cleared existing characters, since I use invert = true. It doesn't move the position of my input and just gives a dropdown list of choices. But this should still probably be fixed.

Lillecarl commented 5 months ago
diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs
index 8ae03752..bff1c872 100644
--- a/atuin/src/command/client/search/interactive.rs
+++ b/atuin/src/command/client/search/interactive.rs
@@ -490,7 +490,8 @@ impl State {
         let mode_width = MAX_WIDTH - pref.len();
         // sanity check to ensure we don't exceed the layout limits
         debug_assert!(mode_width >= mode.len(), "mode name '{mode}' is too long!");
-        let input = format!("[{pref}{mode:^mode_width$}] {}", self.search.input.as_str(),);
+        let input = format!("[{pref}{mode:^mode_width$}]").replace(" ", "\u{a0}");
+        let input = format!("{input} {}", self.search.input.as_str());
         let input = Paragraph::new(input);
         if style.compact {
             input

https://asciinema.org/a/gzgzolH2QtPtCNv6CgcnQyV3h

This is my first ever contribution to a Rust project (just had the LSP installed the other day), so take it with a pinch of salt. What it does is it replaces the space character with a non-breaking space character, which fish with the repaint thingy will redraw.

There's still an extra square bracket on the left, not the end of the world. But while we're at it it might be something worth looking into (I have to go to bed)

EDIT: My issue is a reproduction and fix for the problem @arcuru, but anywhere atuin is writing spaces they should probably be replaced by nbsp instead. See https://en.wikipedia.org/wiki/Whitespace_character

EDIT2: This seems like a fish-shell bug. They're also mostly written in Rust now so people here might have an easy time understanding the codebase. The current release is the last before they're "100% Rust" 😄 I'll open an issue tomorrow