Add icons for Markdown headers#298857
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the Outline view’s iconography for Markdown headers by introducing dedicated “header level” icons (H1–H6) and wiring Outline rendering to select them for Markdown documents.
Changes:
- Add Markdown-specific header icon selection logic to the document symbols outline renderer.
- Introduce new theme colors + CSS rules for header-level symbol icon foregrounds.
- Add new codicon glyph registrations for
symbol-header-one…symbol-header-six.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsTree.ts |
Updates outline element rendering to compute a “leveled” icon id and apply Markdown-specific header icons. |
src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsOutline.ts |
Passes the editor model language id into the outline element renderer. |
src/vs/editor/contrib/symbolIcons/browser/symbolIcons.ts |
Registers new theme colors for header-level symbol icons. |
src/vs/editor/contrib/symbolIcons/browser/symbolIcons.css |
Adds CSS color rules for the new codicon-symbol-header-* icons. |
src/vs/base/common/codiconsLibrary.ts |
Registers new codicons for symbol-header-one through symbol-header-six. |
…mbolsTree.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks for the PR. Instead of having to build these into vscode-codicons (which has a higher bar to merging) I wonder if the markdown extension itself could contribute these icons: https://code.visualstudio.com/api/references/contribution-points#contributes.icons Then we'd need to also update That would be much cleaner and avoid having to have markdown specific workarounds in core vscode |
Man, GitHub has been terrible with these notifications lately. Sorry I missed this! I generally agree with what you’re saying, and I actually considered something similar earlier, as I mentioned in the PR:
I may have misread part of your suggestion at first, though. I see now that you’re suggesting the Markdown extension could contribute the icons itself, rather than adding them directly to My main concern with that approach is consistency. As far as I understand it, the other language-related icons are included in the main codicons repo. If Markdown’s heading icons live inside the Markdown extension instead, that feels like a slight architectural inconsistency. One could also argue that, by that same logic, other language-specific icons should eventually move into their respective extensions as well. That said, I do understand why Markdown is a special case here. The only reason this issue exists is that Markdown headings include the leading The approach in these PRs was my attempt at a middle ground: avoid a larger rewrite of the icon/theme system while still allowing level-based symbol icons in a way that could potentially benefit more than just Markdown later. I also realize there is a higher bar for merging changes into At this point, I’m not completely sure which path is preferred. If you think contributing the icons from the Markdown extension is the better architectural direction, I’m happy to look into that and update the PR accordingly. |
Description
A long-standing issue with Markdown not displaying correctly in the outline view (includes '#' in headers and uses generic "String" symbols for icons). This PR and the associated PRs resolve this issue in its entirety.
I originally designed an extension to do this, but realized the only language with this issue is Markdown. So I figured I'd dip my toes into the codebase and see what I could do. This is my first PR, so I'm obviously expecting to have made some mistakes and to receive feedback on changes. I will try to be prompt as necessary with those changes :)
Requires: microsoft/vscode-markdown-languageservice#228
Requires: microsoft/vscode-codicons#442
Resolves #53992
Changes
How to Test
Make sure you have "vscode (my PR)", "vscode-codicons (my PR)", "vscode-markdown-languageservice (my PR)", and "vscode-markdown-languageserver" cloned in the same directory.
1. Codeicons
Run
npm run build,npm run export-to-ts, andnpm run fonts. Don't close this workspace.2. Language Service
Run
npm run compilethennpm run prepublishOnly.3. Language Server
Modify package.json and change the language service dependency to be local (e.g.,
"vscode-markdown-languageservice": "file://../vscode-markdown-languageservice",). Reinstall your node dependencies. Then runnpm run compileandnpm run prepublishOnly.4. VS Code
Go to
extensions/markdown-language-features, modify its package.json and change the language server dependency to be local (e.g.,"vscode-markdown-languageserver": "file://../../../vscode-markdown-languageserver/"). Reinstall your node dependencies.Go back to top level and run
npm run watch. Return to the codeicons workspace and runnpm run replace-in-vscode.Examples