yurikhan / kitty_grab

Keyboard-driven screen grabber for Kitty
GNU General Public License v3.0
171 stars 11 forks source link

Bugged selection using zsh with Powerlevel10k #26

Closed Sonico98 closed 1 year ago

Sonico98 commented 1 year ago

https://user-images.githubusercontent.com/61394886/210804264-50effadc-217b-48ce-812b-0e4347393c18.mp4

The selection doesn't really match what's shown on screen wherever special characters are present. Using the default zsh configuration (no themes) works flawlessly.

yurikhan commented 1 year ago

It would be much easier to debug if you were able to reduce the problem to a minimum reproducing example.

As it is, I’m inclined to blame the issue on excessive ricing :stuck_out_tongue:

ljcolling commented 1 year ago

I have this issue too, but without Powerlevel10k.

Sonico98 commented 1 year ago

I have this issue too, but without Powerlevel10k.

What's your setup? I've tried creating a minimum reproducing example but P10k's code is so inmensely huge I couldn't figure anything out

ljcolling commented 1 year ago

zsh, and starship prompt, and nothing else

Townk commented 1 year ago

You just need to have color scape codes in the terminal that the selection gets all bogus. I can reproduce this with a simple ls --color=always.

The case of the video, is not even P10K that is causing that, is most likely the syntax highlight plugin that add the color escape codes to the command line, and P10K is happy to use it as it is.

yurikhan commented 1 year ago

Nope, ls --color=always does not do that for me. ls --hyperlink=always does though. I will add something to filter out OSC sequences in the near but not immediate future. (Note to self: the function to modify is unstyled, and please do something about tab characters, too.)

Anyway, you guys who have the issue should tell me which escape sequences you use. If you can reproduce it with a shell command, pipe that command through xxd -g1 or od -t x1 or even just cat -A, and post the output as a code block or a file attachment.

Townk commented 1 year ago

You are correct. I did not realize I had that on my alias. Also, I noticed that any Kitty shell integration escape character causes problem. I wouldn't be surprised to know that all OSC sequences need to be filtered.

yurikhan commented 1 year ago

@Sonico98 @ljcolling @Townk Please try with current master. If something is still off with your shell prompts, post your output of echo $PS1 | cat -A.

Townk commented 1 year ago

The last change resolved the issue for me. I tested with different utilities and, with the shell integration turned on, on Kitty.

I can consider this issue resolved.

Sonico98 commented 1 year ago

Sorry for the late reply, I can confirm there are no problems now as well. Also sorry for the lack of help in debugging this, as I didn't really know where to go. Thanks a lot!