Fix bold/dim handling when wrapping

This commit is contained in:
Kovid Goyal 2023-03-23 11:13:28 +05:30
parent 4bc9cf84a3
commit 4c9efb6ff2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 0 deletions

View File

@ -167,8 +167,12 @@ func (self *sgr_state) apply_csi(raw string) {
self.reset() self.reset()
case 1: case 1:
self.dim, self.bold = false, true self.dim, self.bold = false, true
case 221:
self.bold = false
case 2: case 2:
self.dim, self.bold = true, false self.dim, self.bold = true, false
case 222:
self.dim = false
case 22: case 22:
self.dim, self.bold = false, false self.dim, self.bold = false, false
case 3: case 3:

View File

@ -37,4 +37,10 @@ func TestFormatWithIndent(t *testing.T) {
tx("four", "fou\nr") tx("four", "fou\nr")
tx("nl\n\n", "nl\n\n") tx("nl\n\n", "nl\n\n")
tx("four\n\n", "fou\nr\n\n") tx("four\n\n", "fou\nr\n\n")
screen_width = 8
tx(
"\x1b[1mbold\x1b[221m no more bold",
"\x1b[1mbold\x1b[221m no\nmore\nbold",
)
} }