zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.29k stars 3.1k forks source link

garbage outputted in console? #8497

Open jackTabsCode opened 8 months ago

jackTabsCode commented 8 months ago

Check for existing issues

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

Moshyfawn commented 8 months ago

Looks like an escape sequence representing cursor movement 🤔

jackTabsCode commented 8 months ago

Looks like an escape sequence representing cursor movement 🤔

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

izuzak commented 7 months ago

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
jackTabsCode commented 7 months ago

Here's another repro, running gh repo view:

image
tolluset commented 4 months ago

Same problem occurred. Even not showing git diff.

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

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

izuzak commented 4 months ago

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. 🎉

tolluset commented 4 months ago

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!

jackTabsCode commented 4 months ago

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?

sssilvar commented 4 months ago

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)

silvenon commented 4 months ago

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

bash commented 4 months ago

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 ^^)

ttys3 commented 3 months ago

delta user, and use delta as git diff tool.

I got this too.

]10;rgb:c8c8/cccc/d4d4

11;rgb:3b3b/4141/4d4d
brandonweiss commented 2 months ago

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

mgoodness commented 2 months ago

Fingers crossed for https://github.com/zed-industries/zed/issues/15105#issuecomment-2308404573 to be true.

brandonweiss commented 2 months ago

I also was able to fix it by just updating Lefthook, so it must be some weird combination of two issues?

yodatak commented 2 months ago

for me its fix in v0.151.0-pre

silvenon commented 2 weeks ago

FWIW I no longer seem to be experiencing this issue, I also think the fix might have been two-fold, both a Zed update and a Lefthook update.

jackTabsCode commented 2 weeks ago

I'm still experiencing this issue, but not with Lefthook. I just had it happen the other day, but I can't remember what program it was. I'll report back once I find out