mde-focus-fix
New修复 Markdown Preview Enhanced (MDE) 插件在预览面板已存在时重新触发 openPreview 命令不切换焦点的 bug。直接 patch 本地安装的 extension.js,无需编译。使用场景:MDE 插件升级后需要重新 patch、首次安装 patch、或需要还原原始文件时。触发词:MDE、markdown-preview-enhanced、预览不聚焦、预览不切换焦点、preview focus、openPreview、patch MDE。
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(首次或插件升级后)
python3 scripts/patch.py成功后 Cmd+Shift+P → Reload Window 生效。
撤销 patch
python3 scripts/restore.py插件升级后重新 patch
MDE 升级后路径中版本号变化,修改 scripts/patch.py 顶部的 EXT_VERSION,再重新执行即可:
EXT_VERSION = "0.8.31" # 改成新版本号文件说明
| 文件 | 说明 |
|---|---|
scripts/patch.py | 应用 patch,幂等执行 |
scripts/restore.py | 从备份还原原始文件 |
README.md | 详细问题分析和修复原理 |
注意
- •patch 脚本会在插件目录自动创建
extension.js.bak备份 - •MDE 每次自动更新后 patch 失效,需重新执行
patch.py
Install & Usage
mkdir -p .claude/skillsAdd the configuration to .claude/skills/mde-focus-fix.md
/mde-focus-fixUse Cases
Usage Examples
/mde-focus-fix apply the patch to fix preview focus
Run the patch script and reload VS Code to enable the fix
Restore the original extension.js from backup to undo the patch
Security Audits
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..