Skip to content

Hide Markdown preview editor icon when there is no active icon theme#88692

Merged
mjbvz merged 5 commits intomicrosoft:masterfrom
dvrylc:fix-markdown-preview-icon
Jan 29, 2020
Merged

Hide Markdown preview editor icon when there is no active icon theme#88692
mjbvz merged 5 commits intomicrosoft:masterfrom
dvrylc:fix-markdown-preview-icon

Conversation

@dvrylc
Copy link
Contributor

@dvrylc dvrylc commented Jan 15, 2020

This PR fixes #84962.

Approach

  • Set the Markdown preview editor's icon only if there is an active icon theme
  • Attach a handler for the onDidChangeConfiguration event so that preference changes are reflected live

I've seen in this comment that the issue shouldn't be fixed at the Markdown extension level but I still went with this approach because:

  • I couldn't reproduce the bug in any other Webview
  • This seems isolated to the Markdown extension's incorrect setting of the iconPath regardless of the workbench preferences

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 16, 2020

I still don't think this should be fixed at the markdown extension. Extensions should be free to set the icon to whatever they wish, but then VS Code should determine if it should display those icons or not

If we can't fix this with css rules, I recommend moving the logic into this class in core VS Code instead:

@dvrylc
Copy link
Contributor Author

dvrylc commented Jan 21, 2020

I'm trying to move the logic into core but I'm not sure how to read configuration values from within the WebviewIconsManager. What's the usual approach for this?

https://github.com/microsoft/vscode/blob/master/src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts#L29

mjbvz added a commit that referenced this pull request Jan 21, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 21, 2020

I pushed d6fba31 that makes the change simpler.

Icon manager code:

@IInstantiationService private readonly _instantiationService: IInstantiationService,

You'll want to use the IConfigurationService. It has a similar API to the external configuration api

@dvrylc
Copy link
Contributor Author

dvrylc commented Jan 22, 2020

Thanks for that! I have a good idea of how to fix this, but now I can't seem to reproduce the bug on the latest master. Can you confirm this?

6861571

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 23, 2020

Yes it's still broken:

Screen Shot 2020-01-22 at 4 24 52 PM

@dvrylc dvrylc force-pushed the fix-markdown-preview-icon branch from 1d92449 to b9276a6 Compare January 24, 2020 18:31
@msftclas
Copy link

msftclas commented Jan 24, 2020

CLA assistant check
All CLA requirements met.

@dvrylc
Copy link
Contributor Author

dvrylc commented Jan 24, 2020

I've updated the PR with the following implementation:

  • Check whether there is an active icon theme before setting it
  • Force the Markdown preview webview to update each time there is a configuration change so that new options are reflected in the current open tabs

@dvrylc dvrylc force-pushed the fix-markdown-preview-icon branch from b9276a6 to 9666816 Compare January 25, 2020 18:43
@dvrylc
Copy link
Contributor Author

dvrylc commented Jan 25, 2020

Thanks for the comments!

I refactored the approach to only check for an active icon theme when updating the stylesheet. This ensures that:

  • Extensions can freely set the icon
  • Icons are only shown when there is an active icon theme
  • Configuration changes are immediately reflected

I do have a question however –

private async updateStyleSheet(lifecycleService: ILifecycleService) {

Why does updateStyleSheet need to take lifecycleService as an argument, given that it's already passed in the constructor?

@dvrylc dvrylc requested a review from mjbvz January 28, 2020 02:33
Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one more minor change needed. Otherwise looks good!

@dvrylc dvrylc force-pushed the fix-markdown-preview-icon branch from 9666816 to ee40563 Compare January 28, 2020 04:32
@dvrylc
Copy link
Contributor Author

dvrylc commented Jan 28, 2020

Alright, should be good to go!

@mjbvz mjbvz added this to the January 2020 milestone Jan 29, 2020
@mjbvz mjbvz merged commit 91915be into microsoft:master Jan 29, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 29, 2020

Thanks! This will be in the next insiders build and will ship with VS Code 1.42

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown preview editor shows icon even though I disabled file icons

3 participants