Skip to content

Commit 4ea2eb2

Browse files
committed
Add a new colorscheme group for selections in hlsearch
micro allows setting colors for selections and for search results. If a colorscheme defines a selection color that is very similar to the hlsearch highlight color, the currently selected text will hardly stand out during a highlighted search. So add a new color-group analogous to `statusline`, `statusline.inactive`, `statusline.suggestions`.
1 parent c9ba51d commit 4ea2eb2

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎internal/display/bufwindow.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ func (w *BufWindow) displayBuffer() {
622622
}
623623

624624
if highlight {
625-
if w.Buf.HighlightSearch && w.Buf.SearchMatch(bloc) {
625+
highlightSearchMatch := w.Buf.HighlightSearch && w.Buf.SearchMatch(bloc)
626+
if highlightSearchMatch {
626627
style = config.DefStyle.Reverse(true)
627628
if s, ok := config.Colorscheme["hlsearch"]; ok {
628629
style = s
@@ -648,6 +649,12 @@ func (w *BufWindow) displayBuffer() {
648649
if s, ok := config.Colorscheme["selection"]; ok {
649650
style = s
650651
}
652+
653+
if highlightSearchMatch {
654+
if s, ok := config.Colorscheme["hlsearch.selection"]; ok {
655+
style = s
656+
}
657+
}
651658
}
652659

653660
if b.Settings["cursorline"].(bool) && w.active && !preservebg &&

‎runtime/help/colors.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ Here is a list of the colorscheme groups that you can use:
203203
* error-message (Color of error messages in the bottom line of the screen)
204204
* match-brace (Color of matching brackets when `matchbracestyle` is set to `highlight`)
205205
* hlsearch (Color of highlighted search results when `hlsearch` is enabled)
206+
* hlsearch.selection (Color of the selection within highlighted search
207+
results when `hlsearch` is enabled)
206208
* tab-error (Color of tab vs space errors when `hltaberrors` is enabled)
207209
* trailingws (Color of trailing whitespaces when `hltrailingws` is enabled)
208210

0 commit comments

Comments
 (0)