Repository: godot
Issue: The documentation for a class defined by the keyword 'class_name' does not appear when searching using the '(doc) Search Help'
Labels: bug,topic:gdscript,topic:editor

### Tested versions

Reproducible in : 4.2.stable

### System information

Godot v4.2.stable - Ubuntu 22.04.3 LTS 22.04 - X11 - Vulkan (Forward+) - dedicated Quadro M2000M (nvidia; 535.129.03) - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 Threads)

### Issue description

The documentation for a class defined by the keyword 'class_name' does not appear when searching using the 'Search Help (doc)' bar located in the Workspace Script in the top-right corner of the script editor.

This documentation appears in the search bar the first time the file is loaded or the first time Godot is opened after modifying the file. Subsequent times, the class documentation is no longer suggested in the search bar.

### Steps to reproduce

If you use the MRP (Minimal reproduction project), open the project and jump to the step 3.

1) Download the following repository :
git clone https://gitlab.com/Tomateauketchup/la-state-makina.git /tmp/la-state-makina

2) Create a new empty project with Godot as follows:
- Directory : /tmp/la-state-makina
- Name : la-state-makina

Set Version Control metadata to None.

(ignore the warnings saying that the directory is not empty)

3) Ignore the four errors associated with the following files:
 - unit_test_sm_clock.gd
 - unit_test_sm_clock.gd
 - unit_test_sm_json_serializer.gd
 - unit_test_sm_state_machine.gd
 
 If you want to resolve these errors, install the gdUnit4 asset.
 But this is not important and not needed to reproduce the bug.
 
4) Do not exit the Godot editor. Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

You should be able to open the SMStateMachine documentation, which should display correctly.
 
4 bis) (Optional) In the Godot editor, close all documentation, and scripts.
  
5) Quit the godot IDE.
 
6) Reopen the godot IDE.
 
If you didn't made the 4bis) operation, you should obtain the error :
"No loader found for resource: res://addons/la-state-makina/src/state_machine/sm_state_machine.gd (expected type: SMStateMachine)"
If you made the 4 bis) operation, you have no error.

7) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

The search toolbar should not suggest SMStateMachine.

This is a bug because we don't change anything in our project and the editor was able to display previously the documentation !
 
8) Quit the godot IDE.
 
9) Modify the source code with an external IDE (like vim) : 
 /tmp/la-state-makina/addons/la-state-makina/src/state_machine/sm_state_machine.gd
Add an empty line at the end of the file.

10) Reopen the godot IDE
 
11) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

Now, the search toolbar should suggest SMStateMachine, and you should be able to open the SMStateMachine documentation, which should display correctly.

11bis) (optional) In the Godot editor, close all scenes, documentation, and scripts.

12) Quit the godot IDE.
 
13) Reopen the godot IDE

If you didn't made the 11bis) operation, you should obtain the error :
"No loader found for resource: res://addons/la-state-makina/src/state_machine/sm_state_machine.gd (expected type: SMStateMachine)"
If you made the 11bis) operation, you have no error.

14) Click on "Script" in the Workspace. In the top-right corner of the script editor, click on "Search Help," and enter "SMStateMachine."

The search toolbar should no longer suggest SMStateMachine. 

This is a bug, the editor was able to display previously the documentation.

### Minimal reproduction project (MRP)

[la-state-makina.zip](https://github.com/godotengine/godot/files/13787006/la-state-makina.zip)