Dart-code: Support automatically displaying signature information, when appropriate

Created on 3 Aug 2018  路  8Comments  路  Source: Dart-Code/Dart-Code

The new Signature Help feature triggers almost constantly, even when it doesn't make sense to, like inside of comments. Or the signature shown will be for something the next layer up.

Example code:

return ListTile(
  title: Text("Enable notifications"),
  trailing: Switch(
    value: notificationsEnabled,
    onChanged: (bool enabling){
      if (enabling) {
        // type this comma -> , and get the signature of Switch()
      } else {
        // ...
      }
    },
  ),
);
in editor in lsanalysis server is bug

All 8 comments

Ugh :(

I guess we should never trigger in comments, but maybe also limit how far up we walk trying to find an invocation. This is probably worse in Flutter because build methods tend to have a constructor invocation around huge chunks of code.

How bad does this seem? Fixing it is going to be in the SDK so I can patch in an option to turn this off, but is it bad enough that it should default to off until changes are made in the SDK and rolled into Flutter?

I can't say how frustrating it is for others, but in my case I frequently use split view, meaning a decent portion of one view is obscured.

As long as there's an option to disable the automatic triggers, I think that would be sufficient.

As long as there's an option to disable the automatic triggers, I think that would be sufficient.

Good call, I forgot there was both manual and automatic triggering. I'm gonna disable automatic triggering behind a setting for now (#1134) while we figure out how to make this more reliable. Ideally we want manual triggering to work when you're deeply nested, but not trigger automatically. This may mean returning some additional data from the server to allow us to know whether the provided info is for directly where the cursor is or further up the tree.

v2.17.1 is out and disables automatic triggering (there's a setting to turn it back on). I'll work on making this work better in vNext if possible (leaving this issue open to track that). If you still have any issues, let me know!

Opened https://github.com/dart-lang/sdk/issues/34241 to discuss the analyzer work. I'll work on this once there's a consensus on how best to implement.

(I'm re-purposing this issue as a request to enable auto-triggering, but a non-sucky version)

Working on this in the LSP server at: https://dart-review.googlesource.com/c/sdk/+/162000

If the request for signature info is from an automatic trigger when typing ( then we'll only return results if the ( is exactly the offset of the located ArgumentList. Comma is now just a "retrigger" character, so it will only ever trigger signature help if it's already visible (and therefore returning results will just update the UI and not trigger any new popups).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanTup picture DanTup  路  4Comments

DanTup picture DanTup  路  4Comments

e200 picture e200  路  3Comments

agmcleod picture agmcleod  路  3Comments

rajeshjeshar picture rajeshjeshar  路  4Comments