Skip to content

Commit

Permalink
Fix printing tags if it contains color (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelim-work authored Jul 30, 2024
1 parent 534710d commit c2224cb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
maxWidth -= 1
}

tag := ' '
tag := " "
if val, ok := context.tags[path]; ok && len(val) > 0 {
tag = rune(val[0])
tag = val
}

var icon []rune
Expand Down Expand Up @@ -493,14 +493,16 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
case Preview:
cursorFmt = optionToFmtstr(gOpts.cursorpreviewfmt)
}
line := append([]rune{tag}, icon...)
line = append(line, filename...)
line = append(line, ' ')
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorFmt, string(line)))

// print tag separately as it can contain color escape sequences
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorFmt, tag))

line := append(icon, filename...)
line = append(line, ' ')
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
} else {
if tag != ' ' {
tagStr := fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), string(tag))
if tag != " " {
tagStr := fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)
win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, tagStr)
}

Expand Down

0 comments on commit c2224cb

Please sign in to comment.