Repository: godotengine/godot (language: cpp)

Issue:
Ctrl-Click on enum value/member does nothing
### Tested versions

- reproducible in: 4.4.dev7
- reproducible on master (tested with a 03-Jan-2025 build - `v4.4.dev.gh-101012 [c37ada786]`)
- works in: 4.4.dev6


### System information

Godot v4.4.dev7 - Windows 11 (build 22631) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.6636) - 13th Gen Intel(R) Core(TM) i7-13700KF (24 threads)

### Issue description

I mentioned this here: https://github.com/godotengine/godot/issues/100680#issuecomment-2557966392
While general control-click was restored with https://github.com/godotengine/godot/pull/100707 the enum issue remains.

CTRL-clicking on an enum value/member does nothing (well, it actually navigates to the beginning of the line).

E.g. enum like this:
```
class_name E extends Object

enum Team {
	None,
	One,
}

func test():
	var t = E.Team.None
```
and CTRL-clicking on the `None` of `E.Team.None` does not take you to the `None` under `enum Team`.


### Steps to reproduce

Open enum.gd in MRP - same code as in description.

### Minimal reproduction project (MRP)

[44dev7enum.zip](https://github.com/user-attachments/files/18303044/44dev7enum.zip)



Discussion / hints:
Hi, I was looking at your bug and messing around, and some very weird things were happening ... here's a video in 4.4.dev7. 

https://github.com/user-attachments/assets/90ab71d5-b7aa-428e-b8d5-bb237c101167

It seems that changing the class's documentation updates something and it suddenly works.

I couldn't reproduce this behavior at all in master ... it just goes to the class's documentation page.
> Hi, I was looking at your bug and messing around, and some very weird things were happening ... here's a video in 4.4.dev7. https://github.com/user-attachments/assets/90ab71d5-b7aa-428e-b8d5-bb237c101167
> 
> It seems that changing the class's documentation updates something and it suddenly works.
> 
> I couldn't reproduce this behavior at all in master ... it just goes to the class's documentation page.

Yes, ctrl-click change https://github.com/godotengine/godot/pull/100707 went into master after dev7.

Okay that makes sense but still that behavior where adding documentation effects Ctrl+click is very weird... can you reproduce it on your computer?

Fix patch:
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index cccfff6a8449..062d522b6818 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -3956,10 +3956,14 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
 						} else {
 							const int dot_pos = doc_enum_name.rfind_char('.');
 							if (dot_pos >= 0) {
+								Error err = OK;
 								r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
-								r_result.class_name = doc_enum_name.left(dot_pos);
-								r_result.class_member = p_symbol;
 								if (base_type.class_type != nullptr) {
+									// For script enums the value isn't accessible as class constant so we need the full enum name.
+									r_result.class_name = doc_enum_name;
+									r_result.class_member = p_symbol;
+									r_result.script = GDScriptCache::get_shallow_script(base_type.script_path, err);
+									r_result.script_path = base_type.script_path;
 									const String enum_name = doc_enum_name.substr(dot_pos + 1);
 									if (base_type.class_type->has_member(enum_name)) {
 										const GDScriptParser::ClassNode::Member member = base_type.class_type->get_member(enum_name);
@@ -3972,8 +3976,19 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
 											}
 										}
 									}
+								} else if (base_type.script_type.is_valid()) {
+									// For script enums the value isn't accessible as class constant so we need the full enum name.
+									r_result.class_name = doc_enum_name;
+									r_result.class_member = p_symbol;
+									r_result.script = base_type.script_type;
+									r_result.script_path = base_type.script_path;
+									// TODO: Find a way to obtain enum value location for a script
+									r_result.location = base_type.script_type->get_member_line(doc_enum_name.substr(dot_pos + 1));
+								} else {
+									r_result.class_name = doc_enum_name.left(dot_pos);
+									r_result.class_member = p_symbol;
 								}
-								return OK;
+								return err;
 							}
 						}
 					} else if (Variant::has_builtin_method(Variant::DICTIONARY, p_symbol)) {


Test patch: