Skip to content

Bug: "Go to definition" stops working for a file after it has been opened and closed #99

@math625f

Description

@math625f

PHPantom version

phpantom_lsp 0.7.

Installation method

Built from source

Operating system

Linux x86_64

Editor

VS Code

Bug description

I've run into an issue where "Go to Definition" works perfectly for a closed file, but if I open that file and then close it, the language server can no longer find it. It seems like sending a textDocument/didClose event makes the server forget the file's location.

Because VS Code frequently opens and closes files in the background (like when generating a quick "Peek" preview), this means definitions often break immediately after clicking them once. If I keep the target file open in a tab, everything works perfectly.

Steps to reproduce

  1. composer.json
{
    "name": "test/phpantom-bug",
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    }
}
  1. src/ClassB.php (The target we want to jump to)
<?php
namespace App;

class ClassB {
    public function doSomething() {
        return "Hello from Class B!";
    }
}
  1. src/ClassB.php (The file we are clicking from)
<?php
namespace App;

class ClassA {
    public function test() {
        $b = new ClassB();
        $b->doSomething();
    }
}
  1. Generate the composer autoload files so PHPantom can index them
  2. Open it in vscode, and try "go to definition" from A while B is open and closed.

Error output or panic trace


.phpantom.toml

Additional context

I'm using the recommended zsol.vscode-glspc extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions