### 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
int control_height = get_size().height;
	control_height -= theme_cache.style_normal->get_minimum_size().height;
	if (h_scroll->is_visible_in_tree()) {
		control_height -= h_scroll->get_size().height;
	}
	return control_height;
}
void TextEdit::_v_scroll_input() {
	scrolling = false;
	minimap_clicked = false;
}
void TextEdit::_scroll_moved(double p_to_val) {
	if (updating_scrolls) {
		return;
	}
	if (h_scroll->is_visible_in_tree()) {
		first_visible_col = h_scroll->get_value();
	}
	if (v_scroll->is_visible_in_tree()) {