scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.07k stars 323 forks source link

Remove Go To Definition fallback behaviour #6641

Closed antonsviridov-src closed 1 month ago

antonsviridov-src commented 1 month ago

Describe the bug

In this screenshot I purposefully broke the project and then did "go to definition" on Version.

You can see several unrelated noisy suggestions, which aren't helpful at all.

image

Expected behavior

Frankly this fallback behaviour has never been useful. It either takes you to a completely unrelated location (often in javalib), or shows you tons of random options for commonly used names.

After using Metals exclusively for many years this is the one behaviour I never found to be useful, and it actively annoys me.

Instead it would be preferable for Metals to respond with no definition if it genuinely can't find one, and optionally try to self-diagnose (is the project compiling? are there semanticdb files missing? does presentation compiler knows what this thing is?)

Operating system

None

Editor/Extension

None

Version of Metals

v1.3.4

Extra context or search terms

go to definition, fallback

tgodzik commented 1 month ago

Thanks for reporting! I agree that currently it's not really useful unless the class name is quite specific, I would have to improve the heuristic a lot, which was on my mind, but never got around to it. I will see if I can do it soon, otherwise I will disable it.

tgodzik commented 1 month ago

Ok, I changed the fallback to only work when we can find an exact symbol https://github.com/scalameta/metals/pull/6642

This should reduce false positives to a minimum of few edge cases.

tgodzik commented 1 month ago

You should be able to test out the new behaviour in snapshot versions, but the heuristic will be a lot more strict now.