feat: Add ANSI escape sequence stripping for Atuin version detection

This commit is contained in:
Paul Gauthier (aider) 2025-03-12 13:25:03 -07:00
parent a2e4022e31
commit f4880e2ef3

View file

@ -7,6 +7,13 @@ import sys
# Speed up factor for the recording
SPEEDUP = 1.25
# Regular expression to match ANSI escape sequences
ANSI_ESCAPE_PATTERN = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\([0-9A-Z=])')
def strip_ansi(text):
"""Remove ANSI escape sequences from text"""
return ANSI_ESCAPE_PATTERN.sub('', text)
def process_file(input_path, output_path):
"""
@ -53,9 +60,10 @@ def process_file(input_path, output_path):
# If we're not in skip mode, check if we need to enter it
if not skip_mode:
if "\u001b[" in text and "Atuin" in text:
# First check for cursor positioning command
if "\u001b[" in text:
match = ansi_pattern.search(text)
if match:
if match and "Atuin" in strip_ansi(text):
row = match.group(1)
col = int(match.group(2))
# Create pattern for the ending sequence