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

Common Corner Case where Prompt Background bleeds into Input Field #249

Open
bytebeast opened this issue Sep 19, 2016 · 13 comments
Open

Common Corner Case where Prompt Background bleeds into Input Field #249

bytebeast opened this issue Sep 19, 2016 · 13 comments
Labels

Comments

@bytebeast
Copy link

bytebeast commented Sep 19, 2016

Prompt that is longer than terminal size and wraps around, draws the background after prompt incorrectly after prompt reaches bottom of terminal.

Environment:

  • Iterm2 Build 3.0.10
  • MacOSX El Capitan 10.11.16
  • Python 2.7.12
  • Bash 4.4.0

I have been able to reproduce on several mac laptops. How to reproduce:

  1. Enter a super long directory that wraps around
  2. Keep pressing enter on keyboard until prompt reaches bottom of terminal.

Can someone try and reproduce, and let me know i'm not crazy.

@bytebeast
Copy link
Author

bytebeast commented Oct 4, 2016

I'm also able to reproduce using Mac Terminal Version 2.7.

@b-ryan
Copy link
Owner

b-ryan commented Feb 22, 2018

selection_016

@b-ryan b-ryan added the bug label Feb 22, 2018
@b-ryan
Copy link
Owner

b-ryan commented Feb 22, 2018

Interestingly, I didn't have this issue when I initially tried to reproduce it. But normally I use the "flat" display mode so I don't have the unicode arrows in my prompt. I should test whether this is a contributing factor.

@b-ryan
Copy link
Owner

b-ryan commented Feb 23, 2018

doesn't seem to be the unicode characters. I was not experiencing this when I originally attempted to reproduce because using the newline segment prevents the issue.

After more testing it appears to be related to the use of colors. I stripped out the code that adds any colors and the issue disappears. Still need to dig further into this.

@b-ryan
Copy link
Owner

b-ryan commented Feb 23, 2018

I am inclined to think this is a bug with bash or some other underlying system. I have been testing with a very simple PS1 with colors:

    PS1='\[\e[48;05;10m\] \w \[\e[0m\]'

Which results in the same error. That prompt just sets the background color, prints the current directory, then resets the background color. I am getting the same bleeding with it.

@bytebeast
Copy link
Author

Ok, I believe I found a solution:

export PS1='\[\033[48;05;10m\] \w \[\033[0m\]\[\033[0K'

Will need to test a bit more.

@b-ryan
Copy link
Owner

b-ryan commented Feb 23, 2018

Woah interesting. I am curious how you found that. I tried searching around for this problem but didn't come up with anything.

@bytebeast
Copy link
Author

bytebeast commented Feb 23, 2018

Here we go ( see the Clear Line bullet point ):

Hmm , I think the search was for "ansi color vt100 color codes lines wrap" that came up with that search result.

@bytebeast
Copy link
Author

This appears to fix it:

diff --git a/powerline_shell/__init__.py b/powerline_shell/__init__.py
index 68eb227..603b425 100644
--- a/powerline_shell/__init__.py
+++ b/powerline_shell/__init__.py
@@ -90,7 +90,7 @@ class Powerline(object):
         self.cwd = get_valid_cwd()
         mode = config.get("mode", "patched")
         self.color_template = self.color_templates[args.shell]
-        self.reset = self.color_template % '[0m'
+        self.reset = self.color_template % '[0m\]\[\e[0K'
         self.lock = Powerline.symbols[mode]['lock']
         self.network = Powerline.symbols[mode]['network']
         self.separator = Powerline.symbols[mode]['separator']

@b-ryan
Copy link
Owner

b-ryan commented Feb 23, 2018

Looks about right based on what you've provide so far. This will need some extensive testing, including against other shells.

@Zalgo2462
Copy link

I have the same issue, after applying the suggested patch, things seem to be working correctly. I am running bash 4.4.12 on Ubuntu 17.10.

@b-ryan b-ryan closed this as completed in 86fd04c Apr 21, 2018
b-ryan pushed a commit that referenced this issue Apr 22, 2018
This reverts commit 86fd04c.

Closes #389
@b-ryan b-ryan reopened this Apr 22, 2018
@b-ryan
Copy link
Owner

b-ryan commented Apr 22, 2018

The proposed fix broke things on Mac (#389 )

@shivampotdar
Copy link

shivampotdar commented Feb 22, 2024

As a local fix in one's bashrc - we can add in the _update_ps1 function (from the README).
PS1=${PS1//\[0m/[0m\\]\\[\\e[0K}

Essentially it is doing the thing from bytebeast's comment as a postfix (note the extra \ for escaping \ )

This change works for me!

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

No branches or pull requests

4 participants