### Godot version

v4.0.beta.custom_build [13f0158]

### System information

Windows 10

### Issue description

When doing operations (`begin_complex_operation` and `end_complex_operation`) with multiple selections in TextEdit, some of these selections don't revert upon undo. This behavior is affects some of script editor's operations, like duplicate selection and delete lines.

### Steps to reproduce

Open script editor, make multiple selections. Keep in mind what you have selected. Do duplicate selection (ctrl+shift+D). Undo (ctrl+Z). Compare the result to what you remember.

### Minimal reproduction project

N/A
return highlight_current_line;
}
void TextEdit::set_highlight_all_occurrences(const bool p_enabled) {
	if (highlight_all_occurrences == p_enabled) {
		return;
	}
	highlight_all_occurrences = p_enabled;
	queue_redraw();
}
bool TextEdit::is_highlight_all_occurrences_enabled() const {
	return highlight_all_occurrences;
}
void TextEdit::set_draw_control_chars(bool p_enabled) {
	if (draw_control_chars != p_enabled) {
		draw_control_chars = p_enabled;
		if (menu) {
			menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars);
		}
		text.set_draw_control_chars(draw_control_chars);
		text.invalidate_font();
		_update_placeholder();
		queue_redraw();
	}
}
bool TextEdit::get_draw_control_chars() const {