Statusline wraps prematurely due to ANSI escape codes counting toward line length

Resolved 💬 4 comments Opened Feb 9, 2026 by RISCfuture Closed Mar 12, 2026

Description

When using a custom statusline script that outputs ANSI color escape codes, the statusline wraps to multiple lines even when there appears to be plenty of visible space remaining on the line.

Root cause

ANSI escape codes (e.g. \033[1;34m, \033[0m) are non-printing characters but appear to be counted toward the line length for wrapping purposes. Each color + reset pair adds ~14 invisible bytes. A statusline with ~14 color sequences adds ~100+ bytes of invisible characters, causing the line to wrap well before the visible text reaches the terminal width.

Screenshot

In this example, the statusline wraps onto 3 lines despite the visible content being significantly shorter than the terminal width:

📁 ~/Repositories/hamilton 🌿 02-05-fix_ap…ty_libraries 💎 3.4.5
4.0.1 ⬢ 20.19.5
22.20.0 [Opus 4.6]

Expected behavior

The statusline should account for non-printing escape sequences when determining line length, so that wrapping is based on visible character width only.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗