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 line-wrapping problem #47

Merged
merged 1 commit into from Jul 30, 2020
Merged

Fix line-wrapping problem #47

merged 1 commit into from Jul 30, 2020

Conversation

MetRonnie
Copy link
Contributor

The problem

I had a similar problem to #18 on GNOME Terminal on Red Hat Enterprise Linux 7. If I typed out enough characters to reach the end of the line, the line would wrap back onto the beginning of the same line instead of the next line (until I had typed enough characters to reach the end of the line again, then it would wrap onto the next line). I.e. typing the + char:

user@host:~/foo/bar [master ≡ (3)]$ ++++   # EDGE OF WINDOW

...continuing to type...

++++++ost:~/foo/bar [master ≡ (3)]$ +++++++# EDGE OF WINDOW

The solution

The problem was caused by the symbol definitions, e.g. \xE2\x89\xA1 for the symbol. As per https://unix.stackexchange.com/a/468983/200655

Bash cannot calculate the length [of wide unicode symbols] correctly, so easiest way could be to escape 2 out of three parts of those wide symbols.

i.e. \[\xE2\x89\]\xA1

@lyze lyze merged commit b4c4f47 into lyze:master Jul 30, 2020
@lyze
Copy link
Owner

lyze commented Jul 30, 2020

Nice find. Thanks!

@MetRonnie
Copy link
Contributor Author

MetRonnie commented Jul 31, 2020

Ugh, this appears to have caused a really strange problem with VSCode's integrated terminal when I try to activate a conda environment in it.

Integrated terminal:

user@host:~/foo [master ≡]$ conda activate myenv
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
      File "~/miniconda3/lib/python3.7/site-packages/conda/cli/main.py", line 138, in main
        return activator_main()
      File "~/miniconda3/lib/python3.7/site-packages/conda/activate.py", line 1093, in main
        print(activator.execute(), end='')
    UnicodeEncodeError: 'utf-8' codec can't encode characters in position 95-96: surrogates not allowed
...
user@host:~/foo [master ≡]$ cd ..
user@host:~ $ conda activate myenv
(myenv) user@host:~ $ # So that worked
(myenv) user@host:~ $ which conda
~/miniconda3/bin/conda

Normal/GNOME terminal:

user@host:~/foo [master ≡]$ conda activate myenv
(myenv) user@host:~/foo [master ≡]$ # Works!
(myenv) user@host:~/foo [master ≡]$ which conda
~/miniconda3/condabin/conda

@MetRonnie
Copy link
Contributor Author

MetRonnie commented Jul 31, 2020

Sorry for dumping all this here, but I can't think of a better place for it.

More debugging in the VSCode integrated terminal (fresh terminal):

$ which conda
~/miniconda3/condabin/conda
$ conda activate myenv
# Error report blah blah
$ which conda
~/miniconda3/bin/conda

So that doesn't appear to be the problem. Actually, the line-wrapping issue doesn't exist in the VSCode terminal using posh-git.sh as it was prior to this PR.

The setting Terminal > Integrated: Detect Locale has in its description:

VS Code's terminal only supports UTF-8 encoded data coming from the shell.

so I suspect that's the crux of the issue

lyze added a commit that referenced this pull request Sep 11, 2020
lyze added a commit that referenced this pull request Sep 11, 2020
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.

None yet

2 participants