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

Scope theme colors don't update #2

Closed
vanowm opened this issue Oct 4, 2022 · 19 comments
Closed

Scope theme colors don't update #2

vanowm opened this issue Oct 4, 2022 · 19 comments
Assignees
Labels
enhancement New feature or request

Comments

@vanowm
Copy link

vanowm commented Oct 4, 2022

It seems changes in package.json are not reflected in tmLanguage.json
And some scopes don't have any colors:
image

image

I think it was one time after VSCode restart that is showed all the missing colors for a split of a second, then removed them.

[EDIT]
might be conflicting with other extension? will check

@RedCMD
Copy link
Owner

RedCMD commented Oct 4, 2022

Any changes in package.json requires 2 restarts of vscode to take affect

Do the colours work on your language?
(not the json file)

Currently I'm just piggy backing off vscodes scope highlighting (textmate)
it only takes the current themes colours/scopes into account
idk if the settings in package.json modify's it

I might have to colour it with semantic highlighting

@vanowm
Copy link
Author

vanowm commented Oct 4, 2022

Yes, the colors are working properly in that extension.
Two restarts of vscode??? That's doesn't sound like "real time" 😉

Tried it on fresh portable VSCode with default settings only this extension installed - it doesn't pick up any colors after multiple restarts:
image

@RedCMD
Copy link
Owner

RedCMD commented Oct 4, 2022

the two restarts is default vscode behavior

you adding the scopes to your extension or theme?
I only support themes scopes atm

@vanowm
Copy link
Author

vanowm commented Oct 4, 2022

It's syntax highlighting rules for the extension.
image

It is strange though that it's picking up some colors and not in fresh vscode

@RedCMD
Copy link
Owner

RedCMD commented Oct 4, 2022

Its working for me
image
image

@vanowm
Copy link
Author

vanowm commented Oct 4, 2022

How about on this?

@RedCMD
Copy link
Owner

RedCMD commented Oct 4, 2022

image

@vanowm
Copy link
Author

vanowm commented Oct 4, 2022

that's not the code from that branch thought

@RedCMD
Copy link
Owner

RedCMD commented Oct 4, 2022

I just had a quick look
it is indeed not working
I'll have to figure it out later

@RedCMD
Copy link
Owner

RedCMD commented Oct 5, 2022

seems only one extension can define editor.tokenColorCustomizations at a time
image
I removed editor.tokenColorCustomizations from my test extension and yours started working again
prob should make bug report to vscode

This doesn't affect just my extension
it affects vscodes textmate in general

if you are launching your extension using vscodes debugging mode
then only one extension is modifying editor.tokenColorCustomizations
so it will appear to work correctly

you can see how I apply the scope to "name"


nothing special. just gets the text in "name" and applies itself as a scope
its then up to the current theme (and textMateRules) to colour it
keyboard shortcuts => editor.action.inspectTMScopes

Tried it on fresh portable VSCode with default settings only this extension installed - it doesn't pick up any colors after multiple restarts:

do you also have your extension enabled in the same instance of vscode?

@vanowm
Copy link
Author

vanowm commented Oct 5, 2022

On fresh install I only tested your extension, nothing else.
P.S.
On your screenshots, you are testing it against wrong commit/branch of autoit extension. For me as you can see on first screenshot, these names worked fine too, including names that ended with a color name (blue, red, brown), however on fresh install none are highlighted.

@RedCMD
Copy link
Owner

RedCMD commented Oct 5, 2022

On fresh install I only tested your extension, nothing else.

vscode uses the current theme to colour in scopes
your extension needs to be enabled for it to add your scopes to the current theme
otherwise vscode will default back to standard white

I have both yours and my extension enabled in the same instance of vscode
image

@vanowm
Copy link
Author

vanowm commented Oct 5, 2022

I think there is misunderstanding 😉. My extension has nothing to do with this. When I open workspace where the code of my extension is in fresh vscode with only RedCMD installed, it doesn't show the colors.

@RedCMD
Copy link
Owner

RedCMD commented Oct 5, 2022

which is currently intended behavior
if your current theme doesn't support those scopes
then they won't have any colour

maybe I can add a language feature to load scopes from inactivate extensions (semantic highlighting)
problem is I have to manually check every file for it then
I can't use any builtin vscode features
and then what should happen when there is multiple workspaces and extensions?
how to handle injections and embedding?
manually emulating an environment is much harder than just using the current one
is much simpler, as vscode handles everything

@RedCMD RedCMD added enhancement New feature or request wontfix This will not be worked on labels Dec 20, 2023
@RedCMD RedCMD removed the wontfix This will not be worked on label Jan 3, 2024
@RedCMD RedCMD self-assigned this Jan 3, 2024
@RedCMD RedCMD closed this as completed in baec40e Jan 3, 2024
@RedCMD
Copy link
Owner

RedCMD commented Jan 3, 2024

I didn't end up using semantic highlighting. VSCode's TextMate scopename assigning is way too stupidly complex

Instead I try to locate the package.json file, copy the editor.tokenColorCustomizations setting and apply it to VSCode's global settings file.
Sadly this will overwrite any editor.tokenColorCustomizations thats already there
so I make a copy of that and save it as editor.tokenColorCustomizations_bak
and attempt to reload it back when closing files (TODO: needs more work microsoft/vscode#201664)

@RedCMD RedCMD reopened this Jan 3, 2024
@vanowm
Copy link
Author

vanowm commented Jan 3, 2024

In my tests, since we can't control when, which extension initializing first, all we can do is merge existing setting with ours, not just replace it. But again we can't really trust that the global setting is up-to-date when extension starts, even merging might not be 100% reliable solition...

@RedCMD
Copy link
Owner

RedCMD commented Jan 3, 2024

I thought about merging all settings
But technically VSCode doesn't ever merge the editor.tokenColorCustomizations setting either
so I'll just follow the same way and just temporary replace the settings when clicking on a package.json file or json-textmate languageId file

I don't have to worry about the extension initializing order as this feature is only for in the context that the extension providing the editor.tokenColorCustomizations setting isn't loaded in the same instance of VSCode

I need to look into WorkspaceConfiguration.inspect(), cause currently I'm backing up settings from loaded extensions rather than just the global settings file

@RedCMD
Copy link
Owner

RedCMD commented Jan 10, 2024

I've published a pre-release version with the changes
see if its like how you want
and that theres no bugs :}

RedCMD added a commit that referenced this issue Jan 16, 2024
@RedCMD
Copy link
Owner

RedCMD commented Mar 2, 2024

Now available in the full release 2.3.0 for VSCode 1.87.0

@RedCMD RedCMD closed this as completed Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants