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

Terminal in Jupyter notebook break line for unicode incorrectly #8361

Closed
yuyichao opened this issue Apr 22, 2015 · 3 comments
Closed

Terminal in Jupyter notebook break line for unicode incorrectly #8361

yuyichao opened this issue Apr 22, 2015 · 3 comments
Milestone

Comments

@yuyichao
Copy link

Steps to reproduce

  1. make a file txt with content

    啊啊啊啊啊啊啊
    
  2. cat this file in the jupyter notebook terminal (availabe at url /terminal/*)

The terminal seems to break the line before the last non-ascii character.

It also seems to be confused about the line number since when I cat this file a couple times, the height of the terminal window is larger than the browser window and the scroll bar appears.

@takluyver
Copy link
Member

Again, I think this is an issue with term.js, though hopefully an easier one to fix than the other one you reported. I have checked what gets sent over the websocket, and that is correct '啊啊啊啊啊啊\r\n'.

I'll try to dig into that today. I feel a bit bad just pointing all these issues to term.js without doing anything to help improve it.

@takluyver
Copy link
Member

OK, I've worked out more or less what's going on here.

First, even with monospace fonts, is wider than standard Latin characters, at least on my computer. You can see here if this is the same for you:

abcdef
啊啊啊啊啊啊

Since term.js uses the width of a standard character to calculate the number of columns in the terminal, this means that the row ends up wider than it should be, and it gets wrapped to a second line. Because the rest of the line is non-breaking spaces, and possibly because it's a particle rather than a word character, the browser breaks the line before the last 啊, so it appears to go on the start of the next line.

I can fix this by adding the character to the defined wide characters in the isWide() function. But I assume there are other nearby characters that should be treated similarly, and I don't know where the range starts and ends. Anyone who does know, feel free to make a PR adding that to term.js.

Closing here since I've identified it as a term.js issue.

@takluyver
Copy link
Member

Reported as chjj/term.js#66

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