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

Add a command to write recommended settings to the users User Settings for Dart #1302

Closed
mit-mit opened this issue Nov 14, 2018 · 8 comments
Closed
Milestone

Comments

@mit-mit
Copy link
Contributor

mit-mit commented Nov 14, 2018

Start with the following code:

class CircularButton extends StatelessWidget {
  final Widget text;
  final VoidCallback onPressed;

  const CircularButton({this.text, this.onPressed});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: RaisedButton(
        shape: CircleBorder(side: BorderSide(color: Colors.blue, width: 2)),
        child: text,
        onPressed: onPressed,
      ),
    );
  }
}

Next, place the cursor on RaisedButton
Invoke refactoring (option-enter).
Select 'Wrap with new widget'

=>

The code is oddly formatted; I would expect child: RaisedButton( to be indented two positions in from child: widget(, but it's 8 positions in.

Second, when I attempt to type a widget name, say SizedBox, in the widget placeholder text I get no code completion.

@DanTup DanTup added this to the v2.21.0 milestone Nov 14, 2018
@DanTup DanTup added is bug in editor Relates to code editing or language features labels Nov 14, 2018
@DanTup
Copy link
Member

DanTup commented Nov 14, 2018

The code is oddly formatted

This appears to be the same issue as microsoft/vscode#44200. Frustratingly, it seems like this is finally getting a fix (microsoft/vscode#57093) but only for completions - yet the issue seems to affect general text edits. I'll open an issue in VS Code about this.

Second, when I attempt to type a widget name, say SizedBox, in the widget placeholder text I get no code completion.

If you press Ctrl+Space does the completion work correctly (it seems to for me)? The snippet mode (where you can tab between placeholders, etc.) is controlled by VS Code and I'm not sure if we can force completion open automatically (but I'll do a little more digging).

@mit-mit
Copy link
Contributor Author

mit-mit commented Nov 14, 2018

If you press Ctrl+Space does the completion work correctly (it seems to for me)?

Yes, when I press that I see a 'loading' message for few seconds, and then the completions.

The weird thing is, if I after doing the refactor move the cursor out of widget, back into widget, delete widget and then start typing, then I get the expected immediate completion behavoir...

@DanTup
Copy link
Member

DanTup commented Nov 14, 2018

I've opened microsoft/vscode#63129 about the indenting - seems to be an issue with SnippetStrings rather than general edits.

The weird thing is, if I after doing the refactor move the cursor out of widget, back into widget, delete widget and then start typing, then I get the expected immediate completion behavoir...

Yeah, that's because it exits snippet mode (when it's in snippet mode, you'll see a box around the word widget.

I managed to find this:

microsoft/vscode#57153

It seems that you can disable this with a VS Code setting:

"editor.suggest.snippetsPreventQuickSuggestions": false

In my quick testing, this seems to solve the issue. Give it a test and see what you think. If we think it works well, we could add it to the Recommended Settings page (which I'm thinking of - at some point - showing a one-time notification to point people at).

@mit-mit
Copy link
Contributor Author

mit-mit commented Nov 14, 2018

Yeah, that works a lot better!

Is it not possible to set settings like this programmatically for .dart files?

@DanTup
Copy link
Member

DanTup commented Nov 14, 2018

Is it not possible to set settings like this programmatically for .dart files?

It is, though I'm not too keen on the idea of changing VS Code defaults just for Dart, since it means people using VS Code for other languages will have inconsistencies they might not understand (it also feels a bit aggressive for us to change their settings, even if it is just for Dart). That's why I started the recommended settings page - to try and draw attention to what I generally consider bad VS Code defaults, and allow users to read the descriptions and pick which ones they want.

I don't feel strongly though, my opinion would be swayed, but I'd want to be fairly sure users wouldn't object. We'd also need to figure out when to set them (since ideally we'd write them into their settings file so they can see what we've done, but we don't want to put them back in if the user deleted them).

@DanTup DanTup changed the title Missing completions and bad formatting after 'wrap' refactoring Consider automatically applying some recommended settings to Dart files Nov 15, 2018
@DanTup DanTup modified the milestones: v2.21.0, On Deck Nov 15, 2018
@DanTup DanTup added is enhancement and removed in editor Relates to code editing or language features is bug labels Nov 15, 2018
@DanTup DanTup modified the milestones: On Deck, v3.4.0 Aug 8, 2019
@DanTup
Copy link
Member

DanTup commented Aug 8, 2019

This came up again in the context of completion improvements - when we're sorting the most relevant to the top of the list and VS Code jumps halfway down the list to "the last thing you typed" it just looks buggy.

My main concern with changing these in configurationDefaults (where we set indenting, for ex.) is that if the user tries to set their own value in the VS Code settings editor, they appear to just "not work" (because language-specific defaults from an extension are higher priority than user-specified non-language-specific settings).

As a possible workaround, we could prompt the user the first time, asking if they want to use our recommended settings - and if so, write them explicitly into their settings (instead of using defaults). That way it's opt-in, the user has visibility of what we set, and if they decide to change them they're all visible in their settings without having to worry about the "hidden Dart defaults" they'd need to override).

@DanTup DanTup changed the title Consider automatically applying some recommended settings to Dart files Offer to write recommended settings to the users User Settings for Dart Aug 8, 2019
@DanTup
Copy link
Member

DanTup commented Aug 26, 2019

Re-purposing this to add a command so that we can get feedback on the settings before encouraging all users. The command is Dart: Use Recommended Settings.

I've opened #1946 to add a show-once prompt that will run the command for you in the next version. I'll try to encourage people to use it and provide feedback in the release notes.

The settings it will write are the ones from https://dartcode.org/docs/recommended-settings/ inside the "[dart]" section.

@DanTup DanTup changed the title Offer to write recommended settings to the users User Settings for Dart Add a command to write recommended settings to the users User Settings for Dart Aug 26, 2019
@DanTup
Copy link
Member

DanTup commented Aug 26, 2019

Hmmm, apparently the issue I opened is now a 404 🤷‍♂️ I've re-opened it and it got the same issue number 🤔

#1946

@DanTup DanTup closed this as completed in 69a472f Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants