tmux-plugins / tmux-copycat

A plugin that enhances tmux search
MIT License
1.1k stars 63 forks source link

Bug when highlighting a match in zsh shell prompt #45

Open bruno- opened 10 years ago

bruno- commented 10 years ago

If a user has sophisticated zsh shell prompt with unicode characters, match selection could be buggy.

Example: zsh shell prompt contains unicode chars and current directory path. File search (prefix + C-f) highlights the directory path invalidly. Presumably, this is because of unicode characters.

qstrahl commented 8 years ago

This is indeed an issue and it affects me. Consider the following text:

11:12 ircuser123 │ check out my super cool link! http://example.com :D
11:13 ircuser123 │ is anybody there?

In principle, <prefix> ctrl-u should highlight http://example.com. Instead, due to the multibyte character earlier in the line, it selects the rather less useful tp://example.com :. The behaviour becomes even more destructive when the URL appears at the end of the line; the selection will include the newline character, plus characters from the next line. Very annoying, especially when used with tmux-open.

qstrahl commented 8 years ago

@bruno- I'd like to take a stab at fixing this... can you point me toward the code responsible for finding the boundaries of the search item?

bruno- commented 8 years ago

Hey, the solution for this seems to be installing gawk as indicated in the readme install section.

gawk has better unicode handling so we made this a drop-in replacement for awk. Once you install it everything should work ok. If you try this please leave feedback, thx.

qstrahl commented 8 years ago

Yup, that seems to take care of it. Thanks!

secondwtq commented 8 years ago

Hi guys, it's still not completely solved, not working well with CJK characters.

朕吞玻璃不伤身体 11:12 ircuser123 │ check out my super cool link! http://example.com :D

Paste this in your tmux and try prefix + <C-u>. Here is what I got:

screen shot 2016-02-20 at 6 10 23 pm
bruno- commented 8 years ago

not working well with CJK characters

I tested your line and I can reproduce the issue. Not sure how to solve it though. Using gawk was the best approach till now.