From 1f58eecf3c2de432a45a6ad806daac07cefc5d84 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Mon, 8 Jun 2020 22:15:54 +0200 Subject: [PATCH] Lower priority of cursorline and colorcolumn highlighting (#1697) Fixes #1665 --- internal/display/bufwindow.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index 4bf673a1..9c61140d 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -518,6 +518,13 @@ func (w *BufWindow) displayBuffer() { draw := func(r rune, combc []rune, style tcell.Style, showcursor bool) { if nColsBeforeStart <= 0 { + _, origBg, _ := style.Decompose() + _, defBg, _ := config.DefStyle.Decompose() + + // syntax highlighting with non-default background takes precedence + // over cursor-line and color-column + dontOverrideBackground := origBg != defBg + for _, c := range cursors { if c.HasSelection() && (bloc.GreaterEqual(c.CurSelection[0]) && bloc.LessThan(c.CurSelection[1]) || @@ -530,7 +537,7 @@ func (w *BufWindow) displayBuffer() { } } - if b.Settings["cursorline"].(bool) && w.active && + if b.Settings["cursorline"].(bool) && w.active && !dontOverrideBackground && !c.HasSelection() && c.Y == bloc.Y { if s, ok := config.Colorscheme["cursor-line"]; ok { fg, _, _ := s.Decompose() @@ -562,7 +569,7 @@ func (w *BufWindow) displayBuffer() { } if s, ok := config.Colorscheme["color-column"]; ok { - if colorcolumn != 0 && vloc.X-w.gutterOffset+w.StartCol == colorcolumn { + if colorcolumn != 0 && vloc.X-w.gutterOffset+w.StartCol == colorcolumn && !dontOverrideBackground { fg, _, _ := s.Decompose() style = style.Background(fg) }