Skip to content

fix: #4890 use file extension for side bar icons - #4910

Merged
Jocs merged 1 commit into
marktext:developfrom
doktorigi:fix/4890-docker-icon-md-files
Sep 7, 2026
Merged

Jocs merged 1 commit into
marktext:developfrom
doktorigi:fix/4890-docker-icon-md-files

Conversation

@doktorigi

Copy link
Copy Markdown
Contributor

Description

Fixes #4890 — a markdown file whose name starts with Dockerfile (e.g. Dockerfile-Notes.md) was shown with the Docker icon in the side bar instead of the Markdown icon.

Root cause

@marktext/file-icons tests whole-name rules before extension rules, and its Docker rule is an unanchored prefix match (/^(?:Dockerfile|docker-compose)|\.docker(?:file|ignore)$/i), so any file name starting with Dockerfile matches it — including markdown files.

Fix

The side bar tree only lists files with markdown extensions (the directory watcher in main/filesystem/watcher.ts filters out everything else), so the extension is the reliable signal. The icon lookup (extracted from icon.vue into fileIconClass.ts so it can be unit-tested) now matches on the extension first and falls back to the full name only for extensionless names:

  • Dockerfile-Notes.md → markdown icon ✅ (was docker)
  • notes.md, unknown/empty names → markdown icon (unchanged)
  • Dockerfile, app.dockerfile → docker icon (unchanged)

The durable upstream fix would be anchoring the Docker regex in marktext/file-icons (e.g. /^(?:Dockerfile|docker-compose)(?:$|\.)/), which would also benefit the other consumers — happy to send that PR too if wanted.

Tests

Added test/unit/specs/file-icon-class.spec.ts covering the cases above; it passes against the current (unfixed) @marktext/file-icons, i.e. the fix is fully app-side. pnpm run lint and pnpm run typecheck pass.

Note: I couldn't produce a screenshot — my Windows environment lacks the native build toolchain so the app doesn't run locally. The behavior change is captured by the unit tests; happy to add a screenshot if someone can run it.

🤖 Generated with Claude Code

…f name prefix

file-icons tests whole-name rules before extension rules, so a markdown
file named like another tool's file (e.g. Dockerfile-Notes.md) picked up
that tool's icon in the side bar. The tree only lists files with markdown
extensions, so match the icon on the extension first and fall back to the
full name only for extensionless names.

Co-Authored-By: Claude Fable 5 <[email protected]>
niyo-oyin added a commit to niyo-oyin/marktext-ja that referenced this pull request Jul 30, 2026
Upstream PRs applied (all diff-reviewed, tests included and passing):
- marktext#4776: preserve ordered-list source markers — opening and saving no
  longer rewrites 1./1./1. to 1./2./3. (marktext#4772, silent doc mutation)
- marktext#4788: UNC/WSL paths become valid file:// authority URLs
  (file://server/share/…, not file:////…) so network images load
  (marktext#4577, marktext#4563)
- marktext#4952: table columns size to content (min-width 10em → 2em, marktext#4894)
- marktext#4773: malformed percent-escape in a clicked link no longer throws an
  unhandled URIError (marktext#4749)
- marktext#4873: Shift+digit/punctuation keybindings recordable and matchable
  again (patch-package fix for @hfelix/electron-localshortcut, marktext#4863)
- marktext#4910: sidebar icons match by extension first, so Dockerfile-Notes.md
  gets the markdown icon (marktext#4890)
- marktext#4317: restored windows are clamped to the target display's work area
  (multi-monitor / DPI, marktext#2928, marktext#1947)

Found while integrating marktext#4776: cloneStateTree shallow-copied meta, so
array-valued fields (order-list sourceMarkers, table aligns) stayed
SHARED between a getState() clone and the live document — mutating a
returned tree corrupted the document. Meta arrays are now copied, and
the clone walks an explicit work list instead of recursing, so
pathological nesting (600-level lists, marktext#4747) can no longer overflow
the call stack (10k-depth regression test).

Also: folder search debounces its per-keystroke ripgrep run (300ms,
Enter searches immediately, IME-composing keys ignored) (marktext#3556), and a
new undoFloor spec pins that undoing past the opened baseline never
empties the document (marktext#5028 — legacy-engine bug, does not reproduce on
@muyajs/core).

muya 1536/1536, desktop 783/783, lint/tsc/madge clean. PLANS.md gains a
prioritized backlog from the full 563-item issue/PR survey.
@Jocs
Jocs merged commit 8763c35 into marktext:develop Sep 7, 2026
1 check passed
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.

[Bug] Incorrect Docker icon assigned to .md files starting with "Dockerfile"

2 participants