Rebuild the open tab a pack overwrites - #1080
Merged
Merged
Conversation
scene_pack_branch saves inside the editor, so a tab holding the target kept its old tree and the next editor_save_scene put it back over the pack. The pack now goes through the same editor copy refresh as the file writers, with overwrite: true as the consent to lose the tab's changes. On 4.5 and 4.6 a rebuilt tab left of a current last tab stays the edited scene, because reload_scene ends with a set_current_tab that does nothing when the bar is already there. The bridge now names the scene it moved from, and the server opens it again on a later frame. This covers the #1068 writers too. scene_create over a scene no tab holds no longer asks for a reload. That printed "Can't reload scene" on 4.7 and cleared the current scene's undo history on 4.5 and 4.6. The harness allow entry for the deliberately broken fixture script also matches the wording a GDScript language server client triggers on connect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1072
Problem
scene_pack_branchwithoverwrite: truesaves inside the editor withResourceSaver.save. A tab that had the target open kept its old tree, and the nexteditor_save_scenewrote it back over the pack. The pack saidsaved: trueand the save said saved.What changed
scene_pack_branchnow runs the same editor copy refresh as the file writers after a pack that saved. The cached copy is reloaded and an open tab is rebuilt from the packed file. The answer carrieseditor_copy_reloadedand, when a tab was rebuilt,editor_scene_reloaded.overwrite: trueis the consent to lose the tab's unsaved changes, the same callviewport_create_test_labandscene_createmake. So the pack never refuses over an open tab, and there is no new argument.edited_scene_moved_from, and the server opens that scene again withscene.openonce the tabs are done.scene_createover a scene no tab holds no longer asks for a reload. On 4.7 that printedCan't reload scene ..., as it's not opened.The new harness case caught it.Failed parse script, the wording 4.5.1 prints when a GDScript language server client connects and the editor re-parses every script.Engine facts this rests on
Read from
editor/editor_node.cppat 4.5.1, 4.6.2 and 4.7.2, and measured with a live editor on each:reload_scenewithscene_tabs->set_current_tab(current_tab). The tab bar already sits at that index when the rebuilt tab was left of a current last tab, so nothing switches back. 4.7 rewrote the recovery and keeps the current tab.open_scene_from_pathandreload_scene_from_pathreturn early whileis_changing_scene()is set, which lasts until the deferred_set_main_scene_stateat the end of the frame. So the switch back has to be a later request.reload_scenefails with an error for a path no tab holds. 4.5 and 4.6 clear the current scene's undo history instead.Tests
discard_unsaved. A refused pack asks nothing. A rebuild that moves the edited scene is switched back once, to the scene the caller was on. A switch back the editor refuses is named with the way out. A rebuild that keeps the current scene asks nothing more.Invoke-PackBranchTabBlockintests/scene_tab_reload.ps1: the steps from the issue. It packs over a scene open in another tab, checks the edited scene did not move, opens and saves the target, and reads the file. A second session closes the target and overwrites it withscene_create. All three lines pass locally. Before the switch back, 4.5.1 failed on the edited scene check.Filed from this
csharp_check_buildreports a slow dotnet as missing. It turned main red on the last run.scene_createover a scene open in another tab answersopened: falseon 4.5 and 4.6.