summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-05-21 12:39:20 +0200
committerGitHub <noreply@github.com>2022-05-21 12:39:20 +0200
commitfaca2f34b81cb21517dfe638f845326b9b17546d (patch)
tree4d3bdd5599ebf4b7b3c72ce4ea8b14237feb2c78
parenta53434639fc69f02d6d94237bc581a8881f1900a (diff)
parent2eddc3776f24525b56dc19a13c4d1f955cfa8f09 (diff)
Merge pull request #61242 from snailrhymer/class-desc-select-fix-2
Fix class_desc_deselect handling of @GlobalScope.X links
-rw-r--r--editor/editor_help.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 77c4fc71a4..dba0864fcb 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -127,30 +127,35 @@ void EditorHelp::_class_desc_select(const String &p_select) {
if (table->has(link)) {
// Found in the current page.
class_desc->scroll_to_paragraph((*table)[link]);
- } else if (topic == "class_enum") {
- // Try to find the enum in @GlobalScope.
- const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
-
- for (int i = 0; i < cd.constants.size(); i++) {
- if (cd.constants[i].enumeration == link) {
- // Found in @GlobalScope.
- emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link);
- break;
+ } else {
+ // Look for link in @GlobalScope.
+ // Note that a link like @GlobalScope.enum_name will not be found in this section, only enum_name will be.
+ if (topic == "class_enum") {
+ const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
+
+ for (int i = 0; i < cd.constants.size(); i++) {
+ if (cd.constants[i].enumeration == link) {
+ // Found in @GlobalScope.
+ emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link);
+ return;
+ }
}
- }
- } else if (topic == "class_constant") {
- // Try to find the constant in @GlobalScope.
- const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
-
- for (int i = 0; i < cd.constants.size(); i++) {
- if (cd.constants[i].name == link) {
- // Found in @GlobalScope.
- emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link);
- break;
+ } else if (topic == "class_constant") {
+ const DocData::ClassDoc &cd = doc->class_list["@GlobalScope"];
+
+ for (int i = 0; i < cd.constants.size(); i++) {
+ if (cd.constants[i].name == link) {
+ // Found in @GlobalScope.
+ emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link);
+ return;
+ }
}
}
- } else if (link.contains(".")) {
- emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1));
+
+ if (link.contains(".")) {
+ int class_end = link.find(".");
+ emit_signal(SNAME("go_to_help"), topic + ":" + link.substr(0, class_end) + ":" + link.substr(class_end + 1, link.length()));
+ }
}
} else if (p_select.begins_with("http")) {
OS::get_singleton()->shell_open(p_select);