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

Terminal background not detected properly in Lefthook #1305

Open
brynary opened this issue Dec 13, 2024 · 2 comments
Open

Terminal background not detected properly in Lefthook #1305

brynary opened this issue Dec 13, 2024 · 2 comments

Comments

@brynary
Copy link
Member

brynary commented Dec 13, 2024

What happened?

When run via Lefthook, Qlty is rendering a black background into a light colored terminal.

Output when running through lefthook

Image

Output when running directly in terminal

Image

Relevant Files

lefthook.yml

pre-commit:
  commands:
    check:
      run: qlty check -a
      stage_fixed: true
    smells:
      run: qlty smells -a
      stage_fixed: true
commit-msg:
  commands:
    lint:
      run: pnpm exec commitlint -e
@brynary brynary changed the title Bug: Syntax highlighting background not detected properly in Lefthook in VS Code Bug: Terminal background not detected properly in Lefthook in VS Code Dec 13, 2024
@brynary
Copy link
Member Author

brynary commented Dec 13, 2024

This seems like it may be due to an interaction Lefthook and VSCode. Qlty tries to figure out if it is on a light terminal or dark terminal using this code:

let background = match termbg::rgb(timeout) {
Ok(rgb) => TermbgToSyntectColorAdapter::adapt_color(rgb),
Err(_) => Color::BLACK,
};
let theme_name = match termbg::theme(timeout) {
Ok(Theme::Light) => "InspiredGitHub",
Ok(Theme::Dark) => "base16-eighties.dark",
Err(_) => "base16-eighties.dark",
};

We are using termbg to do the detection. It looks like termbg has to add support for different kinds of terminals: https://github.com/dalance/termbg?tab=readme-ov-file#verified-terminals

Maybe VSCode is supported by termbg, but Lefthook is behaving differently causing termbg to not be able to detect it.

@brynary
Copy link
Member Author

brynary commented Dec 13, 2024

@lamualfa -- To keep things organized, I split the prior GitHub issue into two items: This bug for the terminal background problem, and a Feature Request for enhancing the qlty smells to return non-zero exit codes when it finds issues.

@brynary brynary changed the title Bug: Terminal background not detected properly in Lefthook in VS Code Terminal background not detected properly in Lefthook in VS Code Dec 13, 2024
@brynary brynary changed the title Terminal background not detected properly in Lefthook in VS Code Terminal background not detected properly in Lefthook Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant