Fixed implementation of RTL remove_line(), which fixed issues in EditorLog.

There were some issues in RichTextLabel `remove_line()` method, where items were not correctly removed, and line decremending for items in later lines was not correctly done.
This also fixed several headaches with EditorLog, which relied on the `remove_line()` method for collapsing of duplicate messages. The fix to RTL also fixed the issues with EditorLog.

Fixes #49030
This commit is contained in:
Eric M
2021-05-25 21:48:28 +10:00
parent 231daa6025
commit 471f7f1a75
3 changed files with 25 additions and 28 deletions

View File

@@ -234,10 +234,9 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
if (p_replace_previous) {
// Remove last line if replacing, as it will be replace by the next added line.
// Why - 2? RichTextLabel is weird. When you add a line, it also adds a NEW line, which is null,
// Why "- 2"? RichTextLabel is weird. When you add a line with add_newline(), it also adds an element to the list of lines which is null/blank,
// but it still counts as a line. So if you remove the last line (count - 1) you are actually removing nothing...
log->remove_line(log->get_line_count() - 2);
log->increment_line_count();
log->remove_line(log->get_paragraph_count() - 2);
}
switch (p_message.type) {
@@ -271,13 +270,14 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) {
}
log->add_text(p_message.text);
log->add_newline();
// Need to use pop() to exit out of the RichTextLabels current "push" stack.
// We only "push" in the above switch when message type != STD, so only pop when that is the case.
if (p_message.type != MSG_TYPE_STD) {
log->pop();
}
log->add_newline();
}
void EditorLog::_set_filter_active(bool p_active, MessageType p_message_type) {