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

Inlay hints disappear after going to definition #60145

Closed
benthillerkus opened this issue Feb 15, 2025 · 7 comments
Closed

Inlay hints disappear after going to definition #60145

benthillerkus opened this issue Feb 15, 2025 · 7 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@benthillerkus
Copy link

When I open my project in VS Code I can see the type inlay hints, but as soon as I start doing stuff like go-to-definition the hints disappear.

Screen.Recording.2025-02-15.at.21.49.43.mov

Infodump

Workspace Environment
Dart Code extension: 3.104.0
Flutter extension: 3.104.0 (activated)

App: Visual Studio Code
App Host: desktop
Version: mac 1.97.2

Workspace type: Flutter (LSP) (Multiroot)
Workspace name: drank (Workspace)

Dart (3.7.0-323.0.dev): /Users/bent/.puro/shared/caches/010c8a806bccad64ab9972286b85dd24ca98441f/dart-sdk
Flutter (3.29.0): /Users/bent/.puro/envs/stable/flutter (macOS (darwin/macos))

Output from 'dart info'

/Users/bent/.puro/shared/caches/010c8a806bccad64ab9972286b85dd24ca98441f/dart-sdk/bin/dart info

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

General info

  • Dart 3.7.0-323.0.dev (dev) (Mon Jan 13 04:02:13 2025 -0800) on "macos_arm64"
  • on macos / Version 15.0.1 (Build 24A348)
  • locale is en-DE

Project info

  • sdk constraint: '3.7.0-323.0.dev'
  • dependencies: collection, fast_immutable_collections, flutter, flutter_hooks, focusable_control_builder, hooks_riverpod, logging, navigation_utils, sliver_tools, sqlite3, sqlite3_flutter_libs
  • dev_dependencies: custom_lint, flutter_lints, flutter_test, riverpod_lint

Process info

Memory CPU Elapsed time Command line
3 MB 0.0% 14:46 dart devtools --machine --allow-embedding --dtd-uri ws:/im78k0hnq94=
66 MB 0.0% 14:46 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.104.0
3 MB 0.0% 14:37 dart lib/custom_lint_client.dart ::1 55384
3 MB 0.0% 14:46 dart tooling-daemon --machine
30 MB 0.0% 14:45 flutter_tools.snapshot daemon
Output from 'flutter doctor'

/Users/bent/.puro/envs/stable/flutter/bin/flutter doctor -v

[✓] Flutter (Channel stable, 3.29.0, on macOS 15.0.1 24A348 darwin-arm64, locale en-DE) [661ms]
    • Flutter version 3.29.0 on channel stable at /Users/bent/.puro/envs/stable/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (5 days ago), 2025-02-10 12:48:41 -0800
    • Engine revision 010c8a806b
    • Dart version 3.7.0 (build 3.7.0-323.0.dev)
    • DevTools version 2.42.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [3.2s]
    • Android SDK at /Users/bent/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,456ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) [11ms]
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.1) [11ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.97.2) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.104.0

[✓] Connected device (2 available) [7.3s]
    • macOS (desktop)                 • macos                 • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin       • macOS 15.0.1 24A348 darwin-arm64

[✓] Network resources [919ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

dart_analyzer_diagnostics_report.json

@benthillerkus benthillerkus added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Feb 15, 2025
@bwilkerson
Copy link
Member

@DanTup

@DanTup
Copy link
Collaborator

DanTup commented Feb 16, 2025

@benthillerkus can you confirm what your inlay hint settings are? By default (for Dart) they are only shown while you are holding down the key combination, so it's expected that they're not there as standard. There was a bug in VS Code recently that could cause them to appear when they shouldn't after reloading the window.

If you have changed your settings deliverately so they usually show up all the time, can you confirm where you've set this? (it would probably need to be in the "[dart]" section to work). Thanks!

@benthillerkus
Copy link
Author

benthillerkus commented Feb 17, 2025

Wow, you're right; I somehow forgot that you can trigger them with a key combination. The key combination seems to work (and that it would initially show them anyways would be a VS Code bug).

I do have them set to on in my VS Code user profile settings, which seems to be the default. That they'd only show up with the key combination, which should be the behaviour of offUnlessPressed is weird.

After reading your comment I then added this

"[dart]": {
        ///....
        "editor.inlayHints.enabled": "on"
    },

to the Dart block of the settings -- which didn't change the behaviour.

Curiously when I added that block to my VS Code workspace settings block the behaviour seems to be correct. So somehow changing it in the user profile settings was being overridden, but changing it inside the workspace has the final say.

So I guess this is a VS Code bug?
What I don't understand is, does the Dart extension somehow internally override your setting, is that possible? Why do I need to explicitly enable this inside of a "[dart]" block / why is the 'global' / language independent setting that you can set via the GUI ignored?

@DanTup
Copy link
Collaborator

DanTup commented Feb 17, 2025

What I don't understand is, does the Dart extension somehow internally override your setting, is that possible?

The Dart extension sets a language-specific default. That means that our default (which is offUnlessPressed) will override the general default. Eg. if you have:

"editor.inlayHints.enabled": "on"

Then it will be overriden for Dart. However, if you set your own for Dart specifically:

"[dart]": {
  "editor.inlayHints.enabled": "on"
}

Then that should override our default. This should be the case for User or Workspace settings.

I did some testing, but was not able to reproduce what you're seeing. If I add:

"[dart]": {
  "editor.inlayHints.enabled": "on"
}

To my User Settings, then I see inlay hints always shown. Are you able to test this in a new project and see if you see the same behaviour there? Is it possible you had both a User and Workspace setting at the time you tested it, so the User Setting was ignored?

Why do I need to explicitly enable this inside of a "[dart]" block / why is the 'global' / language independent setting that you can set via the GUI ignored?

This is just how VS Code works. Language-specific settings (whether they're defaults contributed by an extension, or set by a user) always override any non-language-specific settings. While I don't think it's very obvious, I think it probably does make the most sense. In order to make this more discoverable (because they question has come up a few times), they did add a "Modified Elsewhere" tag in the settings editor that shows where it's being overridden (if you click on it, you'll get a popup like the one here):

Image

@benthillerkus
Copy link
Author

Oh, this is how that setting looks for me:

Image

Are you able to test this in a new project and see if you see the same behaviour there?

Yeah, same behaviour

Is it possible you had both a User and Workspace setting at the time you tested it, so the User Setting was ignored?

No, my workspace settings block was completely empty before

So I guess this is most likely a VS Code bug?

@DanTup
Copy link
Collaborator

DanTup commented Feb 17, 2025

So I guess this is most likely a VS Code bug?

It could be, although without knowing why you see a difference in your user settings, I'm not sure. I presume this has something to do with Profiles. Is it possible you have that setting set explicitly in your profile, so the change in User Settings was overridden by the profile (but the workspace settings are not)?

I don't use profiles much so I'm not sure how the settings in them interact, but it seems logical that Workspace Settings would override Profile Settings, which override User Settings - however the UI above isn't very clear to me (are you modifying User or Profile settings?).

I would check your profile settings (although I don't know how you'd do that) to see if it's being set there. If not, it may be worth opening a VS Code issue (and you're welcome to CC me if I might be able to help describe how Dart is configured or answer questions).

@benthillerkus
Copy link
Author

If you have a profile the user setting is the profile setting - atleast as far as I understand it.

I think I'll open an issue for VS Code later, ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

3 participants