Don't highlight padding spaces in word wrapping
Don't highlight space characters at the right edge which are used just
for padding after line break in word wrapping, i.e. don't correspond to
any real characters in the buffer.
This makes it look nicer e.g. when selecting word-wrapped text.
@@ -477,8 +477,9 @@ func (w *BufWindow) displayBuffer() {
}
bloc.X = bslice
- draw := func(r rune, combc []rune, style tcell.Style, showcursor bool) {
+ draw := func(r rune, combc []rune, style tcell.Style, highlight bool, showcursor bool) {
if nColsBeforeStart <= 0 && vloc.Y >= 0 {
+ if highlight {
_, origBg, _ := style.Decompose()
_, defBg, _ := config.DefStyle.Decompose()
@@ -541,6 +542,7 @@ func (w *BufWindow) displayBuffer() {
style = style.Underline(true)
}
}
+ }
screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, r, combc, style)
@@ -622,7 +624,7 @@ func (w *BufWindow) displayBuffer() {
// If a word (or just a wide rune) does not fit in the window
if vloc.X+wordwidth > maxWidth && vloc.X > w.gutterOffset {
for vloc.X < maxWidth {
- draw(' ', nil, config.DefStyle, false)
+ draw(' ', nil, config.DefStyle, false, false)
}
// We either stop or we wrap to draw the word in the next line
@@ -638,7 +640,7 @@ func (w *BufWindow) displayBuffer() {
}
for _, r := range word {
- draw(r.r, r.combc, r.style, true)
+ draw(r.r, r.combc, r.style, true, true)
// Draw any extra characters either spaces for tabs or @ for incomplete wide runes
if r.width > 1 {
@@ -648,7 +650,7 @@ func (w *BufWindow) displayBuffer() {
}
for i := 1; i < r.width; i++ {
- draw(char, nil, r.style, false)
+ draw(char, nil, r.style, true, false)
}
}
bloc.X++
@@ -694,7 +696,7 @@ func (w *BufWindow) displayBuffer() {
if vloc.X != maxWidth {
// Display newline within a selection
- draw(' ', nil, config.DefStyle, true)
+ draw(' ', nil, config.DefStyle, true, true)
}
bloc.X = w.StartCol
