godotengine / godot

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

[3.x] Autocomplete of vars fails unless directly below and also if line previously had error #27424

Open chucklepie opened 5 years ago

chucklepie commented 5 years ago

Godot version: 3.1 64-bit

OS/device including version: Windows 10

Issue description: Autocomplete does not work

Steps to reproduce: Hello, New user here. Two autocomplete bugs that I encountered on using Godot for the first time, hampering my ability to learn and use the editor/language properly...

Autocomplete not working for instances

  1. Using latest 64-bit Windows 3.1 version standard edition download the 2D Kinematic demo (or simply use the code below)
  2. In the script, move the cursor to directly below line 11 where 'motion' variable is defined as Vector2D
  3. Type motion. and auto complete will present the correct list, e.g. find 'normalized()'
  4. Move cursor to bottom of script and repeat item 3. All you see are generic 'object' constants and methods and specific methods, e.g. 'normalized()' is not available

I saw a bug report for this from a while ago and said it was fixed, clearly not quite. This bug means you simply cannot use autocomplete and scripting (for new users) is trial and error.

Autocomplete fails to run at all after a fault is found, even after fault is cleared:

  1. Using the sample script place the cursor anywhere below the 'var motion=Vector2D()' line
  2. Type 'motion. ' then press enter. You will get an error message saying 'expected identifier' and the line turns brown.
  3. Go back to this line and remove the '.' then press '.' again and no autocomplete is shown
  4. Delete all the text to the start of the line and repeat 'motion.' and still autocomplete is not shown
  5. Delete all the line, then delete again to remove the line, and the error disappears and you can type again

i.e. once an error is found, even after you start editing the error, it never goes away and features such as autocomplete continue.

I have also found sometimes that even after removing a line, and retyping, autocomplete doesn't even give you any hints, you have to remove the line a couple of times and then eventually it works!

Sample code for player.gd is as below:

Minimal reproduction project:

extends KinematicBody2D

# This is a demo showing how KinematicBody2D
# move_and_slide works.

# Member variables
const MOTION_SPEED = 160 # Pixels/second

func _physics_process(delta):
    var motion = Vector2()

    if Input.is_action_pressed("move_up"):
        motion += Vector2(0, -1)
    if Input.is_action_pressed("move_bottom"):
        motion += Vector2(0, 1)
    if Input.is_action_pressed("move_left"):
        motion += Vector2(-1, 0)
    if Input.is_action_pressed("move_right"):
        motion += Vector2(1, 0)

    motion = motion.normalized() * MOTION_SPEED

    move_and_slide(motion)
Anutrix commented 5 years ago

Maybe you can split this into 2 issues. In my opinion, the issues are major wrt the editor. Thus, warranting their own issues.

Calinou commented 4 years ago

For the record, the second part of this issue is already being tracked in #33191.