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

ansi parser: fix dim / half-bright #563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hellux
Copy link

@hellux hellux commented Apr 2, 2024

\x1b[2m seems to be parsed as DIM | UNDERLINE | BLINK | REVERSE instead of just DIM.

Not sure why the current implementation does this, the message for the commit that added it just mentions implementing multiple parameters, but not specifically why !BOLD was added:

commit d902d65fae1294d7dea5f3dcd90ad31b5b55d1f9
Author: Jinzhou Zhang <lotabout@gmail.com>
Date:   Sat Jul 13 23:41:28 2019 +0800

    fix #194: color not working with ag

    It's because ag uses multiple attributes in SGR parameters.
    e.g. `\e[1;31m` which means set the attribute to BOLD and forground
    color to yellow.

    Previously skim's CSI parsing logic will take only the first parameter.

diff --git a/src/ansi.rs b/src/ansi.rs
index 8495d82..583d19b 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -69,60 +70,88 @@ impl Perform for ANSIParser {
         }
:
                 0 => attr = Attr::default(),
                 1 => attr.effect |= Effect::BOLD,
+                2 => attr.effect |= !Effect::BOLD,
                 4 => attr.effect |= Effect::UNDERLINE,
                 5 => attr.effect |= Effect::BLINK,
:

None of the tests added in this commit use DIM either, they still pass after my change, so I'm assuming this change was accidental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant