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

Allow void to be coloured like a type #3308

Closed
tjx666 opened this issue Apr 28, 2021 · 7 comments
Closed

Allow void to be coloured like a type #3308

tjx666 opened this issue Apr 28, 2021 · 7 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Milestone

Comments

@tjx666
Copy link

tjx666 commented Apr 28, 2021

image

@tjx666 tjx666 added the is bug label Apr 28, 2021
@UmairJibran
Copy link

according to the latest version of the file, void and var are categorized as preemptive type, const has been moved to modifier and the String is highlighted as a normal class.

@UmairJibran
Copy link

However, I have created a pull request with the requested changes, let's see if they accept it or not.

@DanTup
Copy link
Member

DanTup commented May 3, 2021

Sorry for the delay! I think void is is a little different to a normal type (for example there are places where you cannot put void but could put a type). I'm not sure if colouring it like a type is more correct than as a keyword, and some people may prefer it as is (I do - I like being able to see void at a glance and know whether a function is returning a value or not).

If there's demand for being able to colour it like a type, perhaps it would be better to add a modifier to the semantic token so that it can be customised?

@UmairJibran I'll comment on the PR about your change - I'm not sure I entirely understand the goal - although I will note that if we do make changes here, they should also be reflected in LSP semantic tokens, otherwise you'll see them load as one colour, and then change to another colour once the semantic tokens arrive.

@nbros
Copy link

nbros commented May 4, 2021

I know void is a type in Dart but I still see it as the absence of a type, so I like it colored this way too (like a keyword).

@tjx666
Copy link
Author

tjx666 commented May 6, 2021

I see that void is colorized as type in typescript file.

image

@DanTup
Copy link
Member

DanTup commented May 7, 2021

@tjx666 I think there are valid arguments for colouring it both ways. Given at least some people prefer it to be coloured like a keyword and that's what people are already used to, I think any change should be opt-in.

Adding a semantic token modifier will allow anyone who wants it to be coloured like a type to change its colour, and the default would remain as-is.

@DanTup DanTup added this to the v3.23.0 milestone May 7, 2021
@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement and removed is bug labels May 7, 2021
@DanTup DanTup changed the title void is a type but syntax highlight is colorized like a keyword Allow void to be coloured like a type May 7, 2021
@DanTup DanTup modified the milestones: v3.23.0, On Deck May 7, 2021
@DanTup DanTup modified the milestones: On Deck, v3.24.0 May 24, 2021
dart-bot pushed a commit to dart-lang/sdk that referenced this issue Jun 9, 2021
Fixes Dart-Code/Dart-Code#3308.

Change-Id: I2395caa7b52fe690621cb31d87136f236f0efed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202965
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Jun 10, 2021

I landed a change in the SDK in dart-lang/sdk@3690f54 that adds a void modifier to the keyword token, so it's now possible to customise the colour of the void keyword in your VS Code settings:

"editor.semanticTokenColorCustomizations": {
	"rules": {
		"keyword.void": {
			"foreground": "#ffff99",
			"fontStyle": "underline"
		}
	}
},

Screenshot 2021-06-10 at 09 52 11

By default void will remain coloured as a keyword, but you're now able to reliably customise it. Unfortunately I don't know a way with VS Code's customisations to map it to another colour so you'll have to put the colour in explicitly. You can find out what your class colour is with the Inspect Editor Tokens and Scopes command and then selected an existing class name and it should show the hex value:

Screenshot 2021-06-10 at 09 53 26

Note: This change is in the SDK, so you may not see it until a future Dart/SDK update (although for testing, it's already in the bleeding-edge Dart builds - ofc they're not recommended for production).

@DanTup DanTup closed this as completed Jun 10, 2021
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 lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Projects
None yet
Development

No branches or pull requests

4 participants