### 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
Size2 size = theme_cache.style_normal->get_minimum_size();
	if (fit_content_height) {
		size.y += content_height_cache;
	}
	return size;
}
bool TextEdit::is_text_field() const {
	return true;
}
Variant TextEdit::get_drag_data(const Point2 &p_point) {
	Variant ret = Control::get_drag_data(p_point);
	if (ret != Variant()) {
		return ret;
	}
	if (has_selection() && selection_drag_attempt) {
		String t = get_selected_text();
		Label *l = memnew(Label);
		l->set_text(t);
		set_drag_preview(l);
		return t;
	}
	return Variant();
}
bool TextEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const {