### Godot version

v4.1.1-stable_mono_win64

### System information

Windows 11

### Issue description

I removed the node to replace it with another, but when I change the path in the code, the engine crashes for me.

### Steps to reproduce

I did a screen recording as it happens:

https://github.com/godotengine/godot/assets/116289408/b2fd2689-8d82-44e8-8e02-be01674842e1



### Minimal reproduction project

[MixApo.zip](https://github.com/godotengine/godot/files/12208403/MixApo.zip)

set_caret_column(caret_columns[c], c == 0, c);
		if (from_selections.write[c].first != -1) {
			select(from_selections.write[c].first, from_selections.write[c].second, to_selections.write[c].first, to_selections.write[c].second, c);
		}
	}
	merge_overlapping_carets();
	end_complex_operation();
	queue_redraw();
}
int CodeEdit::_calculate_spaces_till_next_left_indent(int p_column) const {
	int spaces_till_indent = p_column % indent_size;
	if (spaces_till_indent == 0) {
		spaces_till_indent = indent_size;
	}
	return spaces_till_indent;
}
int CodeEdit::_calculate_spaces_till_next_right_indent(int p_column) const {
	return indent_size - p_column % indent_size;
}
void CodeEdit::_new_line(bool p_split_current_line, bool p_above) {
	if (!is_editable()) {
		return;
	}
	begin_complex_operation();
	Vector<int> caret_edit_order = get_caret_index_edit_order();
	for (const int &i : caret_edit_order) {
		
		const int cc = p_split_current_line ? get_caret_column(i) : get_line(get_caret_line(i)).length();
		const int cl = get_caret_line(i);
		const String line = get_line(cl);