### 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
if (p_new_line < 0) {
		p_new_line = 0;
	}
	if (p_new_line >= text.size()) {
		p_new_line = text.size() - 1;
	}
	p_new_column = _get_char_pos_for_line(p_last_fit_x, p_new_line, caret_wrap_index);
	if (p_new_column != 0 && get_line_wrapping_mode() != LineWrappingMode::LINE_WRAPPING_NONE && caret_wrap_index < get_line_wrap_count(p_new_line)) {
		Vector<String> rows = get_line_wrapped_text(p_new_line);
		int row_end_col = 0;
		for (int i = 0; i < caret_wrap_index + 1; i++) {
			row_end_col += rows[i].length();
		}
		if (p_new_column >= row_end_col) {
			p_new_column -= 1;
		}
	}
}
void TextEdit::_update_placeholder() {
	if (theme_cache.font.is_null() || theme_cache.font_size <= 0) {
		return; 
	}
	const String placeholder_translated = atr(placeholder_text);
	
	placeholder_data_buf->clear();
	placeholder_data_buf->set_width(text.get_width());
	placeholder_data_buf->set_break_flags(text.get_brk_flags());
	if (text_direction == Control::TEXT_DIRECTION_INHERITED) {
		placeholder_data_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);