From ce2f488c89cb8ea143652f0f14d3956f185ae7a9 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Mon, 27 Apr 2026 14:15:20 +0300 Subject: [PATCH] fix: preserve panel background in cursor mode (renderTextCursorContent) Replace full ANSI reset sequences (\x1b[0m) added by lipgloss.Render() for gutter markers, cursor highlights, and selection highlights with background-preserving resets (\x1b[39;22;23;24;59;48;2;R;G;Bm) that restore the panel background color. Without this fix, every \x1b[0m from lipgloss-styled elements in renderTextCursorContent resets the panel background (set by the outer renderPreviewContent wrapper), causing some letters to have incorrect or missing background color in caret mode. --- internal/ui/model.go | 15 ++++++++++++++- vcom.toml | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/ui/model.go b/internal/ui/model.go index d5105c8..16d8611 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -1886,7 +1886,20 @@ func (m *Model) renderTextCursorContent() string { } lines[idx] = marker + line } - return strings.Join(lines, "\n") + result := strings.Join(lines, "\n") + + // Replace full ANSI resets with background-preserving resets. + // lipgloss.Render() appends \x1b[0m which resets the panel background + // set by the outer renderPreviewContent wrapper. Instead, reset only + // foreground and text attributes, then restore the panel background + // so that gutter markers, cursor highlights, and selection highlights + // don't break the panel background for subsequent text on the line. + panelBG := lipgloss.NewStyle().Background(m.palette.Panel).Render("") + bgCode := strings.TrimSuffix(panelBG, "\x1b[0m") + inner := bgCode[2 : len(bgCode)-1] + safeReset := "\x1b[39;22;23;24;59;" + inner + "m" + result = strings.ReplaceAll(result, "\x1b[0m", safeReset) + return result } func (m *Model) moveTextCursorWordForward() { diff --git a/vcom.toml b/vcom.toml index 55ad510..5355b90 100644 --- a/vcom.toml +++ b/vcom.toml @@ -4,7 +4,7 @@ right_path = '' [ui] app_title = 'vcom' -theme = 'catppuccin-mocha' +theme = 'nord-frost' icon_mode = 'auto' show_title_bar = true show_footer = true