Browse Source

Merge pull request #40735 from akien-mga/no-dominion-outside-borders

Script editor: Don't open dominant script in external editor
Rémi Verschelde 5 years ago
parent
commit
0a7942f4bb
1 changed files with 11 additions and 15 deletions
  1. 11 15
      editor/plugins/script_editor_plugin.cpp

+ 11 - 15
editor/plugins/script_editor_plugin.cpp

@@ -2091,13 +2091,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
 
 
 	Ref<Script> script = p_resource;
 	Ref<Script> script = p_resource;
 
 
-	// refuse to open built-in if scene is not loaded
+	// Don't open dominant script if using an external editor.
+	const bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor");
+	const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
 
 
-	// see if already has it
-
-	bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
-
-	const bool should_open = open_dominant || !EditorNode::get_singleton()->is_changing_scene();
+	const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene();
 
 
 	if (script != nullptr && script->get_language()->overrides_external_editor()) {
 	if (script != nullptr && script->get_language()->overrides_external_editor()) {
 		if (should_open) {
 		if (should_open) {
@@ -2109,10 +2107,10 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
 		return false;
 		return false;
 	}
 	}
 
 
-	if ((EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) &&
+	if (use_external_editor &&
+			(EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) &&
 			p_resource->get_path().is_resource_file() &&
 			p_resource->get_path().is_resource_file() &&
-			p_resource->get_class_name() != StringName("VisualScript") &&
-			bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
+			p_resource->get_class_name() != StringName("VisualScript")) {
 		String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
 		String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
 		String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
 		String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
 
 
@@ -3002,13 +3000,11 @@ Array ScriptEditor::_get_open_script_editors() const {
 }
 }
 
 
 void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
 void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
-	bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
-
-	if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
-		return;
-	}
+	// Don't open dominant script if using an external editor.
+	const bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor");
+	const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
 
 
-	if (open_dominant && p_script.is_valid()) {
+	if (open_dominant && !use_external_editor && p_script.is_valid()) {
 		edit(p_script);
 		edit(p_script);
 	}
 	}
 }
 }