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

Autocompletion doesn't work if other scene is opened #28008

Open
breakmt opened this issue Apr 14, 2019 · 5 comments
Open

Autocompletion doesn't work if other scene is opened #28008

breakmt opened this issue Apr 14, 2019 · 5 comments

Comments

@breakmt
Copy link

breakmt commented Apr 14, 2019

Godot version:
3.1 stable

OS/device including version:
Windows 7 x64

Steps to reproduce:

Prerequisite: 2 scenes, one of them should have at least one node

Ex.:

- Scene 1
	- Node
- Scene 2
  1. Create script for Scene 1,
  2. While Scene 1 tab is opened start typing $ / get_node(" in _ready

Intermediate result: autocompletion suggest you Node. Fine.

  1. Change scene tab to Scene 2,
  2. Repeat step 2

Result: no autocompletion list

Expected: autocompletion list with Node

Minimal reproduction project:
test14042019.zip

bug14042019

@KoBeWi
Copy link
Member

KoBeWi commented Apr 14, 2019

This is somewhat intended behavior. Node autocompletion works only for currently opened and only if there's a node in the scene that contains this script.

Although it should be possible to check all opened scenes to find a node with this script and then fail only when the script is used multiple times.

@YeldhamDev
Copy link
Member

@KoBeWi I wonder if there could be a way to make the editor warn about this? So people aren't caught off-guard.

@willnationsdev
Copy link
Contributor

willnationsdev commented Apr 14, 2019

To put it in perspective, it would be possible to make autocompletion for this work, but this is what it would involve...

  1. If you are in an expression that provides a value to a function parameter expecting a NodePath, or if you are in the constructor of a NodePath, or if you are writing out @" or @' (the beginnings of an '@'-based NodePath string), then we need to trigger NodePath autocompletion:

  2. Get the current script. Look up not just this script, but all scripts which derive it (since they also have this method).

  3. Look up the scenes in which those scripts are listed as dependencies in the editor, i.e. which scenes are those scripts in?

  4. Identify all nodes which have these scripts present. Collect all of their absolute NodePaths.

  5. Generate a flat list of all relative NodePaths from all of those nodes to every other node in each of those scenes. Then list all of those NodePaths in the autocompletion list.

Not only would this be ridiculously taxing to do the larger your project is (and probably resulting in some form of lag for the autocompletion list itself), it would also be far more confusing to the user who suddenly sees not just the NodePaths for the scene they are thinking of, but also the NodePaths for all scenes everywhere, for all nodes with that script or any of its derivatives, everywhere. lol It's....kinda crazy. XD

@willnationsdev
Copy link
Contributor

Well, now one idea I just thought of would be this: what if we made the editor cache which scripts' last-opened scene was? So, the autocompletion for any given script would be active not on the current scene, but on whatever scene most recently opened contained that script. This would confine the list to a single scene, wouldn't be very taxing, but would also help solve OP's problem. Eh? Sound like a possibility?

@KoBeWi
Copy link
Member

KoBeWi commented Aug 20, 2020

This is still valid in 3.2.3 rc3, although this sounds more like missing feature than a bug.

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