### 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)

emit_signal(SNAME("breakpoint_toggled"), next_line);
			breakpointed_lines[next_line] = true;
			continue;
		}
	}
	lines_edited_from = -1;
	lines_edited_to = -1;
	lines_edited_changed = 0;
}
CodeEdit::CodeEdit() {
	
	auto_indent_prefixes.insert(':');
	auto_indent_prefixes.insert('{');
	auto_indent_prefixes.insert('[');
	auto_indent_prefixes.insert('(');
	
	add_auto_brace_completion_pair("(", ")");
	add_auto_brace_completion_pair("{", "}");
	add_auto_brace_completion_pair("[", "]");
	add_auto_brace_completion_pair("\"", "\"");
	add_auto_brace_completion_pair("\'", "\'");
	
	add_string_delimiter("\"", "\"", false);
	add_string_delimiter("\'", "\'", false);
	
	set_layout_direction(LAYOUT_DIRECTION_LTR);
	set_text_direction(TEXT_DIRECTION_LTR);
	
	int gutter_idx = 0;