### 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
v_scroll->show();
		v_scroll->set_max(total_rows + _get_visible_lines_offset());
		v_scroll->set_page(visible_rows + _get_visible_lines_offset());
		set_v_scroll(get_v_scroll());
	} else {
		first_visible_line = 0;
		first_visible_line_wrap_ofs = 0;
		v_scroll->set_value(0);
		v_scroll->set_max(0);
		v_scroll->hide();
	}
	if (total_width > visible_width) {
		h_scroll->show();
		h_scroll->set_max(total_width);
		h_scroll->set_page(visible_width);
		if (first_visible_col > (total_width - visible_width)) {
			first_visible_col = (total_width - visible_width);
		}
		if (fabs(h_scroll->get_value() - (double)first_visible_col) >= 1) {
			h_scroll->set_value(first_visible_col);
		}
	} else {
		first_visible_col = 0;
		h_scroll->set_value(0);
		h_scroll->set_max(0);
		h_scroll->hide();
	}
	updating_scrolls = false;
}
int TextEdit::_get_control_height() const {