### Godot version

4.0.2

### System information

Ubuntu 22.04.1 LTS

### Issue description

When "Collapse Lines" in the output dock is enabled, having a lot of different lines in the output makes the editor extremely slow / unusable when trying to add new lines.

This has frozen Godot many times for me when I'm using tool scripts, as every time I get spammed with warnings and errors, the editor quickly becomes unusable, even if my output dock is closed.

### Steps to reproduce

Enable the Collapse Lines functionality. Then add this script to a node:
```gdscript
@tool
extends Node

func _ready() -> void:
	for i in 600:  # 600 different lines. You might have to raise this higher to notice the slowdown.
		print(i)

func _process(_delta: float) -> void:
	print(Time.get_ticks_msec() / 1000)  # Should add as many messages per line as the FPS.
```

You can close the scene, clear the output, and reopen it to restart the test or after adjusting the number of unique lines to be added initially. For me, the editor becomes unusable at around 2000 different lines and pretty much frozen at around 8000 different lines. This problem is completely absent without the Collapse Lines functionality.

### Minimal reproduction project

I provided a script
jst_flags.set_flag(TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE);
							}
						}
					} else if (subtag_a[0] == "tab_stops") {
						Vector<String> splitters;
						splitters.push_back(",");
						splitters.push_back(";");
						tab_stops = subtag_a[1].split_floats_mk(splitters);
					} else if (subtag_a[0] == "align") {
						if (subtag_a[1] == "l" || subtag_a[1] == "left") {
							alignment = HORIZONTAL_ALIGNMENT_LEFT;
						} else if (subtag_a[1] == "c" || subtag_a[1] == "center") {
							alignment = HORIZONTAL_ALIGNMENT_CENTER;
						} else if (subtag_a[1] == "r" || subtag_a[1] == "right") {
							alignment = HORIZONTAL_ALIGNMENT_RIGHT;
						} else if (subtag_a[1] == "f" || subtag_a[1] == "fill") {
							alignment = HORIZONTAL_ALIGNMENT_FILL;
						}
					} else if (subtag_a[0] == "dir" || subtag_a[0] == "direction") {
						if (subtag_a[1] == "a" || subtag_a[1] == "auto") {
							dir = Control::TEXT_DIRECTION_AUTO;
						} else if (subtag_a[1] == "l" || subtag_a[1] == "ltr") {
							dir = Control::TEXT_DIRECTION_LTR;
						} else if (subtag_a[1] == "r" || subtag_a[1] == "rtl") {
							dir = Control::TEXT_DIRECTION_RTL;
						}
					} else if (subtag_a[0] == "lang" || subtag_a[0] == "language") {
						lang = subtag_a[1];
					} else if (subtag_a[0] == "st" || subtag_a[0] == "bidi_override") {
						if (subtag_a[1] == "d" || subtag_a[1] == "default") {