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

[VSCode] Metals is generating files on click the extension view, even if I'm not in a Scala project #1439

Open
RaniAgus opened this issue Nov 29, 2023 · 8 comments

Comments

@RaniAgus
Copy link

Describe the bug

I opened VSCode in an Angular application and accidentally clicked Metals tab. There are two files that got generated and they shouldn't because I'm not in a Scala project and I din't click the "Start Metals" button.

image

image

Expected behavior

No files should be generated

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

v1.1.0

Extra context or search terms

2023.11.29 09:13:21 INFO  Started: Metals version 1.1.0 in folders 'xxxxxx' for client Visual Studio Code 1.84.2.
2023.11.29 09:13:22 WARN  Build server is not auto-connectable.
2023.11.29 09:13:22 WARN  no build tool detected in workspace 'xxxxxx'. The most common cause for this problem is that the editor was opened in the wrong working directory, for example if you use sbt then the workspace directory should contain build.sbt. 
@RaniAgus RaniAgus changed the title Metals is generating files even outside Scala project Metals is generating files even if I'm not in a Scala project Nov 29, 2023
@RaniAgus RaniAgus changed the title Metals is generating files even if I'm not in a Scala project [VSCode] Metals is generating files even if I'm not in a Scala project Nov 29, 2023
@tgodzik
Copy link
Contributor

tgodzik commented Nov 29, 2023

Thanks for reporting! This is the default behaviour of VS Code currently. When the tab is opened, VS Code will start the extension responsible for that tab :/ We don't define it ourselves.

There is even a note about the change https://code.visualstudio.com/api/references/activation-events#onView

@tgodzik
Copy link
Contributor

tgodzik commented Nov 29, 2023

We might be able not work around it, but not sure currently how to do it.

@tgodzik tgodzik transferred this issue from scalameta/metals Nov 29, 2023
@kasiaMarek
Copy link
Contributor

kasiaMarek commented Nov 29, 2023

This will get automatically resolved if we add single files support scalameta/metals#5531.

@RaniAgus
Copy link
Author

@tanishiking
Copy link
Member

tanishiking commented Nov 30, 2023

There could be 2 solutions regarding the issue if #1439 (comment) didn't work, my 2 cents :)
I think writing log files into tmp dir would be ok, but I believe (2) is nicer + Metals still has some usage for .metals (should we use /tmp for those purposes too? e.g. swtich-build-server setting, I don't think so, but we may workaround by store the setting on client-side).

@tanishiking tanishiking changed the title [VSCode] Metals is generating files even if I'm not in a Scala project [VSCode] Metals is generating files on click the extension view, even if I'm not in a Scala project Nov 30, 2023
@anatoliykmetyuk
Copy link

anatoliykmetyuk commented Dec 13, 2023

Could a solution be to check if the current folder contains files like *.sbt, *.scala or *.sc before creating the .metals directory?

@tgodzik
Copy link
Contributor

tgodzik commented Dec 13, 2023

Probably something like that, basically duplicating the activation triggers, which we defined :/

@YSMull
Copy link

YSMull commented Mar 15, 2024

The problem was so severe that if the file he generated was deleted, it would be immediately regenerated, which was devastating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants