question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Many irrelevant suggestions appear, and they may be autoselected by default, when using optional parameters

See original GitHub issue

peek 2019-01-05 17-19

Here, I created a Flutter stateless widget with the stless snippet, and after typing appBar: the first suggestion is stless and I have to scroll all the way up to see the AppBar() suggestion.

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: ,
    );
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Jan 8, 2019

Suggestions 2-6 shouldn’t appear unless they’re of type Decoration or return a Decoration.

It’s often valid to type these items, because you could be writing something like:

Container(
  decoration: new MyThing().theDecoration,
)

or

Container(
  decoration: SomeClass.myInstance["thing"],
)

Snippets are also always valid, because their contents could contain anything (for example you could have a snippet of code that returns a decoration).

The completion options actually from from the SDK so any changes would need to be made there (though based on the above, I don’t think the things you want to go away will). They are sorted by a rank, however, so it’s possible that could be tuned if there are items that should be at the top that are appearing down the list.

As a result of this, VSCode selects an irrelevant suggestion by default because of the default value of editor.suggestSelection

Unfortunately VS code has many defaults that result in quirks like this (which is why I’ve started collecting them in the recommended settings page, which we may point users at in the future). The issue isn’t isolated to Dart, TypeScript has exactly the same thing:

screenshot 2019-01-08 at 8 38 51 am

If you think the default in VS Code should be changed, you could open an issue in the VS Code repo (I’d certainly 👍 it if you post the link here - it makes me sad that we need to document all the “bad” defaults for reasons like this).

0reactions
DanTupcommented, Jan 15, 2019

I’ve added this to the recommended settings page but I don’t think there’s anything more I can do here. Even the TypeScript extension has had the same issue reported, and the fix is to modify the setting. I agree this isn’t great, but I don’t want to override peoples settings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with Optional Parameters in Go | by Peter Malina
Legend says Go does not support optional parameters or method overloading, as it may be confusing or fragile in practice. However, there are...
Read more >
Optional Parameters in Go? - Stack Overflow
Go doesn't support optional parameters , default values and function overloading but you can use some tricks to implement the same.
Read more >
Named and Optional Arguments - C# Programming Guide
Named arguments in C# specify arguments by name, not position. Optional arguments can be omitted.
Read more >
Create a Query Suggestions index for InstantSearch.js - Algolia
By default, the Query Suggestions builder indexes all popular searches that meet the default configuration values as suggestions. Without ...
Read more >
Using Python Optional Arguments When Defining Functions
In this tutorial, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found