fix: 修复侧边栏根目录、搜索高亮导航、行号同步

问题1: 侧边栏打开文件夹后根目录不显示
修复: FileTree 传入包装后的根节点 { name, path, type: 'dir', children: tree }
      打开文件夹时自动展开根目录 expandDirs([rootPath])

问题2: 搜索没有高亮,上一个/下一个没反应
修复: Editor 添加完整搜索功能
      - 搜索时在 textarea 上方创建 overlay div
      - 用绝对定位 div 标记每个匹配位置(单行/多行)
      - currentIndex 变化时选中匹配文本并滚动到可视区域
      - 搜索结果随内容变化自动更新

问题3: 滚动时行号跟随不准确
修复: 行高测量改为与 CSS line-height 一致的动态测量
      搜索高亮位置随编辑器滚动同步更新
This commit is contained in:
thzxx
2026-05-27 22:49:34 +08:00
parent 9e3029774a
commit b3987e9abd
3 changed files with 180 additions and 95 deletions
@@ -39,8 +39,8 @@ export function SearchBar() {
const handleSearchChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const text = e.target.value
setSearchText(text)
doSearch(text)
}, [setSearchText, doSearch])
// Editor 会监听 searchText 变化并执行搜索和高亮
}, [setSearchText])
const handleReplaceCurrent = useCallback(() => {
const tab = getActiveTab()