Browse Source

External editor fixes
- Fix VS Code opening on the previous line to the desired one.
- Fix running MonoDevelop without the line and column parameters.
- Fix `ScriptEditor::_goto_script_line` not working with language overriden external editors.

Ignacio Etcheverry 7 years ago
parent
commit
1c6269f2dd
2 changed files with 19 additions and 16 deletions
  1. 13 15
      editor/plugins/script_editor_plugin.cpp
  2. 6 1
      modules/mono/editor/godotsharp_editor.cpp

+ 13 - 15
editor/plugins/script_editor_plugin.cpp

@@ -313,24 +313,22 @@ void ScriptEditor::_goto_script_line2(int p_line) {
 
 
 void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
 void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
 
 
-	editor->push_item(p_script.ptr());
+	Ref<Script> script = Object::cast_to<Script>(*p_script);
+	if (!script.is_null() && script->get_path().is_resource_file()) {
+		if (edit(p_script, p_line, 0)) {
+			editor->push_item(p_script.ptr());
 
 
-	if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
-
-		Ref<Script> script = Object::cast_to<Script>(*p_script);
-		if (!script.is_null() && script->get_path().is_resource_file())
-			edit(p_script, p_line, 0);
-	}
-
-	int selected = tab_container->get_current_tab();
-	if (selected < 0 || selected >= tab_container->get_child_count())
-		return;
+			int selected = tab_container->get_current_tab();
+			if (selected < 0 || selected >= tab_container->get_child_count())
+				return;
 
 
-	ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
-	if (!current)
-		return;
+			ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
+			if (!current)
+				return;
 
 
-	current->goto_line(p_line, true);
+			current->goto_line(p_line, true);
+		}
+	}
 }
 }
 
 
 void ScriptEditor::_update_history_arrows() {
 void ScriptEditor::_update_history_arrows() {

+ 6 - 1
modules/mono/editor/godotsharp_editor.cpp

@@ -151,7 +151,7 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int
 
 
 			if (p_line >= 0) {
 			if (p_line >= 0) {
 				args.push_back("-g");
 				args.push_back("-g");
-				args.push_back(script_path + ":" + itos(p_line) + ":" + itos(p_col));
+				args.push_back(script_path + ":" + itos(p_line + 1) + ":" + itos(p_col));
 			} else {
 			} else {
 				args.push_back(script_path);
 				args.push_back(script_path);
 			}
 			}
@@ -170,6 +170,11 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int
 				monodevel_instance = memnew(MonoDevelopInstance(GodotSharpDirs::get_project_sln_path()));
 				monodevel_instance = memnew(MonoDevelopInstance(GodotSharpDirs::get_project_sln_path()));
 
 
 			String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
 			String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
+
+			if (p_line >= 0) {
+				script_path += ";" + itos(p_line + 1) + ";" + itos(p_col);
+			}
+
 			monodevel_instance->execute(script_path);
 			monodevel_instance->execute(script_path);
 		} break;
 		} break;
 		default:
 		default: