diff --git a/src/terminal.go b/src/terminal.go index 6e198ba..494fa46 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -66,7 +66,7 @@ func init() { // * https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it // * https://sw.kovidgoyal.net/kitty/graphics-protocol // * https://en.wikipedia.org/wiki/Sixel - passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\`) + passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\\r?`) } type jumpMode int @@ -1996,6 +1996,7 @@ func (t *Terminal) renderPreviewText(height int, lines []string, lineNo int, unc maxWidth := t.pwindow.Width() var ansi *ansiState spinnerRedraw := t.pwindow.Y() == 0 + wiped := false sixel := false wireframe := false Loop: @@ -2023,7 +2024,7 @@ Loop: t.renderPreviewSpinner() t.pwindow.Move(y, x) } - for _, passThrough := range passThroughs { + for idx, passThrough := range passThroughs { // Handling Sixel output requiredLines := 0 isSixel := strings.HasPrefix(passThrough, "\x1bP") @@ -2050,13 +2051,18 @@ Loop: } // Clear previous wireframe or any other text - if t.previewed.wireframe || isSixel && !t.previewed.sixel { + if (t.previewed.wireframe || isSixel && !t.previewed.sixel) && !wiped { + wiped = true for i := y + 1; i < height; i++ { t.pwindow.MoveAndClear(i, 0) } } sixel = sixel || isSixel - t.pwindow.MoveAndClear(y, x) + if idx == 0 { + t.pwindow.MoveAndClear(y, x) + } else { + t.pwindow.Move(y, x) + } t.tui.PassThrough(passThrough) if requiredLines > 0 { diff --git a/src/tui/light.go b/src/tui/light.go index e5080d1..e9cf04e 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -33,7 +33,6 @@ var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+ func (r *LightRenderer) PassThrough(str string) { r.queued.WriteString("\x1b7" + str + "\x1b8") - r.flush() } func (r *LightRenderer) stderr(str string) {