From 50142ec4a8ee793f5bd7f4f5c9b499906c7da758 Mon Sep 17 00:00:00 2001 From: serrebidev Date: Sat, 11 Jul 2026 18:17:11 -0700 Subject: [PATCH] Strip decorative padding and borders from terminal review text Terminal cells are space-padded to the column width and TUI apps reserve whole rows/columns for borders and status chrome. Captured as a UNIT_STORY, a Windows Terminal review fills with blank padding and box-drawing-only lines that bury the real content when navigated line by line. Add _cleanTerminalText(): strip per-line trailing whitespace and drop lines whose only non-whitespace characters are Unicode box-drawing glyphs (U+2500-U+257F). Content lines that merely contain a border character are kept. Applied to both TermControl captures in obtainUWPWindowText(). Co-Authored-By: Claude Opus 4.8 --- addon/globalPlugins/virtualRevision.py | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/addon/globalPlugins/virtualRevision.py b/addon/globalPlugins/virtualRevision.py index c4ab909..20dedc5 100644 --- a/addon/globalPlugins/virtualRevision.py +++ b/addon/globalPlugins/virtualRevision.py @@ -18,6 +18,30 @@ except: SCRCAT_TEXTREVIEW = None +def _isDecorativeTerminalLine(line): + # True for lines whose only non-whitespace characters are in the Unicode Box Drawing + # block (U+2500-U+257F): the borders, separators, and corners that TUI apps paint. + # Content lines that happen to contain a "│" border still survive because the + # letters/digits inside fall outside the range. + stripped = line.strip() + if not stripped: + return True + return all("─" <= ch <= "╿" for ch in stripped) + +def _cleanTerminalText(text): + # Terminal cells are space-padded to the column width, and TUI apps reserve fixed + # rows/columns for borders, status bars, input, etc. Captured as a UNIT_STORY this + # turns into long runs of blank padding and box-border-only lines that bury the actual + # content when the review window is navigated line by line. Strip per-line trailing + # whitespace and drop lines that carry no real content. + lines = [] + for line in text.split("\n"): + stripped = line.rstrip() + if _isDecorativeTerminalLine(stripped): + continue + lines.append(stripped) + return "\n".join(lines) + def obtainUWPWindowText(): foreground = api.getForegroundObject() desktop = api.getDesktopObject() @@ -28,7 +52,7 @@ def obtainUWPWindowText(): if hasattr(curObject, "UIAElement") and curObject.UIAElement and curObject.UIAElement.currentClassName == "TermControl": info = curObject.makeTextInfo(textInfos.POSITION_FIRST) info.expand(textInfos.UNIT_STORY) - text = info.clipboardText.rstrip() + text = _cleanTerminalText(info.clipboardText) uwpTextList.append(text) if curObject.simpleFirstChild: curObject=curObject.simpleFirstChild @@ -52,7 +76,7 @@ def obtainUWPWindowText(): if hasattr(foreground, "UIAElement") and foreground.UIAElement and foreground.UIAElement.currentClassName == "TermControl": info = foreground.makeTextInfo(textInfos.POSITION_FIRST) info.expand(textInfos.UNIT_STORY) - text = info.clipboardText.rstrip() + text = _cleanTerminalText(info.clipboardText) uwpTextList.append(text) return uwpTextList