### Godot version

4.1

### System information

Windows 10

### Issue description

I have this config file and thought I'd try and edit it. The editor opens the .cfg file with no issue but highlighting the text crashes the editor.
Also adding and deleting text is very delayed.

This is probably a performance issue, I'm not sure if the editor would unfreeze if I waited a while.

Note:
The text highlights fine but crashes when I let go of the mouse.

### Steps to reproduce

Try highlighting some of the text from this file, I dare you!
[AStar Data.zip](https://github.com/godotengine/godot/files/12387133/AStar.Data.zip)


### Minimal reproduction project

N/A
} break;
		case MENU_DIR_AUTO: {
			set_text_direction(TEXT_DIRECTION_AUTO);
		} break;
		case MENU_DIR_LTR: {
			set_text_direction(TEXT_DIRECTION_LTR);
		} break;
		case MENU_DIR_RTL: {
			set_text_direction(TEXT_DIRECTION_RTL);
		} break;
		case MENU_DISPLAY_UCC: {
			set_draw_control_chars(!get_draw_control_chars());
		} break;
		case MENU_INSERT_LRM: {
			if (editable) {
				insert_text_at_caret(String::chr(0x200E));
			}
		} break;
		case MENU_INSERT_RLM: {
			if (editable) {
				insert_text_at_caret(String::chr(0x200F));
			}
		} break;
		case MENU_INSERT_LRE: {
			if (editable) {
				insert_text_at_caret(String::chr(0x202A));
			}
		} break;
		case MENU_INSERT_RLE: {
			if (editable) {