### 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 draw_minimap;
}
void TextEdit::set_minimap_width(int p_minimap_width) {
	if (minimap_width == p_minimap_width) {
		return;
	}
	minimap_width = p_minimap_width;
	_update_wrap_at_column();
	queue_redraw();
}
int TextEdit::get_minimap_width() const {
	return minimap_width;
}
int TextEdit::get_minimap_visible_lines() const {
	return _get_control_height() / (minimap_char_size.y + minimap_line_spacing);
}
void TextEdit::add_gutter(int p_at) {
	if (p_at < 0 || p_at > gutters.size()) {
		gutters.push_back(GutterInfo());
	} else {
		gutters.insert(p_at, GutterInfo());
	}
	text.add_gutter(p_at);
	_update_gutter_width();
	emit_signal(SNAME("gutter_added"));
	queue_redraw();
}
void TextEdit::remove_gutter(int p_gutter) {