1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Use the correct style for the trailer

This commit is contained in:
Johan Walles 2023-10-10 06:16:09 +02:00
parent 59a636205a
commit a082fe207e
2 changed files with 7 additions and 1 deletions

View File

@ -427,6 +427,11 @@ func renderLine(row []Cell) (string, int) {
// Trailer is rendered by clearing to EOL, and AttrReverse didn't
// survive that when I tried it using iTerm2 3.4.4 on my MacBook. Don't
// bother with any trailer in this case.
} else if lastCell.Style.hyperlinkUrl != nil {
// This block intentionally left blank.
//
// Trailer is rendered by clearing to EOL, and I don't see how
// hyperlinks could play well with that.
} else if lastCell.Rune == ' ' {
// Line has a number of trailing spaces
for i := len(row) - 1; i >= 0; i-- {
@ -472,7 +477,7 @@ func renderLine(row []Cell) (string, int) {
if trailerLength > 0 {
// Set trailer attributes
trailerStyle := lastStyle.WithHyperlink(nil)
trailerStyle := lastCell.Style.WithHyperlink(nil)
builder.WriteString(trailerStyle.RenderUpdateFrom(lastStyle))
lastStyle = trailerStyle
} else {

View File

@ -92,6 +92,7 @@ func (style Style) WithAttr(attr AttrMask) Style {
// Call with nil to remove the link
func (style Style) WithHyperlink(hyperlinkUrl *string) Style {
if hyperlinkUrl != nil && *hyperlinkUrl == "" {
// Use nil instead of empty string
hyperlinkUrl = nil
}