Skip to content

Commit 5683c7f

Browse files
committed
feat: support plain icon.svg for plugin icon preview
1 parent 4f1dbf7 commit 5683c7f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Search order (first existing directory wins precedence if duplicates):
229229

230230
Supported file patterns (case-insensitive):
231231
- Banners: `banner-1544x500.(png|jpg)` (large), `banner-772x250.(png|jpg)` (small)
232-
- Icons: `icon-256x256.*`, `icon-128x128.*`, `icon-64x64.*`, `icon-32x32.*` (`.png`, `.jpg`, `.jpeg`, `.svg`)
232+
- Icons: `icon.svg` (scalable, preferred), `icon-256x256.*`, `icon-128x128.*`, `icon-64x64.*`, `icon-32x32.*` (`.png`, `.jpg`, `.jpeg`, `.svg`)
233233
- Screenshots: `screenshot-1.(png|jpg|jpeg|gif)`, `screenshot-2.*`, etc.
234234

235235
The best available icon size is chosen in order: 256 → 128 → 64 → 32. Screenshots are displayed in ascending numerical order.

src/preview/htmlGenerator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export class HtmlGenerator {
176176

177177
private pickBestIcon(icons: { [size: string]: vscode.Uri } | undefined): vscode.Uri | undefined {
178178
if (!icons) return undefined;
179-
const preferred = ['256','128','64','32'];
179+
// Prefer scalable SVG, then largest raster sizes
180+
const preferred = ['svg', '256','128','64','32'];
180181
for (const p of preferred) {
181182
if (icons[p]) return icons[p];
182183
}

src/preview/previewProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ ReadmePreviewProvider.prototype.collectPluginAssets = async function(resource: v
421421
const bannerLargeRegex = /^banner-(?:1544x500|1544x500@2x)\.(png|jpe?g)$/i;
422422
const bannerSmallRegex = /^banner-(?:772x250|772x250@2x)\.(png|jpe?g)$/i;
423423
const iconRegex = /^icon-(\d{2,3})x\1\.(png|jpe?g|svg)$/i; // icon-256x256.png
424+
const iconSvgRegex = /^icon\.svg$/i; // plain icon.svg (scalable, preferred)
424425
const screenshotRegex = /^screenshot-(\d+)\.(png|jpe?g|gif)$/i;
425426

426427
for (const dir of assetDirs) {
@@ -434,6 +435,9 @@ ReadmePreviewProvider.prototype.collectPluginAssets = async function(resource: v
434435
} else if (bannerSmallRegex.test(name)) {
435436
assets.banner = assets.banner || {};
436437
assets.banner.small = vscode.Uri.joinPath(dir, name);
438+
} else if (iconSvgRegex.test(name)) {
439+
// Plain icon.svg (scalable) - store under 'svg' key with highest priority
440+
assets.icons!['svg'] = vscode.Uri.joinPath(dir, name);
437441
} else {
438442
const iconMatch = name.match(iconRegex);
439443
if (iconMatch) {

0 commit comments

Comments
 (0)