natecraddock / zf

a commandline fuzzy finder and zig package designed for filtering filepaths
MIT License
451 stars 14 forks source link

Cursor position is off when ZF_PROMPT has special characters like ansi escape codes #13

Closed technicalpickles closed 1 year ago

technicalpickles commented 1 year ago

I'm trying to use a character like as the ZF_PROMPT, but it seems like it the cursor is shifted way right of where text is actually inserted:

https://user-images.githubusercontent.com/159/210809294-81ca5d92-b019-4746-9d02-136ac6f2e11f.mov

This is even more pronounced when adding ansi color codes, ie ZF_PROMPT="\e[41m  \e[0m\e[31m\e[0m" :

https://user-images.githubusercontent.com/159/210811146-38b11451-212f-4be9-b29a-d4c80be5a936.mov

natecraddock commented 1 year ago

Hi @technicalpickles, thank you for the thorough bug report! There are two things wrong here

The first is that zf doesn't yet support Unicode. I haven't made that super clear yet though, so that's on me. I do have plans to add utf-8 support soon.

The second is that I don't escape the ANSI escape sequences. That's a bug and I can get that fixed sooner.

natecraddock commented 1 year ago

I have created two issues to track this: https://github.com/natecraddock/zf/issues/15 and https://github.com/natecraddock/zf/issues/16

I won't close this issue until both are completed

natecraddock commented 1 year ago

I have now resolved this in my https://github.com/natecraddock/zf/tree/unicode branch. You are welcome to test now if you would like, or just wait for the 0.7.0 release. I should be adding the remainder of the unicode support soon and releasing the new version.

natecraddock commented 1 year ago

Will be released in zf 0.7.0 soon (hopefully this week)