Skip to content

Fix double-width line (DECDWL / ESC #6) fragment positioning#46

Open
epatel wants to merge 1 commit intoSwordfish90:masterfrom
epatel:fix/double-width-line-positioning
Open

Fix double-width line (DECDWL / ESC #6) fragment positioning#46
epatel wants to merge 1 commit intoSwordfish90:masterfrom
epatel:fix/double-width-line-positioning

Conversation

@epatel
Copy link

@epatel epatel commented Feb 12, 2026

Summary

  • The old moveTopLeft(textScale.inverted().map(textArea.topLeft())) inverse-mapped the entire top-left point (margins + column offset), so the painter's scale(2,1) simply recovered the original single-width coordinates
  • On lines with multiple text fragments (e.g. box-drawing chars + text + box-drawing chars), each fragment was placed at its single-width position but rendered at double width, causing overlaps and gaps
  • Fix: inverse-map only the margin/origin offset and leave the column position unmapped, so the painter scale correctly doubles it

Test script

#!/usr/bin/env bash
# Test ESC #6 (DECDWL - double-width line) rendering
# On a correct terminal, the boxes should be the same width

clear
printf '\033[H'

# Normal width box (20 chars wide)
printf '\033#5'
printf '\033(0lqqqqqqqqqqqqqqqqqqk\033(B\n'
printf '\033#5'
printf '\033(0x\033(B  Normal width    \033(0x\033(B\n'
printf '\033#5'
printf '\033(0mqqqqqqqqqqqqqqqqqqj\033(B\n'

printf '\n'

# Double width box (10 chars = 20 screen columns)
printf '\033#6'
printf '\033(0lqqqqqqqqk\033(B\n'
printf '\033#6'
printf '\033(0x\033(B Double \033(0x\033(B\n'
printf '\033#6'
printf '\033(0mqqqqqqqqj\033(B\n'

printf '\n\033#5'
printf 'If both boxes are the same width, ESC #6 works correctly.\n'
printf 'If the double box is narrower, spaces are not being doubled.\n'

Test plan

  • Run the test script above — both boxes should be the same screen width
  • Verify box-drawing characters on double-width lines render as solid lines (no dashed gaps)
  • Verify normal (non-double-width) text rendering is unaffected

🤖 Generated with Claude Code

The old code inverse-mapped the entire top-left point (margins + column
offset), so the painter's scale(2,1) simply recovered the original
single-width coordinates. On lines with multiple text fragments (e.g.
box-drawing chars + text + box-drawing chars), each fragment was placed
at its single-width position but rendered at double width, causing
overlaps and gaps.

Fix by inverse-mapping only the margin/origin offset and leaving the
column position unmapped, so the painter scale correctly doubles it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant