fix: clean up whitespace in ANSI utilities and preview script

This commit is contained in:
Benexl
2025-12-01 18:48:15 +03:00
parent 901d1e87c5
commit 26bc84e2eb
2 changed files with 12 additions and 7 deletions

View File

@@ -71,23 +71,25 @@ def print_table_row(
"""
r, g, b = parse_color(header_color)
key_styled = rgb_color(r, g, b, key, bold=True)
# Ensure minimum width to avoid textwrap errors
safe_value_width = max(20, value_width)
# Wrap value if it's too long
value_lines = textwrap.wrap(str(value), width=safe_value_width) if value else [""]
if not value_lines:
value_lines = [""]
# Print first line with right-aligned value
first_line = value_lines[0]
print(f"{key_styled:<{key_width + 20}} {first_line:>{safe_value_width}}")
# Print remaining wrapped lines (left-aligned, indented)
for line in value_lines[1:]:
print(f"{' ' * (key_width + 2)}{line}")
def strip_markdown(text: str) -> str:
"""
Strip markdown formatting from text.

View File

@@ -139,10 +139,13 @@ def _ensure_ansi_utils_in_cache():
"""Copy _ansi_utils.py to the info cache directory so cached scripts can import it."""
source = FZF_SCRIPTS_DIR / "_ansi_utils.py"
dest = INFO_CACHE_DIR / "_ansi_utils.py"
if source.exists() and (not dest.exists() or source.stat().st_mtime > dest.stat().st_mtime):
if source.exists() and (
not dest.exists() or source.stat().st_mtime > dest.stat().st_mtime
):
try:
import shutil
shutil.copy2(source, dest)
logger.debug(f"Copied _ansi_utils.py to {INFO_CACHE_DIR}")
except Exception as e: