### Godot version

v4.0.stable.official [92bee43ad]

### System information

Windows10,64,OpenGL API 3.3.0 NVIDIA 425.25 - Compatibility - Using Device: NVIDIA Corporation - GeForce MX250

### Issue description

When I change the tileset texture area size, godot crashes with the following error

The tileset contains a 107*35 sprite sheet

```
ERROR: UndoRedo history mismatch: expected 0, got 2.
   at: (editor/editor_undo_redo_manager.cpp:108)
```

### Steps to reproduce

1. create a tilemap node
2. create a tileset
3. click the tileset
4. drag the spritesheet(107*35) into the tileset
5. click yes with "auto create tiles in non-tra... "pop
6. change the tileset texture region size
7. program freezes
8.
 ```
ERROR: UndoRedo history mismatch: expected 0, got 2.
   at: (editor/editor_undo_redo_manager.cpp:108)
```

### Minimal reproduction project

[test1.zip](https://github.com/godotengine/godot/files/10918599/test1.zip)

tile_data_painting_editor_container = memnew(VBoxContainer);
	tile_data_painting_editor_container->set_h_size_flags(SIZE_EXPAND_FILL);
	tile_data_editors_vbox->add_child(tile_data_painting_editor_container);
	
	atlas_source_proxy_object = memnew(TileSetAtlasSourceProxyObject());
	atlas_source_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed));
	atlas_source_inspector = memnew(EditorInspector);
	atlas_source_inspector->set_v_size_flags(SIZE_EXPAND_FILL);
	atlas_source_inspector->set_show_categories(true);
	atlas_source_inspector->edit(atlas_source_proxy_object);
	middle_vbox_container->add_child(atlas_source_inspector);
	
	VBoxContainer *right_vbox_container = memnew(VBoxContainer);
	add_child(right_vbox_container);
	
	tool_settings = memnew(HBoxContainer);
	right_vbox_container->add_child(tool_settings);
	tool_settings_tile_data_toolbar_container = memnew(HBoxContainer);
	tool_settings->add_child(tool_settings_tile_data_toolbar_container);
	tools_settings_erase_button = memnew(Button);
	tools_settings_erase_button->set_flat(true);
	tools_settings_erase_button->set_toggle_mode(true);
	tools_settings_erase_button->set_shortcut(ED_SHORTCUT("tiles_editor/eraser", TTR("Eraser"), Key::E));
	tools_settings_erase_button->set_shortcut_context(this);
	tool_settings->add_child(tools_settings_erase_button);
	tool_advanced_menu_button = memnew(MenuButton);
	tool_advanced_menu_button->set_flat(true);
	tool_advanced_menu_button->get_popup()->add_item(TTR("Create Tiles in Non-Transparent Texture Regions"), ADVANCED_AUTO_CREATE_TILES);
	tool_advanced_menu_button->get_popup()->add_item(TTR("Remove Tiles in Fully Transparent Texture Regions"), ADVANCED_AUTO_REMOVE_TILES);
	tool_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option));