Script editor: Don't open dominant script in external editor

Fixes #13429.

(cherry picked from commits b5f110c77e,
6b3f013a82, and
e016859c3b)
This commit is contained in:
Rémi Verschelde 2020-07-26 23:18:05 +02:00
parent a2f034d3ab
commit 518f109927
1 changed files with 16 additions and 17 deletions

View File

@ -2057,15 +2057,15 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
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") ||
(script.is_valid() && script->get_language()->overrides_external_editor());
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
// see if already has it
const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene();
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();
if (script != NULL && script->get_language()->overrides_external_editor()) {
if (script.is_valid() && script->get_language()->overrides_external_editor()) {
if (should_open) {
Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col);
if (err != OK)
@ -2074,11 +2074,10 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
return false;
}
if ((debugger->get_dump_stack_script() != p_resource || debugger->get_debug_with_external_editor()) &&
if (use_external_editor &&
(debugger->get_dump_stack_script() != p_resource || debugger->get_debug_with_external_editor()) &&
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 flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
@ -2972,13 +2971,13 @@ Vector<Ref<Script> > ScriptEditor::get_open_scripts() const {
}
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
// 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") ||
(p_script.is_valid() && p_script->get_language()->overrides_external_editor());
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
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;
if (open_dominant && p_script.is_valid()) {
if (open_dominant && !use_external_editor && p_script.is_valid()) {
edit(p_script);
}
}