### 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
draw_caret = !draw_caret;
	if (is_visible_in_tree() && has_focus() && window_has_focus) {
		queue_redraw();
	}
}
int TextEdit::_get_column_x_offset_for_line(int p_char, int p_line, int p_column) const {
	ERR_FAIL_INDEX_V(p_line, text.size(), 0);
	int row = 0;
	Vector<Vector2i> rows2 = text.get_line_wrap_ranges(p_line);
	for (int i = 0; i < rows2.size(); i++) {
		if ((p_char >= rows2[i].x) && (p_char <= rows2[i].y)) {
			row = i;
			break;
		}
	}
	RID text_rid = text.get_line_data(p_line)->get_line_rid(row);
	CaretInfo ts_caret = TS->shaped_text_get_carets(text_rid, p_column);
	if ((ts_caret.l_caret != Rect2() && (ts_caret.l_dir == TextServer::DIRECTION_AUTO || ts_caret.l_dir == (TextServer::Direction)input_direction)) || (ts_caret.t_caret == Rect2())) {
		return ts_caret.l_caret.position.x;
	} else {
		return ts_caret.t_caret.position.x;
	}
}
void TextEdit::_click_selection_held() {