Skip to content

Fix: insertText newline regression#9022

Merged
vadi2 merged 11 commits intoMudlet:developmentfrom
vadi2:fix/insertText-newline-regression
Apr 8, 2026
Merged

Fix: insertText newline regression#9022
vadi2 merged 11 commits intoMudlet:developmentfrom
vadi2:fix/insertText-newline-regression

Conversation

@vadi2
Copy link
Copy Markdown
Member

@vadi2 vadi2 commented Mar 7, 2026

Brief overview of PR changes/additions

Fix insertText newline regression in 4.20 that came with #7714.

Motivation for adding to Mudlet

Fixes #8945
Fixes #8824

Other info (issues closed, discussion etc)

Added all test cases we found as test cases to our CI to ensure we don't regress.

vadi2 added 2 commits March 7, 2026 22:32
getWrapInfo discarded all wrap info when totalWidth <= mWrapAt,
including newline-triggered splits. Track hasNewline and skip
the early return when newlines are present.

Add C++ functional tests for insertText with newlines and echo
with newlines in trigger mode. Add Lua tests for the same.

Fixes Mudlet#8945
@vadi2 vadi2 requested a review from a team as a code owner March 7, 2026 21:37
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Mar 7, 2026

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@vadi2
Copy link
Copy Markdown
Member Author

vadi2 commented Mar 7, 2026

@Harrison-Teeg could you test this one out?

@vadi2 vadi2 marked this pull request as draft March 8, 2026 09:07
vadi2 added 2 commits March 8, 2026 10:43
decho's trailing \n moves cursor to the next line, so
selectSection was operating on an empty line.
@ZookaOnGit ZookaOnGit added this to the 4.21.0 milestone Mar 25, 2026
vadi2 added 5 commits March 25, 2026 21:27
Use insertInLine instead of appendLine in TConsole::echo()
trigger mode so newlines are embedded in the line text rather
than creating new buffer lines. This fixes cecho/creplaceLine
regression from Mudlet#7714 where subsequent echo calls would append
to wrong lines.

Also adds regression tests for Mudlet#8945 and Mudlet#8824.
The getWrapInfo fix now properly splits on embedded newlines,
so decho's trailing \n moves the cursor to the next line.
selectSection operates on the current line, so we need to
move back to line 0 first.
- Add moveCursor(0,0) to before_each for testformat and formattest
  consoles since clearWindow doesn't reset mUserCursor
- Fix off-by-one in selectSection calls: positions are 0-indexed so
  last char of N-char line is at N-1, not N
- Fix getFgColor/getBgColor assertions: these return r,g,b numbers,
  not tables
- Remove redundant moveCursor from inside test 665

These tests were passing on development by accident - cursor state
from prior tests caused if-guards to skip all assertions, making
them pass vacuously.
Tests are already in UI_spec.lua.
@vadi2 vadi2 marked this pull request as ready for review March 26, 2026 19:42
@ZookaOnGit
Copy link
Copy Markdown
Contributor

this does seem to fix the problem

@vadi2
Copy link
Copy Markdown
Member Author

vadi2 commented Mar 31, 2026

Good to merge?

@Harrison-Teeg
Copy link
Copy Markdown
Contributor

There's an issue with this PR -- I'm still tracking it down but it looks like it's something regarding the length of the line not resetting for newlines in echoes. If I have a trigger that has long enough echos mudlet will wordwrap them even though the linebreaks make it so the lines shouldn't be wrapped.

E.g. before:

A magic aura flares around you and completely absorbs the damage.
 ============= /\  /\  /\  /\ =============
 ============= \/  \/  \/  \/ ============= 

After

A magic aura flares around you and completely absorbs the damage.
 ============= /\  /\  /\  /\ =============
 ============= \/  \/ 
  \/  \/ =============

xPos was not reset to 0 when processing embedded linefeeds,
causing line width to accumulate across newline boundaries
and triggering false word-wrapping on short lines.
@vadi2
Copy link
Copy Markdown
Member Author

vadi2 commented Mar 31, 2026

Good one, fixed.

@ZookaOnGit
Copy link
Copy Markdown
Contributor

nice catch, we good then @Harrison-Teeg ?

@Harrison-Teeg
Copy link
Copy Markdown
Contributor

That solves the issue!

@vadi2
Copy link
Copy Markdown
Member Author

vadi2 commented Apr 4, 2026

/refresh links

@vadi2 vadi2 merged commit 683f25a into Mudlet:development Apr 8, 2026
12 checks passed
@vadi2 vadi2 deleted the fix/insertText-newline-regression branch April 8, 2026 18:30
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.

Newline in insertText no longer works in 4.20.1 cecho behavior change with newlines and creplaceLine

3 participants