-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[analyzer] Flutter project with packages inside breaks textDocument/definition and other navigation #51251
Comments
@DanTup - do you mind doing some investigation here to run down where the problem might be? |
@tupos I'm having trouble reproducing this. I'm on stable Flutter 3.7.1 and followed your steps. I still have the Flutter project open and the source for the Are you able to provide the complete log file from when the server starts to when this occurs? You can enable writing the log to disk by adding the following to your Workspace settings ( "dart.analyzerLogFile": "logs/analyzer.txt", Thanks! |
@DanTup From your screenshot I see that you use mac os. My original issue is on windows. Could you please try on windows as well? I definitely have an issue on windows, as when I was working yesterday evening the navigation was broken. %LOCALAPPDATA%\.dartServer
%LOCALAPPDATA%\Pub
%APPDATA%\Code
%USERPROFILE%\.vscode
<flutter_git_path>\flutter\bin\cache |
@tupos good spot. You're right, I can repro on Windows. My feeling is that it may be related to a mismatching of the casing of drive letters in paths: The open file has a lowercase drive letter and that doesn't match what the server is using, so I think it's failing to realise that this file should be analyzed in the context of the parent Flutter project, and is analyzed with the Dart one, which cannot resolve This is an issue that's come up before (#28895) and a complete fix is complicated, but there were some attempts to normalize drive letters to the same casing to avoid this - I'll see if I track down why that doesn't handle this case. |
@tupos is it possible you could test a fix for me using the pre-release version of the Dart extension? You can switch to the pre-release versions of the extensions in VS Code by going to the Extensions section, finding Dart and clicking the button shown in the screenshot below. The version with my change is v3.59.20230207. It might take 10-20 minutes to show up due to VS Code marketplace caching (edit: it has showed up and installed for me now). |
@DanTup So I installed the pre-release version of the dart extension and the navigation is working on windows as well. Thanks a lot for a quick fix. |
Great, thanks for confirming! Assuming no issues come up, it'll be included in the next stable release of the extension. If you hit any issues with the pre-release versions in the meantime, please file issues at https://github.com/Dart-Code/Dart-Code. |
Thanks a million, @DanTup !! |
I'm slightly less sure about this fix now. When investigating this, I had remembered that we'd always uppercased drive letters to avoid this issue, and while testing I saw this wasn't happening and thought VS Code's However, with a little more digging I found that the drive-letter-casing-normalisation was never happening for LSP, so it's likely this behaviour/bug has been around a long time. It's very possible that whether it occurs depends on some other factor outside of our control (for example, the casing of the drive letter in the I'm going to leave it in for now (since it improved things for both of us, and on my Windows 11 PC, I was unable to change the (@bwilkerson FYI... I've looked at this in the past and concluded it's rather tricky - not just technically, because also because the rules for LSP are not clearly defined and VS Code (incorrectly) bases case-sensitivity decisions on platform and not the actual case-sensitivity of the platform (although I expect in the large majority of cases this works out correct). |
Editor is VSCode with Dart and Flutter extensions 3.58.0
To reproduce the issue
Open
lib/main.dart
and insideMyApp::build
add prior to returnJump to definition
TextFormField()
. Inside constructor definition it is possible to jump to definition of any type.Now being in
test
folder create packageRestart dart analysis server by F1 -> Dart: Restart Analysis Server. The jump to definition is completely broken for many types like
If now the
test_package
is removed from thetest
project and language server is restarted the navigation is working again.Inside the logs I can only see
and
The text was updated successfully, but these errors were encountered: