denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.48k stars 144 forks source link

Go to definition breaks for some newly imported modules #948

Closed syhol closed 7 months ago

syhol commented 1 year ago

(Edit) Turns out it's not just deno std lib and it's not just the difference between the versions as I've now had the issue with multiple modules inside the https://deno.land/x/lume@v1.19.0/ path.

I can't intentionally recreate this bug in a new environment and I've resolved it on my side, but I wanted to provide you with some data in case anyone runs into it again.

Describe the bug

cmd+click aka "go to definition" doesn't work as expected for some new symbols I pull into my project. In this case, it was https://deno.land/std@0.203.0.

cmd+hovering over the symbol shows type and docs, but cmd+click shows me the message:

The editor could not be opened due to an unexpected error: Unable to resolve resource https://deno.land/std%400.203.0/http/server.ts

The URL encoding of %40 instead of @ could be something dodgy.

Let me stress, that this issue affected whatever is the latest version of the Deno std lib for me over the last 24 hours:

I managed to resolve the issue by doing the following:

(Edit) See the comment below, it just needed a vscode restart in the end.

~1. deno cache --reload main.ts

  1. Deleting the project from my vscode recent project list
    image
  2. Close vscode
  3. Open the directory using the vscode cli code ./my-project~

~I'm not sure if 1 actually did anything to solve the issue because I did both 1 and 2 at the same time. It might be that the cache reload plus a vscode restart might have fixed it.~

To Reproduce

I can no longer reproduce this issue in a new project, but in the project that was affected I could recreate the issue like this:

import { Server as ServerV0_202_0 } from "https://deno.land/std@0.202.0/http/server.ts";
import { Server as ServerV0_203_0 } from "https://deno.land/std@0.203.0/http/server.ts";

const serverV0_202_0 = new ServerV0_202_0({});
const serverV0_203_0 = new ServerV0_203_0({});

Go to definition worked for ServerV0_202_0 but not ServerV0_203_0.

My .vscode/settings.json looked like this:

{
    "deno.enable": true,
    "deno.lint": true,
    "deno.unstable": true,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "denoland.vscode-deno",
    "[typescript]": {
      "editor.defaultFormatter": "denoland.vscode-deno"
    }
}

Expected behavior

The source file should open at the symbol requested.

Screenshots

(Edit) See screenshots in the comment below.

~Unfortunately, I fixed the issue and can no longer recreate it for screenshots but a VS Code error page popped up and said:~

~The editor could not be opened due to an unexpected error: Unable to resolve resource https://deno.land/std%400.202.0/http/server.ts~

Versions

vscode: v1.82.2 deno: v1.37.0 extension: v3.24.0

syhol commented 1 year ago

I just got it again with https://deno.land/x/lume@v1.19.0/ so it's not restricted to std.

First let's look at a module that works as expected "lume/plugins/base_path.ts"

Specifically the symbol import basePath from "lume/plugins/base_path.ts";

cmd+hovering over the symbol:

image

cmd+clicking on the symbol

image

Now let's look at a module that does NOT work as expected "lume/plugins/code_highlight.ts"

Specifically the symbol import codeHighlight from "lume/plugins/code_highlight.ts";:

cmd+hovering over the symbol:

image

cmd+clicking on the symbol

image

Fix

I restarted vscode and it fixed itself. Turns out that's all it needed. Still a bit annoying.

syhol commented 7 months ago

No action on this for about 5 months now so looks like it must have been something wrong with my setup. Closing.