Handle trailing line breaks when pasting text - #6069
Open
volksec wants to merge 3 commits into
Open
Conversation
Signed-off-by: Luan Nutels - VolkSec <luan.nutels@owasp.org>
volksec
marked this pull request as ready for review
July 29, 2026 22:28
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes newline handling in LLTextEditor::pasteTextWithLinebreaks() so a trailing \n in pasted text is processed as an actual line break (via addLineBreakChar()), instead of being inserted through the normal text path where it can render as an unexpected glyph/space on Windows/macOS.
Changes:
- Iterate through all newline occurrences (including a final trailing newline) and route each through
addLineBreakChar(). - Stop “group with next” undo-grouping when the pasted content ends with a line break.
- Avoid attempting an empty trailing substring insertion after processing the last newline.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Handle a trailing newline as a line break when pasting into
LLTextEditor, instead of inserting it as a regular character.Fixes #5871.
Root cause
LLTextEditor::pasteTextWithLinebreaks()excluded a newline at the final position from its line-break loop. The remaining substring, including the trailing newline, was then passed to the regular text insertion path. On Windows this could render as an unexpected special character; on macOS it could appear as a space.Changes
addLineBreakChar(), including a trailing newline.Validation
pre-commit run --files indra/llui/lltexteditor.cppgit diff --checkcmake --build build-vc170-64 --config Release --target llui -- /mcmake --build build-vc170-64 --config Release --target secondlife-bin -- /mBoth
llui.libandsecondlife-bin.exewere built successfully with Visual Studio 2022. Manual runtime reproduction is still pending.