You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//zero-width space => 1console.log("".length);//empty string => 0console.log("".length);
Any command with a zero-width space causes future rendering issues when displaying the command from history:
#run zero-width space code with node => 1
node -p 'console.log("".length);'#echo zero-width spaceecho""
Pasting this into bash will display the zero-width space as a normal space. However, pasting this into fish causes rendering issues whenever a command from history has a zero-width space (you don't actually have to run node to see the issue).
It was happening on fish 2.2/2.3. I updated to 2.7.0 and it's still occurring. Also tried without third-party extensions and still occurs.
jp $ fish --version
fish, version 2.7.0
jp $ uname -a
Darwin jp 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
jp $ echo $TERM
xterm-256color
Fish uses a function called wcwidth to figure out how many cells a character uses. It ships its own version, and that returns "0" for a zero-width space, which seems correct.
It's possible your terminal uses a different definition that returns something else, and so fish and the terminal get out of sync.
Can you try #4554 (which would use the os-provided version which the terminal probably uses, so both would be wrong in the same way)? Can you try a different terminal (which might use a different wcwidth)?
"Can you try #4554" so you mean compile that C program and run it?
The program I posted there would help, yes. It's also a PR that adds a commit to fish, so you could also try compiling and running that, but I don't think there should be a difference.
works in bash
And that's not all that surprising. The reason this causes problems in fish is that fish needs to do a bunch of cursor movement for suggestions and highlighting and such, and that needs to count the columns correctly, in the same way that the terminal does.
However, looking at that screenshot, it seems like Terminal.app is wrong here. I'm assuming the argument to echo is just a zero-width space in quotes. It's displayed as one column of whitespace (i.e. the same as a normal space), which is wrong. So obviously that'll cause a difference between fish's column count and the terminal's.
So the best we can expect here is that the terminal is using the system's wcwidth, and that switching to that will make fish and the terminal wrong in the same way, which should make for a better experience.
So, as you can see here, your system's version (which iTerm is probably using) is wrong in a few places. It's assigned a width of 1 to the zero-width space, and the high voltage sign has a width of -1. (The arabic one - the bismillah - as well, but everybody gets that one wrong)
What I'd assume is that this is one of those cases where it's better for fish to be wrong in the same way as the terminal. Can you try building the fish from #4554?
Note that the rendering is wrong regardless - you'll see how all of the other characters overlap the closing quote. There's nothing we can do to fix that.
@ridiculousfish: This is what I was talking about in #4554. We get the zero-width space right and we're still worse off than bash.
Activity
faho commentedon Dec 2, 2017
Fish uses a function called
wcwidthto figure out how many cells a character uses. It ships its own version, and that returns "0" for a zero-width space, which seems correct.It's possible your terminal uses a different definition that returns something else, and so fish and the terminal get out of sync.
Can you try #4554 (which would use the os-provided version which the terminal probably uses, so both would be wrong in the same way)? Can you try a different terminal (which might use a different wcwidth)?
jpillora commentedon Dec 8, 2017
"Can you try #4554" so you mean compile that C program and run it?
iTerm2 is my main terminal and I just tested with macOS's Terminal.app, happens there too when I paste
echo ""into fish. Whereas works inbash:faho commentedon Dec 8, 2017
The program I posted there would help, yes. It's also a PR that adds a commit to fish, so you could also try compiling and running that, but I don't think there should be a difference.
And that's not all that surprising. The reason this causes problems in fish is that fish needs to do a bunch of cursor movement for suggestions and highlighting and such, and that needs to count the columns correctly, in the same way that the terminal does.
However, looking at that screenshot, it seems like Terminal.app is wrong here. I'm assuming the argument to echo is just a zero-width space in quotes. It's displayed as one column of whitespace (i.e. the same as a normal space), which is wrong. So obviously that'll cause a difference between fish's column count and the terminal's.
So the best we can expect here is that the terminal is using the system's wcwidth, and that switching to that will make fish and the terminal wrong in the same way, which should make for a better experience.
If you do, can you add
L'\u200B'tochars[]?jpillora commentedon Dec 26, 2017
Sorry for the delay:
It displays here as zero-width, but when rendered in iTerm2, it looks like:
Note: I added single-quotes the cpp program.
faho commentedon Dec 26, 2017
So, as you can see here, your system's version (which iTerm is probably using) is wrong in a few places. It's assigned a width of 1 to the zero-width space, and the high voltage sign has a width of -1. (The arabic one - the bismillah - as well, but everybody gets that one wrong)
What I'd assume is that this is one of those cases where it's better for fish to be wrong in the same way as the terminal. Can you try building the fish from #4554?
Note that the rendering is wrong regardless - you'll see how all of the other characters overlap the closing quote. There's nothing we can do to fix that.
@ridiculousfish: This is what I was talking about in #4554. We get the zero-width space right and we're still worse off than bash.
faho commentedon Jan 4, 2018
Let's track this in #4539.
ridiculousfish commentedon Feb 26, 2018
With 5282d3e this character U+200B should have its width "correctly" reported as 1. Please comment if you don't see this fixed - thanks!
Make wcwidth configurable
Make wcwidth configurable (#4816)
Make wcwidth configurable (fish-shell#4816)