summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_text_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/script_text_editor.cpp')
-rw-r--r--editor/plugins/script_text_editor.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index eb934da4dd..d8fb55ca54 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -36,10 +36,10 @@
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
-#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_toaster.h"
+#include "editor/themes/editor_scale.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/split_container.h"
@@ -146,6 +146,7 @@ void ScriptTextEditor::set_edited_resource(const Ref<Resource> &p_res) {
ERR_FAIL_COND(p_res.is_null());
script = p_res;
+ script->connect_changed(callable_mp((ScriptEditorBase *)this, &ScriptEditorBase::reload_text));
code_editor->get_text_editor()->set_text(script->get_source_code());
code_editor->get_text_editor()->clear_undo_history();
@@ -788,9 +789,7 @@ static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_curr
}
void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_for_script) {
- if (!bool(EDITOR_GET("text_editor/external/use_external_editor"))) {
- return;
- }
+ bool use_external_editor = bool(EDITOR_GET("text_editor/external/use_external_editor"));
ERR_FAIL_NULL(get_tree());
@@ -804,6 +803,10 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
for (const Ref<Script> &E : scripts) {
Ref<Script> scr = E;
+ if (!use_external_editor && !scr->get_language()->overrides_external_editor()) {
+ continue; // We're not using an external editor for this script.
+ }
+
if (p_for_script.is_valid() && p_for_script != scr) {
continue;
}
@@ -822,7 +825,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
scr->set_last_modified_time(rel_scr->get_last_modified_time());
scr->update_exports();
- trigger_live_script_reload();
+ trigger_live_script_reload(scr->get_path());
}
}
}
@@ -884,7 +887,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
_edit_option(breakpoints_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx));
- code_editor->get_text_editor()->call_deferred(SNAME("center_viewport_to_caret")); //Need to be deferred, because goto uses call_deferred().
+ callable_mp((TextEdit *)code_editor->get_text_editor(), &TextEdit::center_viewport_to_caret).call_deferred(0); // Needs to be deferred, because goto uses call_deferred().
}
}
@@ -1271,27 +1274,27 @@ void ScriptTextEditor::_edit_option(int p_op) {
switch (p_op) {
case EDIT_UNDO: {
tx->undo();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_REDO: {
tx->redo();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_CUT: {
tx->cut();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_COPY: {
tx->copy();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_PASTE: {
tx->paste();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_SELECT_ALL: {
tx->select_all();
- tx->call_deferred(SNAME("grab_focus"));
+ callable_mp((Control *)tx, &Control::grab_focus).call_deferred();
} break;
case EDIT_MOVE_LINE_UP: {
code_editor->move_lines_up();
@@ -1409,7 +1412,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
PackedStringArray results;
for (int i = 0; i < lines.size(); i++) {
- String line = lines[i];
+ const String &line = lines[i];
String whitespace = line.substr(0, line.size() - line.strip_edges(true, false).size()); // Extract the whitespace at the beginning.
if (expression.parse(line) == OK) {
Variant result = expression.execute(Array(), Variant(), false, true);
@@ -2447,7 +2450,7 @@ void ScriptTextEditor::register_editor() {
ED_SHORTCUT("script_text_editor/indent", TTR("Indent"), Key::NONE);
ED_SHORTCUT("script_text_editor/unindent", TTR("Unindent"), KeyModifierMask::SHIFT | Key::TAB);
- ED_SHORTCUT_ARRAY("script_text_editor/toggle_comment", TTR("Toggle Comment"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::K), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::SLASH) });
+ ED_SHORTCUT_ARRAY("script_text_editor/toggle_comment", TTR("Toggle Comment"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::K), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::SLASH), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_DIVIDE), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::NUMBERSIGN) });
ED_SHORTCUT("script_text_editor/toggle_fold_line", TTR("Fold/Unfold Line"), KeyModifierMask::ALT | Key::F);
ED_SHORTCUT_OVERRIDE("script_text_editor/toggle_fold_line", "macos", KeyModifierMask::CTRL | KeyModifierMask::META | Key::F);
ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), Key::NONE);
@@ -2505,5 +2508,5 @@ void ScriptTextEditor::register_editor() {
}
void ScriptTextEditor::validate() {
- this->code_editor->validate_script();
+ code_editor->validate_script();
}