Open
Conversation
Fixed a bug where multi-line output would fail to clear properly on standard terminals (macOS Terminal, iTerm2, gnome-terminal, konsole, xterm), causing previous output to stack and "bleed" upward, overwriting earlier terminal content. This only occurred when output exceeded terminal width and soft-wrapped across multiple physical lines. Root Cause: The clearing logic used ANSI escape sequence \x1b[1000D (move left 1000 columns) before clearing each line. However, when content soft-wraps across multiple physical lines without explicit newlines, most VT100-compatible terminals treat this as a single logical line. The MOVE_UP command (\x1b[1A) then operates on logical lines rather than physical wrapped lines, causing the cursor to target wrong screen positions during clearing. Solution: Replaced \x1b[1000D (move left 1000 columns) with \r (carriage return) in the line clearing sequence. Carriage return is a standard ASCII control character that reliably moves the cursor to column 0 of the current physical line across all terminal emulators, regardless of soft-wrap behavior. Also fixed log.clear() to output a newline instead of an empty string, ensuring the cursor properly moves to a new line after clearing, preventing the bash prompt from appearing on the same line as cleared content. Changes: - Line 27: Replace MOVE_LEFT with \r for universal column 0 positioning - Line 43: Change log.clear() to output \n for proper cursor positioning Fixes issues with soft-wrapped line clearing on all standard POSIX terminals.
luismulinari
added a commit
to Automattic/vip-cli
that referenced
this pull request
Dec 8, 2025
The @wwa/single-line-log package is unmaintained and contains a bug that causes line clearing to fail when output wraps across multiple physical terminal lines, resulting in stacked output. This change vendors the fixed version locally with the fix from freeall/single-line-log#21, which uses '\r' instead of '\x1b[1000D' for cursor positioning to ensure consistent behavior across all terminal emulators. Changes: - Remove @wwa/single-line-log dependency - Add src/lib/cli/single-log-line.ts with MIT license preserved - Update all imports to use local implementation - Add string-width@8.1.0 as direct dependency Related PR: - freeall/single-line-log#21
7 tasks
luismulinari
added a commit
to Automattic/vip-cli
that referenced
this pull request
Dec 8, 2025
The @wwa/single-line-log package is unmaintained and contains a bug that causes line clearing to fail when output wraps across multiple physical terminal lines, resulting in stacked output. This change vendors the fixed version locally with the fix from freeall/single-line-log#21, which uses '\r' instead of '\x1b[1000D' for cursor positioning to ensure consistent behavior across all terminal emulators. Changes: - Remove @wwa/single-line-log dependency - Add src/lib/cli/single-log-line.ts with MIT license preserved - Update all imports to use local implementation - Add string-width@8.1.0 as direct dependency Related PR: - freeall/single-line-log#21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When output exceeded the terminal width and soft-wrapped across multiple physical lines, the library failed to properly clear previous content on standard terminals (macOS Terminal, iTerm2, gnome-terminal, konsole, xterm). This caused previous iterations to stack vertically and "bleed" upward, overwriting earlier terminal content.
Root Cause
The clearing logic used
\x1b[1000D(ANSI escape: move left 1000 columns) to position the cursor at column 0 before clearing each line. However, when text soft-wraps across multiple physical lines (without explicit\ncharacters), most VT100-compatible terminals treat this as a single logical line spanning multiple rows.When
MOVE_UP(\x1b[1A) is then executed, it moves up one logical line in the terminal's internal buffer, not one physical/visual line. This causes the cursor to jump to incorrect positions, resulting in the wrong lines being cleared.Why it worked in JetBrains Terminal: JetBrains Terminal treats soft-wrapped content as separate physical lines for cursor movement operations, masking the bug.
Before
before.mov
After
after.mov
Solution
Replace
\x1b[1000Dwith\r(carriage return) for positioning the cursor at column 0:\ris a standard ASCII control character (0x0D) that reliably moves to column 0 of the current physical line