Skip to content

fix(build): restore dedicated .md file icon on Windows - #4284

Merged
Jocs merged 1 commit into
marktext:developfrom
Blueteemo:fix/win-md-file-icon
May 27, 2026
Merged

Jocs merged 1 commit into
marktext:developfrom
Blueteemo:fix/win-md-file-icon

Conversation

@Blueteemo

Copy link
Copy Markdown
Contributor

Summary

Restore the dedicated Markdown document icon for .md (and other Markdown) files on Windows. After installing v0.19.0-rc.3, Markdown files in Explorer show the MarkText application logo instead of the document-style icon used by v0.17.x and earlier.

Before (current develop / v0.19.0-rc.x) After (this PR)
.md → app logo (fallback to marktext.exe,0) .md → dedicated md.ico document icon

Root cause

PR #4001 (Re-Factor MarkText with electron-vite) rewrote electron-builder.yml. In the new file each extension is its own fileAssociations entry, but the original

icon: "../resources/icons/md.icns"

field (present in v0.17.1) was not carried over to any of the new entries. With no per-association icon, electron-builder’s NSIS target falls back to the main application icon when registering DefaultIcon in the registry, which is exactly what users see now:

HKCR\Markdown\DefaultIcon = "...\marktext.exe",0

The icon assets themselves are still shipped — extraResources already copies build/icons/*.ico to resources/icons/, so resources/icons/md.ico is present in the installed app. They were simply no longer referenced from the file associations.

Fix

Re-add icon: icons/md.ico (resolved against buildResources, i.e. build/icons/md.ico) to every Markdown extension in fileAssociations. This restores the pre-refactor behavior without touching anything else.

fileAssociations:
  - ext: md
    name: Markdown
    description: Markdown document
    mimeType: text/markdown
    role: Editor
    icon: icons/md.ico         # ← restored
  - ext: markdown
    ...
    icon: icons/md.ico
  # …same for mmd / mdown / mdtxt / mdtext

Linux and macOS file associations are unaffected (Linux doesn’t use this field; macOS file types are declared elsewhere with icons/md.icns already wired up via mac.extendInfo / dmg flow as before).

Verification

Local registry check on a v0.19.0-rc.3 install confirms the regression and the fix path:

# Before
HKCR\.md           = Markdown
HKCR\Markdown\DefaultIcon = "...\marktext.exe",0       # falls back to app logo

# After (with this patch, or as a manual user override)
HKCR\Markdown\DefaultIcon = "...\resources\icons\md.ico",0

Re-running the icon cache (ie4uinit.exe -ClearIconCache && ie4uinit.exe -show) immediately switches Explorer to the document icon.

I have not produced a fresh installer locally for this change (no Windows signing setup), but the patch is a one-line-per-entry config restoration of behavior that already shipped in v0.17.x, against assets that are still present and copied into the installer.

Notes

  • I searched issues and open PRs (md.ico, fileAssociations, file icon, etc.) and didn’t find an existing report or fix for this specific regression.
  • Happy to also restore the .icns reference for any platform that needs it if reviewers want it bundled in the same PR.

@Blueteemo
Blueteemo force-pushed the fix/win-md-file-icon branch from 7ff2ee4 to 22a1e7b Compare May 26, 2026 04:09
Re-introduce the per-extension `icon: icons/md.ico` mapping in
`fileAssociations` so Markdown files use the dedicated document icon
(`build/icons/md.ico`) instead of falling back to the application logo.

The dedicated icon was lost during the electron-vite refactor in marktext#4001
when each extension was split into its own entry without copying over
the original `icon` field. The icon assets are still shipped via
`extraResources` (`resources/icons/md.ico` is present in the install),
they were simply not referenced.

Apply the same icon to all six Markdown extensions (md, markdown, mmd,
mdown, mdtxt, mdtext) to match v0.17.x behavior.
@Jocs
Jocs requested review from Tkaixiang and Copilot May 26, 2026 11:00

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Tkaixiang Tkaixiang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, builds and adds a more maintained layer. The NSIS manual writing can serve as a backup which was added for certain setups where the electron association didn't work.

@Jocs
Jocs merged commit ac3bbad into marktext:develop May 27, 2026
17 checks passed
@Blueteemo
Blueteemo deleted the fix/win-md-file-icon branch May 27, 2026 03:56
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
Re-introduce the per-extension `icon: icons/md.ico` mapping in
`fileAssociations` so Markdown files use the dedicated document icon
(`build/icons/md.ico`) instead of falling back to the application logo.

The dedicated icon was lost during the electron-vite refactor in marktext#4001
when each extension was split into its own entry without copying over
the original `icon` field. The icon assets are still shipped via
`extraResources` (`resources/icons/md.ico` is present in the install),
they were simply not referenced.

Apply the same icon to all six Markdown extensions (md, markdown, mmd,
mdown, mdtxt, mdtext) to match v0.17.x behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants