summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index cb72af39ca..edf0b73356 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -433,7 +433,11 @@ ScriptEditor *ScriptEditor::script_editor = nullptr;
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
String val = EditorDebuggerNode::get_singleton()->get_var_value(p_text);
+ const int display_limit = 300;
if (!val.is_empty()) {
+ if (val.size() > display_limit) {
+ val = val.left(display_limit) + " [...] truncated!";
+ }
return p_text + ": " + val;
} else {
return String();
@@ -441,7 +445,7 @@ String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
}
void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
- if (bool(EDITOR_GET("text_editor/external/use_external_editor"))) {
+ if (external_editor_active) {
return;
}
@@ -544,7 +548,7 @@ void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_
}
state["breakpoints"] = breakpoints;
script_editor_cache->set_value(scr->get_path(), "state", state);
- EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, false);
+ EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, p_enabled);
}
}
@@ -1423,11 +1427,7 @@ void ScriptEditor::_menu_option(int p_option) {
path = path.get_slice("::", 0); // Show the scene instead.
}
- FileSystemDock *file_system_dock = FileSystemDock::get_singleton();
- file_system_dock->navigate_to_path(path);
- // Ensure that the FileSystem dock is visible.
- TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control();
- dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock));
+ FileSystemDock::get_singleton()->navigate_to_path(path);
}
} break;
case CLOSE_DOCS: {
@@ -2274,7 +2274,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
// Don't open dominant script if using an external editor.
bool use_external_editor =
- EDITOR_GET("text_editor/external/use_external_editor") ||
+ external_editor_active ||
(scr.is_valid() && scr->get_language()->overrides_external_editor());
use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts.
const bool open_dominant = EDITOR_GET("text_editor/behavior/files/open_dominant_script_on_scene_change");
@@ -2516,17 +2516,7 @@ void ScriptEditor::save_current_script() {
clear_docs_from_script(scr);
}
- if (resource->is_built_in()) {
- // If built-in script, save the scene instead.
- const String scene_path = resource->get_path().get_slice("::", 0);
- if (!scene_path.is_empty()) {
- Vector<String> scene_to_save;
- scene_to_save.push_back(scene_path);
- EditorNode::get_singleton()->save_scene_list(scene_to_save);
- }
- } else {
- EditorNode::get_singleton()->save_resource(resource);
- }
+ EditorNode::get_singleton()->save_resource(resource);
if (scr.is_valid()) {
update_docs_from_script(scr);
@@ -2534,7 +2524,7 @@ void ScriptEditor::save_current_script() {
}
void ScriptEditor::save_all_scripts() {
- Vector<String> scenes_to_save;
+ HashSet<String> scenes_to_save;
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
@@ -2583,7 +2573,7 @@ void ScriptEditor::save_all_scripts() {
// For built-in scripts, save their scenes instead.
const String scene_path = edited_res->get_path().get_slice("::", 0);
if (!scene_path.is_empty() && !scenes_to_save.has(scene_path)) {
- scenes_to_save.push_back(scene_path);
+ scenes_to_save.insert(scene_path);
}
}
}
@@ -2606,6 +2596,9 @@ void ScriptEditor::apply_scripts() const {
}
void ScriptEditor::reload_scripts(bool p_refresh_only) {
+ if (external_editor_active) {
+ return;
+ }
for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (!se) {
@@ -2773,6 +2766,7 @@ void ScriptEditor::_editor_settings_changed() {
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index");
+ external_editor_active = EDITOR_GET("text_editor/external/use_external_editor");
_update_members_overview_visibility();
_update_help_overview_visibility();
@@ -2969,7 +2963,7 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
}
for (int i = 0; i < files.size(); i++) {
- String file = files[i];
+ const String &file = files[i];
if (file.is_empty() || !FileAccess::exists(file)) {
continue;
}
@@ -3049,7 +3043,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
int num_tabs_before = tab_container->get_tab_count();
for (int i = 0; i < files.size(); i++) {
- String file = files[i];
+ const String &file = files[i];
if (file.is_empty() || !FileAccess::exists(file)) {
continue;
}
@@ -3569,7 +3563,7 @@ TypedArray<ScriptEditorBase> ScriptEditor::_get_open_script_editors() const {
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
// Don't open dominant script if using an external editor.
bool use_external_editor =
- EDITOR_GET("text_editor/external/use_external_editor") ||
+ external_editor_active ||
(p_script.is_valid() && p_script->get_language()->overrides_external_editor());
use_external_editor = use_external_editor && !(p_script.is_valid() && p_script->is_built_in()); // Ignore external editor for built-in scripts.
const bool open_dominant = EDITOR_GET("text_editor/behavior/files/open_dominant_script_on_scene_change");
@@ -3837,6 +3831,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
waiting_update_names = false;
pending_auto_reload = false;
auto_reload_running_scripts = true;
+ external_editor_active = false;
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index");
@@ -3967,8 +3962,8 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
_update_recent_scripts();
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KeyModifierMask::CMD_OR_CTRL | Key::S), FILE_SAVE);
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As..."), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::S), FILE_SAVE_AS);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KeyModifierMask::ALT | KeyModifierMask::CMD_OR_CTRL | Key::S), FILE_SAVE);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As...")), FILE_SAVE_AS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KeyModifierMask::SHIFT | KeyModifierMask::ALT | Key::S), FILE_SAVE_ALL);
ED_SHORTCUT_OVERRIDE("script_editor/save_all", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::S);
file_menu->get_popup()->add_separator();