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

garbage outputted in console? #8497

Closed
1 task done
jackTabsCode opened this issue Feb 27, 2024 · 20 comments
Closed
1 task done

garbage outputted in console? #8497

jackTabsCode opened this issue Feb 27, 2024 · 20 comments
Labels
bug [core label] terminal Feedback for terminal integration, shell commands, etc

Comments

@jackTabsCode
Copy link
Contributor

Check for existing issues

  • 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 jackTabsCode added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Feb 27, 2024
@Moshyfawn Moshyfawn added terminal Feedback for terminal integration, shell commands, etc and removed triage Maintainer needs to classify the issue labels Feb 28, 2024
@Moshyfawn
Copy link
Member

Looks like an escape sequence representing cursor movement 🤔

@jackTabsCode jackTabsCode changed the title Leftover colors outputted in console? garbage outputted in console? Feb 28, 2024
@jackTabsCode
Copy link
Contributor Author

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
Copy link
Contributor

izuzak commented Apr 9, 2024

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
Copy link
Contributor Author

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

@tolluset
Copy link

Same problem occurred. Even not showing git diff.

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

@SomeoneToIgnore
Copy link
Contributor

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

@izuzak
Copy link
Contributor

izuzak commented Jun 24, 2024

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
Copy link

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
Copy link
Contributor Author

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
Copy link

sssilvar commented Jul 4, 2024

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
Copy link

silvenon commented Jul 4, 2024

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

@bash
Copy link
Contributor

bash commented Jul 13, 2024

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
Copy link

ttys3 commented Jul 23, 2024

delta user, and use delta as git diff tool.

I got this too.

]10;rgb:c8c8/cccc/d4d4

11;rgb:3b3b/4141/4d4d

mrnugget pushed a commit that referenced this issue Aug 22, 2024
Partially addresses #8497 (namely, the occurring with `delta`)

As I mentioned in
#8497 (comment),
zed currently replies to OSC color requests (`OSC 10`, `OSC 11`, ...)
out of order when immediately followed by another request (for example
`CSI c`). All other terminals that [I have
tested](https://github.com/bash/terminal-colorsaurus/blob/main/doc/terminal-survey.md)
maintain relative order when replying to requests.

## Solution
Respond to the `ColorRequest` in `process_event` (in the same place
where other PTY writes happen) instead of queuing it up in the internal
event queue.

## Alternative
I initially thought that I could handle the color request similarly to
the `TextAreaSizeRequest` where the size is stored in `last_content` and
updated on `sync`. However this causes the terminal to report
out-of-date values when a "set color" sequence is followed by a color
request.

## Tests

1. `OSC 11; ?` (request bg color) + `CSI c` (request device attributes):
   ```shell
   printf '\e]11;?\e\\ \e[c' && cat -v
   # Expected result: ^[]11;rgb:dcdc/dcdc/dddd^[\^[[?6c
# Current result: ^[[?6c^[]11;rgb:dcdc/dcdc/dddd^[\ (❌)
# Result with this PR: ^[]11;rgb:dcdc/dcdc/dddd^[\^[[?6c (✅)
# Result with alternative: ^[]11;rgb:dcdc/dcdc/dddd^[\^[[?6c (✅)
   ```
2. `OSC 11; rgb:f0f0/f0f0/f0f0` (set bg color) + `OSC 11; ?` (request bg
color)
   ```shell
   printf '\e]11;rgb:f0f0/f0f0/f0f0\e\\ \e]11;?\e\\' && cat -v
   # Expected result: ^[]11;rgb:f0f0/f0f0/f0f0^[\
# Current result: ^[]11;rgb:f0f0/f0f0/f0f0^[\ (✅)
# Result with this PR: ^[]11;rgb:f0f0/f0f0/f0f0^[\ (✅)
# Result with alternative: ^[]11;rgb:OUT_OF_DATE_COLOR_HERE^[\ (❌)
   ```

Release Notes:

- N/A
@brandonweiss
Copy link

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

@mgoodness
Copy link

Fingers crossed for #15105 (comment) to be true.

@brandonweiss
Copy link

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

@yodatak
Copy link
Contributor

yodatak commented Aug 29, 2024

for me its fix in v0.151.0-pre

@silvenon
Copy link

silvenon commented Oct 29, 2024

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
Copy link
Contributor Author

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

@notpeter
Copy link
Member

notpeter commented Jan 2, 2025

I am no longer able to reproduce this issue.

If you are seeing this with a current version of Zed please reply with your zed version and steps to reproduce and I'm happy to reopen.

Thanks all!

@notpeter notpeter closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] terminal Feedback for terminal integration, shell commands, etc
Projects
None yet
Development

No branches or pull requests