Skip to content

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

Merged
Matt Bierner (mjbvz) merged 5 commits into
microsoft:masterfrom
dvrylc:fix-markdown-preview-icon
Jan 29, 2020
Merged

Matt Bierner (mjbvz) merged 5 commits into
microsoft:masterfrom
dvrylc:fix-markdown-preview-icon

Conversation

@dvrylc

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

Matt Bierner (mjbvz) pushed a commit that referenced this pull request Jan 21, 2020
@mjbvz

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

Yes it's still broken:

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

@msftclas

Microsoft Contribution License Agreements (msftclas) commented Jan 24, 2020 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@dvrylc

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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?

@mjbvz Matt Bierner (mjbvz) left a comment

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Alright, should be good to go!

@mjbvz Matt Bierner (mjbvz) added this to the January 2020 milestone Jan 29, 2020
@mjbvz
Matt Bierner (mjbvz) merged commit 91915be into microsoft:master Jan 29, 2020
@mjbvz

Copy link
Copy Markdown
Contributor

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