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

Issues with long lines #14

Open
jsteemann opened this issue Nov 9, 2021 · 1 comment
Open

Issues with long lines #14

jsteemann opened this issue Nov 9, 2021 · 1 comment
Assignees

Comments

@jsteemann
Copy link

jsteemann commented Nov 9, 2021

Just compiled bestline_example and tried its Unicode-handling, because I looking for a replacement of a hacked version of linenoise with partial Unicode support.

The following was run in a terminal of size 80x24 in a gnome terminal window on Ubuntu 21.10.

$ echo $TERM
xterm-256color

The initial prompt is hello> , which is fine.
Pasting the string 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ። into bestline also works fine.
Now when pasting the same string 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ። again, the line would be longer than 80 characters, so bestline wraps the line (correctly).
However, on its way to there bestline prints the complete input line once again for each overflow character.

Example ("x" denotes cursor position):
Initial:

hello> x

After pasting the string once:

hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።x

After pasting the string twice:

hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
ይከሰስ።x

This should instead be just

hello> 💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አይከሰስ።💩🍺🌧 ⛈ 🌩 ⚡🔥💥🌨 "ሰማይ አይታረስ ንጉሥ አ
ይከሰስ።x

As a follow-up, I was trying to go down in history (pressing the down arrow key), which brings up the last used line.
It provides the correct line, but pressing it several times moves everything else up even one line. This shouldn't be the case because when there is room to display the last full history entry, nothing should be moved around.

Thanks for the amazing work on bestline! IMO a modern linenoise successor is much needed!

@jart jart self-assigned this Nov 10, 2021
@jart
Copy link
Owner

jart commented Nov 10, 2021

Thanks for the detailed report. Still working to fully debug the software to get it ready for release and help like this is invaluable. I intend to dive into this sometime in the next two weeks. If you spot any other blockers then please file issues. Feature requests are welcome too.

jsteemann added a commit to jsteemann/bestline that referenced this issue Feb 25, 2023
fixes several issues in bestline:
* maskmode didn't really work with characters that would need more than
  1 display unit (width > 1).
* the display width of several characters wasn't correct before,
  especially for some emojis. fix this by replacing the code in
  GetMonospaceCharacterWidth with a call to `wcwidth`, which seems to be
  more accurate (but complex) for determining display widths.
* when the cursor was positioned at the last column in a row, and then a
  character was entered, the cursor advanced correctly to the beginning
  of the next line, but the just-entered character wasn't displayed.
  only when another character was entered, the previous character would
  be displayed just fine.

- fixes issue jart#14
- adds external `wcwidth` function maintained at
  https://raw.githubusercontent.com/termux/wcwidth/master/wcwidth.c
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