Skip to content

fix(draw): avoid negative cursor-left in vertical_seq#235

Merged
Tieske merged 3 commits intolunarmodules:mainfrom
Vinit-786:fix/negative-ansi-vertical-seq
Mar 27, 2026
Merged

fix(draw): avoid negative cursor-left in vertical_seq#235
Tieske merged 3 commits intolunarmodules:mainfrom
Vinit-786:fix/negative-ansi-vertical-seq

Conversation

@Vinit-786
Copy link
Copy Markdown
Contributor

Fix the terminal.draw.line.vertical_seq() so it does not generate invalid ANSI when lastcolumn=true.

Problem :

In src/terminal/draw/line.lua, vertical_seq() used:

cursor.position.left_seq(w - lastcolumn * 2)

For a 1-column character (for example "|") and lastcolumn=true, this becomes left_seq(-1), which emits invalid ANSI like \27[-1D.

Fix :
Clamp the computed back-move before calling left_seq():

compute back = w - lastcolumn * 2
if back < 0, set back = 0

Tests added :
Updated spec/12-draw_spec.lua with regression tests:

  • vertical_seq(3, "|", true) no longer emits negative left movement.
  • vertical_seq(3, "|", false) keeps existing normal behavior.

Impact :
Prevents invalid cursor movement sequences at terminal right edge and avoids rendering glitches in vertical line / border drawing.

Copy link
Copy Markdown
Member

@Tieske Tieske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx! @Vinit-786

@Tieske Tieske merged commit 2ed97a5 into lunarmodules:main Mar 27, 2026
8 checks passed
Gitkbc pushed a commit to Gitkbc/terminal.lua that referenced this pull request Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants