1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

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.
This commit is contained in:
Lucas OH 2025-07-06 22:10:51 +02:00 committed by GitHub
parent 2a8ee686d9
commit 51a453ca7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View file

@ -1104,10 +1104,7 @@ void CGUIEditBox::breakText()
lineBreak = true; lineBreak = true;
c = 0; c = 0;
if (Text[i + 1] == L'\n') { // Windows breaks 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. Text.erase(i);
// 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);
--size; --size;
if (CursorPos > i) if (CursorPos > i)
--CursorPos; --CursorPos;

View file

@ -337,10 +337,7 @@ void GUIEditBoxWithScrollBar::breakText()
line_break = true; line_break = true;
c = 0; c = 0;
if (Text[i + 1] == L'\n') { // Windows breaks 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. Text.erase(i);
// 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);
--size; --size;
if (m_cursor_pos > i) if (m_cursor_pos > i)
--m_cursor_pos; --m_cursor_pos;