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

kitty hints highlight the wrong character in RTL text #6927

Closed
munzirtaha opened this issue Dec 18, 2023 · 6 comments
Closed

kitty hints highlight the wrong character in RTL text #6927

munzirtaha opened this issue Dec 18, 2023 · 6 comments
Labels

Comments

@munzirtaha
Copy link

munzirtaha commented Dec 18, 2023

Describe the bug
The highlighted character for the hint numbering is not correct in case of RTL text.

To Reproduce
Steps to reproduce the behavior:

  1. mkdir 'اللغة العربية'
  2. kitty_mod+p>y
  3. See the number added is in a different place than the highlighted character
@munzirtaha munzirtaha added the bug label Dec 18, 2023
@kovidgoyal
Copy link
Owner

This is not something I have the time/interest to fix, but patches are
most welcome. Relevant code is in the hints/marks.go file.

@munzirtaha
Copy link
Author

I guess this should be a trivial fix. Instead of highlighting the first character of the RTL word, just highlight the last character, theoretically, this should fix it. Does this make sense to you?

@kovidgoyal
Copy link
Owner

Sure, in principle, there might be some edge cases to handle though. For
instance for words that contain a mix of characters, punctuation, etc.

@munzirtaha
Copy link
Author

Even if some edge cases show, it's not important, but I couldn't understand why mix of characters or punctuation would even be an exception. By "word", I meant any characters before the space, so e.g.

>>> a="عربي!!"
>>> a[len(a)-1]
'!'

That's fine because now the "!" would be highlighted which is the last character of the Arabic word and it would be the first character in the column aligned with currently rendered highlight. Of course, I am speaking about a "word" not a "string", so in "Hello, World!", the "," should be highlighted and not the "!"

@kovidgoyal
Copy link
Owner

The hints kitten can match many things apart from words. You need to
check what a particular match is an decide whether to treat it as RTL or
LTR based on the codepoints in the match. There is no straightforward way
to make that decision, in general, for mixed text. FOr example if you
are matching a path and one of the path components is LTR and another is
RTL, so you put the hint at the start or the end?

@munzirtaha
Copy link
Author

munzirtaha commented Dec 19, 2023

The hints kitten can match many things apart from words

When I said "word" I meant any series of characters before a space, whether it's a file path or text in a file or whatever. I am completely new to kitty and didn't even know there is kitty hint to select words which I guess what you meant. Actually, my bug report's how to produce showed only the file path selection, but, fortunately, I still believe in all these cases, selecting the last character of the first component/word should be enough until there is proper RTL support later.

FOr example if you are matching a path and one of the path components is LTR and another is RTL, so you put the hint at the start or the end?

Only if the first component is Arabic, you put the hint at the end of the first word

If this is easy for you to modify, I would be willing to test and report back, and at least I would understand which functions needs modifications and try different scenarios. Otherwise, I would would put it on my TOOD list, though I don't know a thing about Go. Thanks for your hints ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants