mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
refactor(ansi): do not print when invisible
This commit is contained in:
parent
850787cd6f
commit
c1bf3a16fe
|
@ -89,6 +89,7 @@ type Writer struct {
|
|||
currentBackground Color
|
||||
runes []rune
|
||||
transparent bool
|
||||
invisible bool
|
||||
|
||||
shell string
|
||||
format string
|
||||
|
@ -365,8 +366,11 @@ func (w *Writer) writeSegmentColors() {
|
|||
fg = w.currentForeground
|
||||
}
|
||||
|
||||
// always reset inverted
|
||||
// w.transparent = false
|
||||
// ignore processing fully tranparent colors
|
||||
w.invisible = fg.IsTransparent() && bg.IsTransparent()
|
||||
if w.invisible {
|
||||
return
|
||||
}
|
||||
|
||||
if fg.IsTransparent() && len(w.TerminalBackground) != 0 {
|
||||
background := w.getAnsiFromColorString(w.TerminalBackground, false)
|
||||
|
@ -430,6 +434,12 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
|
|||
}
|
||||
w.currentBackground, w.currentForeground = w.asAnsiColors(match[BG], match[FG])
|
||||
|
||||
// ignore processing fully tranparent colors
|
||||
w.invisible = w.currentForeground.IsTransparent() && w.currentBackground.IsTransparent()
|
||||
if w.invisible {
|
||||
return
|
||||
}
|
||||
|
||||
// make sure we have colors
|
||||
if w.currentForeground.IsEmpty() {
|
||||
w.currentForeground = w.foreground
|
||||
|
|
|
@ -10,7 +10,11 @@ import (
|
|||
)
|
||||
|
||||
func (w *Writer) write(i int, s rune) {
|
||||
// ignore the logic when there is no hyperlink
|
||||
// ignore processing when invisible (<transparent,transparent>)
|
||||
if w.invisible {
|
||||
return
|
||||
}
|
||||
// ignore the logic when there is no hyperlink or things arent't visible
|
||||
if !w.hasHyperlink {
|
||||
w.length += runewidth.RuneWidth(s)
|
||||
w.builder.WriteRune(s)
|
||||
|
|
Loading…
Reference in a new issue