mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Fix colors not being preserved when using the pipe command with the pager history buffer
Fixes #1657
This commit is contained in:
@@ -13,6 +13,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
- Fix a missing newline when using the pipe command between the
|
- Fix a missing newline when using the pipe command between the
|
||||||
scrollback and screen contents (:iss:`1642`)
|
scrollback and screen contents (:iss:`1642`)
|
||||||
|
|
||||||
|
- Fix colors not being preserved when using the pipe command with
|
||||||
|
the pager history buffer (:pull:`1657`)
|
||||||
|
|
||||||
- macOS: Fix a regression that could cause rendering of a kitty window
|
- macOS: Fix a regression that could cause rendering of a kitty window
|
||||||
to occasionally freeze in certain situations, such as moving it between
|
to occasionally freeze in certain situations, such as moving it between
|
||||||
monitors or transitioning from/to fullscreen (:iss:`1641`)
|
monitors or transitioning from/to fullscreen (:iss:`1641`)
|
||||||
|
|||||||
@@ -111,8 +111,12 @@ def setup_colors(screen, opts):
|
|||||||
|
|
||||||
|
|
||||||
def text_sanitizer(as_ansi, add_wrap_markers):
|
def text_sanitizer(as_ansi, add_wrap_markers):
|
||||||
import re
|
pat = getattr(text_sanitizer, 'pat', None)
|
||||||
pat = re.compile(r'\033\[.+?m')
|
if pat is None:
|
||||||
|
import re
|
||||||
|
pat = text_sanitizer.pat = re.compile(r'\033\[.+?m')
|
||||||
|
|
||||||
|
ansi, wrap_markers = not as_ansi, not add_wrap_markers
|
||||||
|
|
||||||
def remove_wrap_markers(line):
|
def remove_wrap_markers(line):
|
||||||
return line.replace('\r', '')
|
return line.replace('\r', '')
|
||||||
@@ -123,8 +127,8 @@ def text_sanitizer(as_ansi, add_wrap_markers):
|
|||||||
def remove_both(line):
|
def remove_both(line):
|
||||||
return pat.sub('', line.replace('\r', ''))
|
return pat.sub('', line.replace('\r', ''))
|
||||||
|
|
||||||
if as_ansi:
|
if ansi:
|
||||||
return remove_both if add_wrap_markers else remove_sgr
|
return remove_both if wrap_markers else remove_sgr
|
||||||
return remove_wrap_markers
|
return remove_wrap_markers
|
||||||
|
|
||||||
|
|
||||||
@@ -483,7 +487,7 @@ class Window:
|
|||||||
if add_history:
|
if add_history:
|
||||||
h = []
|
h = []
|
||||||
self.screen.historybuf.pagerhist_as_text(h.append)
|
self.screen.historybuf.pagerhist_as_text(h.append)
|
||||||
if not as_ansi or not add_wrap_markers:
|
if h and (not as_ansi or not add_wrap_markers):
|
||||||
sanitizer = text_sanitizer(as_ansi, add_wrap_markers)
|
sanitizer = text_sanitizer(as_ansi, add_wrap_markers)
|
||||||
h = list(map(sanitizer, h))
|
h = list(map(sanitizer, h))
|
||||||
self.screen.historybuf.as_text(h.append, as_ansi, add_wrap_markers)
|
self.screen.historybuf.as_text(h.append, as_ansi, add_wrap_markers)
|
||||||
|
|||||||
Reference in New Issue
Block a user