Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript 2.0: Autocomplete doesn't work for function until restarting the editor #67740

Closed
nofacer opened this issue Oct 22, 2022 · 5 comments
Closed

Comments

@nofacer
Copy link

nofacer commented Oct 22, 2022

Godot version

4.0 beta3

System information

macos 12.6

Issue description

I've a custom class in addon folder. It has a func named with fetch_class_name. The auto-complete for this func not show up. After I close the IDE and reopen then it works as expected.

Steps to reproduce

Create gd script in res://addons/fsm/state.gd

extends Node
class_name State
@icon("res://addons/fsm/state_logo.svg")

var state_machine: StateMachine
var target

static func fetch_class_name() -> String:
	return "State"
	

func enter() -> void:
	print(666)


func update():
	pass


func exit():
	pass

In another script res://addons/fsm/state_machine.gd

extends Node
class_name StateMachine
@icon("res://addons/fsm/state_machine_logo.svg")

@export var init_state = NodePath()
@onready var _target_node: Node = get_parent() as Node
@onready var _states: Array[State] = []


var cur_state: State 
var _states_map: Dictionary = {}

func _ready():
	for child in get_children():
		if child.get_class() == State.fetch_class_name():
			_states.append(child)
	for state in _states:
		state.target = get_parent()
		state.state_machine = self
		_states_map[state.name] = state
	cur_state = get_node(init_state) as State
	cur_state.enter()


func _process(delta):
	pass

The auto completion doesn't work for State.fetch_class_name() and cur_state.enter()

Then close the IDE and reopen it.

It will work as expected

Minimal reproduction project

No response

@nofacer nofacer changed the title Auto-complete doesn't work for function until reopen IDE Auto-complete doesn't work for function until reopening IDE Oct 22, 2022
@nofacer nofacer changed the title Auto-complete doesn't work for function until reopening IDE [4.0, Universal] Auto-complete doesn't work for function until reopening IDE Oct 22, 2022
@nofacer nofacer changed the title [4.0, Universal] Auto-complete doesn't work for function until reopening IDE [4.0, beta3, Universal] Auto-complete doesn't work for function until reopening IDE Oct 22, 2022
@Calinou Calinou changed the title [4.0, beta3, Universal] Auto-complete doesn't work for function until reopening IDE GDScript 2.0: Autocomplete doesn't work for function until reopening IDE Oct 22, 2022
@Calinou Calinou changed the title GDScript 2.0: Autocomplete doesn't work for function until reopening IDE GDScript 2.0: Autocomplete doesn't work for function until restarting the editor Oct 22, 2022
@Calinou
Copy link
Member

Calinou commented Oct 22, 2022

Then close the IDE and reopen it.

To clarify, are you using the built-in script editor or an external editor?

@nofacer
Copy link
Author

nofacer commented Oct 23, 2022

@Calinou I'm using built-in script editor.

@Nickelvad
Copy link

Happens on v4.2.beta5 as well, using built-in editor.

@Jules5
Copy link

Jules5 commented Mar 4, 2024

Still happening on v4.2.1, this is a bit annoying.

@Calinou
Copy link
Member

Calinou commented Mar 5, 2024

Thanks for the report! Consolidating in #78074, as this is due to the same cause (cyclic reference).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants