From 51a453ca7bc53b3a0ce6f390ce67113672e5f71c Mon Sep 17 00:00:00 2001 From: Lucas OH <3687994+PtiLuky@users.noreply.github.com> Date: Sun, 6 Jul 2025 22:10:51 +0200 Subject: [PATCH] Formspec: Fix newline conversion on Windows (#16311) Strings with CR+LF (\r+\n) were wrongly fixed into \r, which is enough to display them correctly, but the missing \n became important once the text was saved/reloaded. By removing the \r instead of the \n, then the text is displayed correctly and saved correctly. --- irr/src/CGUIEditBox.cpp | 5 +---- src/gui/guiEditBoxWithScrollbar.cpp | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/irr/src/CGUIEditBox.cpp b/irr/src/CGUIEditBox.cpp index 6c29e89a9..1bce60a04 100644 --- a/irr/src/CGUIEditBox.cpp +++ b/irr/src/CGUIEditBox.cpp @@ -1104,10 +1104,7 @@ void CGUIEditBox::breakText() lineBreak = true; c = 0; if (Text[i + 1] == L'\n') { // Windows breaks - // TODO: I (Michael) think that we shouldn't change the text given by the user for whatever reason. - // Instead rework the cursor positioning to be able to handle this (but not in stable release - // branch as users might already expect this behavior). - Text.erase(i + 1); + Text.erase(i); --size; if (CursorPos > i) --CursorPos; diff --git a/src/gui/guiEditBoxWithScrollbar.cpp b/src/gui/guiEditBoxWithScrollbar.cpp index 4206a2249..7e89a32d3 100644 --- a/src/gui/guiEditBoxWithScrollbar.cpp +++ b/src/gui/guiEditBoxWithScrollbar.cpp @@ -337,10 +337,7 @@ void GUIEditBoxWithScrollBar::breakText() line_break = true; c = 0; if (Text[i + 1] == L'\n') { // Windows breaks - // TODO: I (Michael) think that we shouldn't change the text given by the user for whatever reason. - // Instead rework the cursor positioning to be able to handle this (but not in stable release - // branch as users might already expect this behavior). - Text.erase(i + 1); + Text.erase(i); --size; if (m_cursor_pos > i) --m_cursor_pos;