You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When assigning the text of a TextEdit node, it completely loses all information about whether the assigned string originally contained any \r characters at all. It can't even differentiate a consistently \r\n buffer from a \n buffer, and the API doesn't provide a way to recover this information. This happens even if you assign individual lines containing \r characters with set_line.
This also means that any files edited with Godot's built-in script editor will immediately lose their \rs upon being saved, causing data loss. In some cases, e.g. with text file processing test cases, this is a problem even if you're ideologically opposed to \r\n linefeeds.
To some extent some amount of information loss here is expectable because LineEdit is (apparently) based on an array of single-line strings without line terminators, but it should probably at least attempt to detect LF vs CRLF and restore that information when generating the output of get_text(), at least in simple cases like when \n never appears without a preceding \r. A way to query and override this detection would also be nice.
Also, \r characters should never be silently stripped from the middles of lines. Such characters can be the result of e.g. terminal capture logging, where \r literally means "go back to the start of the line and start typing from there again".
Steps to reproduce
Assign "\r\n\r\nasdf\rasdf\rasdf\rasdf" to a TextEdit's text field and note that all the \r characters completely disappear (e.g. by running print(editor.text.c_escape())).
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered:
Tested versions
4.4.dev7
System information
Godot v4.4.dev7 - Windows 10 (build 19045) - Multi-window, 2 monitors - OpenGL 3 (Compatibility) - AMD Radeon RX 6800 (Advanced Micro Devices, Inc.; 32.0.12033.1030) - AMD Ryzen 5 7600X 6-Core Processor (12 threads)
Issue description
When assigning the text of a
TextEdit
node, it completely loses all information about whether the assigned string originally contained any\r
characters at all. It can't even differentiate a consistently\r\n
buffer from a\n
buffer, and the API doesn't provide a way to recover this information. This happens even if you assign individual lines containing\r
characters withset_line
.This also means that any files edited with Godot's built-in script editor will immediately lose their
\r
s upon being saved, causing data loss. In some cases, e.g. with text file processing test cases, this is a problem even if you're ideologically opposed to\r\n
linefeeds.To some extent some amount of information loss here is expectable because LineEdit is (apparently) based on an array of single-line strings without line terminators, but it should probably at least attempt to detect LF vs CRLF and restore that information when generating the output of
get_text()
, at least in simple cases like when\n
never appears without a preceding\r
. A way to query and override this detection would also be nice.Also,
\r
characters should never be silently stripped from the middles of lines. Such characters can be the result of e.g. terminal capture logging, where\r
literally means "go back to the start of the line and start typing from there again".Steps to reproduce
Assign
"\r\n\r\nasdf\rasdf\rasdf\rasdf"
to a TextEdit'stext
field and note that all the\r
characters completely disappear (e.g. by runningprint(editor.text.c_escape())
).Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: