-
Notifications
You must be signed in to change notification settings - Fork 92
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
Set gutter colour with CSS #436
Conversation
d065906
to
c897485
Compare
c897485
to
b3f4b9a
Compare
609ffa7
to
76ecf2b
Compare
@verhovsky Thanks for the PR, this will be sweet to have and is much better than the manual icon route. I definitely think this should be the new way moving forward, but I wonder if we should leave in the old values (but maybe add deprecated to the description in the In the meantime, the extension could use an adaptor pattern to allow us to move forward with the better approach and still provide support for the old file method so we can release this in 2.x? (which will be much sooner than a hypothetical 3.0 heh). |
return ""; | ||
} | ||
|
||
const svg = '<svg width="32" height="48" viewPort="0 0 32 48" xmlns="http://www.w3.org/2000/svg"><polygon points="16,0 32,0 32,48 16,48" fill="' + colour + '"/></svg>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tests will also need to be adjusted to support this (or if we support the old method and the new, then we could add a new test to cover this).
https://github.com/ryanluker/vscode-coverage-gutters/actions/runs/7951747196/job/21742231483?pr=436#step:6:128
This would only matter to people that have a different gutter color than the line highlight color and people that only set a gutter color and no line color. I can't imagine anyone going through the trouble of generating an image file just to change the color of a gutter in their code editor, surely not many people use this setting. |
263cd10
to
87c5a88
Compare
Alright I agree with that logic, makes sense! |
const svg = '<svg width="32" height="48" viewPort="0 0 32 48" xmlns="http://www.w3.org/2000/svg"><polygon points="16,0 32,0 32,48 16,48" fill="' + colour + '"/></svg>'; | ||
|
||
const icon = 'data:image/svg+xml;base64,' + Buffer.from(svg).toString('base64'); | ||
return Uri.parse(icon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional Logging: This is looking good, I do wonder though if we should add some logging to assist with if the make icon process fails in some way 🤔. (maybe lower down where the calls to this new inline are)
const outputChannel = vscode.window.createOutputChannel("coverage-gutters");
const configStore = new Config(context);
expect((options.dark as any).gutterIconPath).to.equal(iconPathDark); | ||
expect((options.light as any).gutterIconPath).to.include("./app_images/"); | ||
expect(((options.dark as any).gutterIconPath as any).path).to.be.a('string').and.match(preamble).and.satisfy((icn: string) => atob(icn.replace(preamble, '')).includes(highlightdark)); | ||
expect(((options.light as any).gutterIconPath as any).path).to.be.a('string').and.match(preamble).and.satisfy((icn: string) => atob(icn.replace(preamble, '')).includes(highlightlight)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props 👍🏻 : Cool test, thanks for adding this!
✔ Should set the gutter icon colour to the provided value if set @Unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet feature addition @verhovsky , thanks for contributing!
@verhovsky FYI this is going out with today's release. I was just doing the QA as a double check, and it was working nicely locally for me! Thanks again for the contribution. |
This is actually possible as we can see from the VS Code source code:
https://github.com/microsoft/vscode/blob/12443ca030f93843ca5e9dfb5682ad92d2c6400c/src/vs/editor/browser/services/abstractCodeEditorService.ts#L801
https://github.com/microsoft/vscode/blob/12443ca030f93843ca5e9dfb5682ad92d2c6400c/src/vs/editor/browser/services/abstractCodeEditorService.ts#L591
This isn't explicitly documented (just the type says "string or Uri") but it is even tested:
https://github.com/microsoft/vscode/blob/12443ca030f93843ca5e9dfb5682ad92d2c6400c/src/vs/editor/test/browser/services/decorationRenderOptions.test.ts#L113
See #432