BeClaude

mde-focus-fix

New
GitHub TrendingDocumentationby Li-Mingshuang

修复 Markdown Preview Enhanced (MDE) 插件在预览面板已存在时重新触发 openPreview 命令不切换焦点的 bug。直接 patch 本地安装的 extension.js,无需编译。使用场景:MDE 插件升级后需要重新 patch、首次安装 patch、或需要还原原始文件时。触发词:MDE、markdown-preview-enhanced、预览不聚焦、预览不切换焦点、preview focus、openPreview、patch MDE。

First seen 6/17/2026

Summary

This skill patches the Markdown Preview Enhanced (MDE) VS Code extension to fix a bug where the openPreview command refreshes content but does not switch focus to the preview panel if it already exists.

  • It is useful for developers who rely on MDE for previewing markdown and want consistent focus behavior after plugin updates or initial installation.

Overview

MDE Focus Fix

修复 Markdown Preview Enhanced 插件在预览面板已存在时,触发 openPreview 命令只刷新内容但不切换焦点的 bug。

背景

MDE 插件 initPreview 函数在 panel 已存在时走了两条不 reveal 的路径,导致预览在后台更新、焦点不切换。详见 README.md

使用方法

应用 patch(首次或插件升级后)

bash
python3 scripts/patch.py

成功后 Cmd+Shift+PReload Window 生效。

撤销 patch

bash
python3 scripts/restore.py

插件升级后重新 patch

MDE 升级后路径中版本号变化,修改 scripts/patch.py 顶部的 EXT_VERSION,再重新执行即可:

python
EXT_VERSION = "0.8.31"  # 改成新版本号

文件说明

文件说明
scripts/patch.py应用 patch,幂等执行
scripts/restore.py从备份还原原始文件
README.md详细问题分析和修复原理

注意

  • patch 脚本会在插件目录自动创建 extension.js.bak 备份
  • MDE 每次自动更新后 patch 失效,需重新执行 patch.py

Install & Usage

1
Create the skills directory
mkdir -p .claude/skills
2
Download the skill file

Add the configuration to .claude/skills/mde-focus-fix.md

3
Invoke in Claude Code
/mde-focus-fix

Use Cases

Apply the patch after upgrading MDE to a new version to restore preview focus behavior.
First-time setup of the patch on a fresh MDE installation to prevent focus loss during preview.
Restore the original extension.js file using the backup if the patch causes unexpected issues.
Reapply the patch after MDE auto-updates, which typically overwrites the patched file.
Verify that the patch is correctly applied by checking the backup file existence.
Update the patch script's version number when MDE upgrades to a new version with a changed path.

Usage Examples

1

/mde-focus-fix apply the patch to fix preview focus

2

Run the patch script and reload VS Code to enable the fix

3

Restore the original extension.js from backup to undo the patch

View source on GitHub
code-review

Security Audits

LicenseUnknownSourceWarnRepositoryPass

Frequently Asked Questions

What is mde-focus-fix?

This skill patches the Markdown Preview Enhanced (MDE) VS Code extension to fix a bug where the openPreview command refreshes content but does not switch focus to the preview panel if it already exists. It is useful for developers who rely on MDE for previewing markdown and want consistent focus behavior after plugin updates or initial installation.

How to install mde-focus-fix?

To install mde-focus-fix: create the skills directory (mkdir -p .claude/skills), then add the config to .claude/skills/mde-focus-fix.md. Finally, /mde-focus-fix in Claude Code.

What is mde-focus-fix best for?

mde-focus-fix is a other categorized under Documentation. It is designed for: code-review. Created by Li-Mingshuang.

What can I use mde-focus-fix for?

mde-focus-fix is useful for: Apply the patch after upgrading MDE to a new version to restore preview focus behavior.; First-time setup of the patch on a fresh MDE installation to prevent focus loss during preview.; Restore the original extension.js file using the backup if the patch causes unexpected issues.; Reapply the patch after MDE auto-updates, which typically overwrites the patched file.; Verify that the patch is correctly applied by checking the backup file existence.; Update the patch script's version number when MDE upgrades to a new version with a changed path..