zed icon indicating copy to clipboard operation
zed copied to clipboard

garbage outputted in console?

Open jackTabsCode opened this issue 1 year ago • 12 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

I'm having an issue with some commands where, what I believe to be are color codes are being spat into the output. This issue is not occurring with the built in Terminal.

I'm not 100% sure if this is due to Zed so I think this might need some further investigation, but I'm assuming it might be because of it being a non issue with other terminals?

Environment

Zed: v0.124.6 (Zed Preview) OS: macOS 14.3.1 Memory: 32 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

image

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

jackTabsCode avatar Feb 27 '24 16:02 jackTabsCode

Looks like an escape sequence representing cursor movement 🤔

Moshyfawn avatar Feb 28 '24 03:02 Moshyfawn

Looks like an escape sequence representing cursor movement 🤔

Interesting. I don't know much about this kind of stuff. I edited the issue title.

jackTabsCode avatar Feb 28 '24 03:02 jackTabsCode

I'm seeing the same and was about to open a new issue when I found this one.

To reproduce:

  1. Start Zed and open the terminal with an empty settings.json file
  2. Run git log -n 5 --pretty=format:'%C(red)%h' --date=short
  3. Notice the strange sequence of characters near the start of the output (:c8c8/cccc/d4d4^G^[]11;rgb:3b3b/4141/4d4d^G) and after the command runs (10;rgb:c8c8/cccc/d4d411;rgb:3b3b/4141/4d4d). They look like some form of color information or escape sequences.

Observed:

Screenshot 2024-04-09 at 08 08 08@2x

Expected (and what Alacritty shows):

Screenshot 2024-04-09 at 08 07 40@2x

Zed info:

Zed: v0.130.2 (Zed Preview)
OS: macOS 14.4.1
Memory: 64 GiB
Architecture: aarch64

izuzak avatar Apr 09 '24 06:04 izuzak

Here's another repro, running gh repo view: image

jackTabsCode avatar Apr 09 '24 07:04 jackTabsCode

Same problem occurred. Even not showing git diff.

❯ git diff
❯ 10;rgb:c8c8/cccc/d4d4
❯ 11;rgb:3b3b/4141/4d4d

tolluset avatar Jun 24 '24 03:06 tolluset

For anyone having these symptoms and having delta installed for git diff browsing, https://github.com/zed-industries/zed/issues/13418#issuecomment-2185000070 might help. Relevant delta issue: https://github.com/dandavison/delta/issues/1707

SomeoneToIgnore avatar Jun 24 '24 08:06 SomeoneToIgnore

For anyone having these symptoms and having delta installed for git diff browsing, #13418 (comment) might help. Relevant delta issue: dandavison/delta#1707

This didn't help me, unfortunately, but completely removing delta from my .gitconfig did help. 🤷 So, definitely seems like a problem related to using delta. 👍 Thanks for pointing to this out, @SomeoneToIgnore ⚡

EDIT: ohh, actually what helped was adding --dark and removing export GIT_PAGER=delta from my .bashrc. 🎉

izuzak avatar Jun 24 '24 08:06 izuzak

For anyone having these symptoms and having delta installed for git diff browsing, #13418 (comment) might help. Relevant delta issue: dandavison/delta#1707

Thanks! It works for me!

tolluset avatar Jun 25 '24 11:06 tolluset

Do these fixes suggested only apply to git diff?

I'm confused on why this is happening. I don't know a lot about terminal emulators. How is it possible that something can put text in the input field? And why would it be a color code?

jackTabsCode avatar Jun 25 '24 16:06 jackTabsCode

Do these fixes suggested only apply to git diff?

I'm confused on why this is happening. I don't know a lot about terminal emulators. How is it possible that something can put text in the input field? And why would it be a color code?

No, seems to be happenin with other CLI tools (e.g., #9742)

sssilvar avatar Jul 04 '24 07:07 sssilvar

For me this happens with lefthook. Especially annoying on its pre-commit hook because I have nvim as my git editor.

silvenon avatar Jul 04 '24 10:07 silvenon

Hi, author of terminal-colorsaurus (the library that delta uses for color detection) here 👋🏼

The 10;rgb:c8c8/cccc/d4d4 11;rgb:3b3b/4141/4d4d output is caused by delta trying to detect the terminal's foreground and background color. To do this it uses terminal-colorsaurus.

The output appears because terminal-colorsaurus thinks that zed doesn't support these sequences. It uses a neat trick to detect support. This trick relies on the fact that terminals usually answer to different queries in the order that they arrived.

Zed however replies to color queries out of order.

For example when sending OSC 11 ; ? ST (bg color query) followed by CSI c (request device attributes) the response to CSI c arrives first:

$ printf '\e]11;?\e\\ \e[c' && cat -v
 ^[[?6c^[]11;rgb:dcdc/dcdc/dddd^[\^C

(edit: my printf was incorrect, but my conclusion was nevertheless correct ^^)

bash avatar Jul 13 '24 13:07 bash

delta user, and use delta as git diff tool.

I got this too.

]10;rgb:c8c8/cccc/d4d4

11;rgb:3b3b/4141/4d4d

ttys3 avatar Jul 23 '24 10:07 ttys3

This is also happening for me on repos that use lefthook.

brandonweiss avatar Aug 22 '24 17:08 brandonweiss