JohnnyMorganz / luau-lsp

Language Server Implementation for Luau
MIT License
245 stars 59 forks source link

No autocompletion of uses of upvalues not at top level on lines created after sourcemap regeneration with project path using `..` #645

Closed Ketasaja closed 4 months ago

Ketasaja commented 5 months ago

Reproduction for post-1.29.1 0ebfa54: luau-lsp_#645_reproduction.zip

  1. Open project in VS Code.
  2. aftman install.
  3. In server/code/init.lua, on line 2, start typing autocomplete. #645_working
  4. Delete what you typed.
  5. Insert at least two new lines within the function after line 2.
  6. Start typing autocomplete again. #645_not_working
  7. Delete what you typed.
  8. Save the file.
  9. Start typing autocomplete again. #645_working_again

sourcemap.json:

{
  "emitLegacyScripts": false,
  "name": "Reproduction",
  "tree": {
    "$className": "DataModel",

    "ServerScriptService": {
      "server": {
        "$path": "directory/../server"
      }
    }
  }
}
JohnnyMorganz commented 4 months ago

The underlying cause seems to be the interesting sourcemap, where the filepath for code is stored as "directory/../server\\code\\init.luau. This causes us to fail to match the "real path" of this file with the path that VSCode understands (because we don't normalise it correctly). That is a bug, thanks for the report!

Curious why your project.json is configured to do it like this, seems odd.