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

Color Preview in VSCode is fooled when using custom classes ending with "Colors". #2857

Closed
HosseinYousefi opened this issue Oct 8, 2020 · 1 comment
Labels
in editor Relates to code editing or language features in flutter Relates to running Flutter apps is bug
Milestone

Comments

@HosseinYousefi
Copy link

Describe the bug
If the name of the class finishes with Colors, VSCode shows a preview as if the class name was Colors. (see the screenshot)

To Reproduce
You can use this code:

import 'dart:ui';

class MyColors {
  static const red = Color(0xff00ff00);
}

class NoColorHere {
  static const red = Color(0xff00ff00);
}

void somefunction() {
  final someOtherColor = NoColorHere.red;
  final someColor = MyColors.red;
}

Expected behavior
Preferably it should show the actual color in all cases, but a quick fix could be to not show the color preview when the class is not "Colors".

Screenshots
Screenshot 2020-10-08 at 10 49 29

Versions (please complete the following information):

  • VS Code version: 1.49.3
  • Dart extension version: 3.15.0
  • Dart/Flutter SDK version: 2.8.4/Flutter 1.17.5
@DanTup DanTup added this to the v3.16.0 milestone Oct 8, 2020
@DanTup DanTup added in editor Relates to code editing or language features in flutter Relates to running Flutter apps labels Oct 8, 2020
@DanTup
Copy link
Member

DanTup commented Oct 8, 2020

I'll fix this to only allow Colors, though I don't think we can make this completely reliably (some colours may not be known statically, and you could also create your own Colors class too). In the future this may move into the server (with LSP), so perhaps it will be easier to make it more reliable there (that's #2167).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in flutter Relates to running Flutter apps is bug
Projects
None yet
Development

No branches or pull requests

2 participants