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

"Metals: Find text in dependency JAR files" does not seem to work #3726

Closed
spangaer opened this issue Mar 16, 2022 · 7 comments
Closed

"Metals: Find text in dependency JAR files" does not seem to work #3726

spangaer opened this issue Mar 16, 2022 · 7 comments
Labels
bug Something that is making a piece of functionality unusable

Comments

@spangaer
Copy link

Describe the bug

  1. launch command
  2. type .conf
  3. type buffer (well any word failed)

VSCode Metals log -> {"code":"Unknown","name":"Error (FileSystemError)"}

Expected behavior

Expect results 🤷‍♂️

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

v0.11.2

Extra context or search terms

No response

@spangaer
Copy link
Author

  • works in ext v1.11.1 + metals 0.11.0
  • works in ext v1.12.0 + metals 0.11.1
  • does not work in ext v1.13.0 + metals 0.11.2

Regression due to the virtual document change?

@dos65
Copy link
Member

dos65 commented Mar 16, 2022

@spangaer Thanks for reporting and for hint. Will look what is going wrong

@Arthurm1
Copy link
Contributor

@dos65 I can look at this tomorrow if you want. I didn't test this out when adding virtual docs

@tgodzik
Copy link
Contributor

tgodzik commented Mar 16, 2022

From what I checked the issue is when the jar is broken. Managed to reproduce it on the Metals repository. We could probably just add a Try somewhere to be sure.

@dos65
Copy link
Member

dos65 commented Mar 16, 2022

@Arthurm1 I took a look. It seems that it might be solved by introducing FileSystemProvider.

However, I think we need to do changes on server side too. There is an issue with preview text. Currently we extract it by reading a whole file on client side that wasn't optimal even with having files on disk. It would be better to extend protocol and send prepared preview-text from the server

@Arthurm1
Copy link
Contributor

@dos65 OK, but if you don't want to go that far - I think you can just change the VSCode side to use workspace.openTextDocument(uri) instead of reading the file directly...

async function toTopLevel(locations: Location[]): Promise<TopLevel[]> {
  const locationsByFile = new Map<string, Location[]>();

  for (const loc of locations) {
    const previous = locationsByFile.get(loc.uri) || [];
    locationsByFile.set(loc.uri, [...previous, loc]);
  }

  return await Promise.all(
    Array.from(locationsByFile, async ([filePath, locations]) => {
      const uri: Uri = Uri.parse(filePath);
      const document = await workspace.openTextDocument(uri);
      if (document) {
        const newPositions = locations.reduce((arr, location) => {
          const line = document.lineAt(location.range.start.line);
          const newPosition = new PositionInFile(
            location,
            uri,
            line.text.trimStart()
          );
          return [...arr, newPosition];
        }, [] as PositionInFile[]);
        return new TopLevel(newPositions, uri);
      } else return new TopLevel([] as PositionInFile[], uri);
    })
  );
}

@kpodsiad
Copy link
Member

Should be fixed in the scalameta/metals-vscode#918.
It can be checked using pre-release version - instruction how to switch to it is here.

That's said, I'll close this issue. If you will still have problems @spangaer don't hesitate with reopening this issue.

@kpodsiad kpodsiad added this to the Metals v0.11.3 milestone Apr 22, 2022
@kpodsiad kpodsiad added the bug Something that is making a piece of functionality unusable label Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable
Projects
None yet
Development

No branches or pull requests

5 participants