godotengine / godot

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

LSP offers empty completions from other class variables in 3.5 #64658

Open rcorre opened 2 years ago

rcorre commented 2 years ago

Godot version

3.5.stable

System information

Linux 5.19.1-arch2-1

Issue description

After typing "var", the LSP seems to offer completions from other class variables, which then insert empty text when you select them.

I have a script that looks like this:

extends Node

# set from main menu
var turns_per_day := 3

func _ready() -> void:
    $TileMap/Player.set("turns_per_day", turns_per_day)

I'm now editing a script like this:

extends Button

var turns_<cursor is here>

func _pressed() -> void:
    get_tree().change_scene("res://scenes/game/Game.tscn")
    get_tree().connect("idle_frame")

Godot 3.4 does not offer any completions at the cursor. Godot 3.5 offers "turns_per_day". I'm using neovim's builtin LSP client with https://github.com/neovim/nvim-lspconfig.

35.log 34.log

I see that 3.5, but not 3.4, is returning this entry:

{      data = "res://scenes/game/Game.gd::turns_per_day",      insertText = "",      kind = 6,      label = "turns_per_day"    }

I doubt this should be returned (completing a variable name based on a variable name from another script doesn't make much sense), and insertText shouldn't be empty.

Steps to reproduce

  1. Open the attached example
  2. Open PlayButton.gd in an external editor configured to godot's LSP
  3. Under "extends Button", add a newline and type "var turns_"
  4. Note that the LSP offers the completion "turns_per_day" (which comes from Game.gd)
  5. Press (or whatever your "accept completion" button is)
  6. The text is wiped out

Minimal reproduction project

example.zip

rcorre commented 2 years ago

Godot 4 is not affected either. This seems specific to 3.5.

rcorre commented 2 years ago

I suspect the "empty text" issue is the same as https://github.com/godotengine/godot/issues/64666, but I'm not sure why it is offering completions from other classes.

HolonProduction commented 1 day ago

Godot 4 is not affected either. This seems specific to 3.5.

This should be closed or moved to the 3.x milestone then.

The unrelated suggestions are likely cause by the smart resolve lsp feature which can be turned off in the editor settings.

HolonProduction commented 23 hours ago

This is caused by the lsp falling back to the smart resolve feature for autocompletion (this should not happen). And I'm able to get this behaviour in 4.x as well.