godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.83k stars 21.14k forks source link

Autocompletion in array indices in 4.x is worse than in 3.x #76955

Closed 451507056 closed 2 months ago

451507056 commented 1 year ago

Godot version

4.0.2.stable

System information

windows10,gtx1050ti

Issue description

The bracket code prompt is not as good as it used to be.

Steps to reproduce

3 5 1 4 0 2 It was OK in 3.5.1, but not after 4.0.

Minimal reproduction project

none

ajreckof commented 1 year ago

It should be fixed by #75746.

PS: not 100% sure because there is no MRP

HolonProduction commented 1 year ago

Can still reproduce this in 4.1.stable

Calinou commented 1 year ago

Can still reproduce this in 4.1.stable

Can you post a code sample that reproduces the issue? Does it occur in a blank project with no other scripts and no open scene?

HolonProduction commented 1 year ago

Yes. Just a script without anything else:

var outside = 2

func _ready():
    var inside = 1

    var k = {}
    k[]

When typing inside of the brackets inside and outside are not proposed.

Some inside information: The completion type of the completion context is COMPLETION_SUBSCRIPT. This case only searchs inside properties of the class on which the subscript appears (here an dictionary). It does not search for local identifiers. The case seems to be written for the . syntax which is also packed into the subscript node but has its own completion type (COMPLETION_ATTRIBUTE). I will propably try to add new behaviour for this tomorrow.

451507056 commented 1 year ago

bbb aaa.zip I ran a test and the problem persisted.

hsandt commented 2 months ago

When trying to access an enum stored in a pure class such as:

class_name HeroEnums

enum HeroType {
    SPEED,
    FLY,
    POWER,
}

and then accessing this from another script, the first level autocomplete fails: heroes[HeroEn...] will not autocomplete

but the second level autocomplete will work: heroes[HeroEnums.HeroTy...] will autocomplete.

I'll ask on the PR if this is fixed too.