支持搜索文件和目录
This commit is contained in:
@@ -744,7 +744,8 @@ function RenderNode({
|
||||
export function FileTreeTab() {
|
||||
const t = useTranslations("Folder.fileTreeTab")
|
||||
const tCommon = useTranslations("Folder.common")
|
||||
const { activeTab } = useAuxPanelContext()
|
||||
const { activeTab, pendingRevealPath, consumePendingRevealPath } =
|
||||
useAuxPanelContext()
|
||||
const { folder } = useFolderContext()
|
||||
const { tabs, activeTabId } = useTabContext()
|
||||
const { createTerminalInDirectory } = useTerminalContext()
|
||||
@@ -857,6 +858,24 @@ export function FileTreeTab() {
|
||||
externalConflictSignatureByPathRef.current.clear()
|
||||
}, [folder?.path])
|
||||
|
||||
// Handle pending reveal path: expand all ancestor directories once tree is loaded
|
||||
const hasNodes = nodes.length > 0
|
||||
useEffect(() => {
|
||||
if (!pendingRevealPath || !hasNodes) return
|
||||
consumePendingRevealPath()
|
||||
setExpandedPaths((prev) => {
|
||||
const next = new Set(prev)
|
||||
next.add(FILE_TREE_ROOT_PATH)
|
||||
let idx = pendingRevealPath.indexOf("/")
|
||||
while (idx !== -1) {
|
||||
next.add(pendingRevealPath.slice(0, idx))
|
||||
idx = pendingRevealPath.indexOf("/", idx + 1)
|
||||
}
|
||||
next.add(pendingRevealPath)
|
||||
return next
|
||||
})
|
||||
}, [pendingRevealPath, consumePendingRevealPath, hasNodes])
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeFileTab || activeFileTab.kind !== "file") return
|
||||
if (!activeFileTab.path) return
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useCallback, useState } from "react"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { FileDiff, Folder, FolderPen, GitCommit } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
@@ -26,6 +26,14 @@ export function AuxPanel() {
|
||||
activeTab === "git_log"
|
||||
)
|
||||
|
||||
// Sync mount flags when activeTab changes programmatically (e.g. revealInFileTree)
|
||||
useEffect(() => {
|
||||
if (!isOpen) return
|
||||
if (activeTab === "file_tree") setHasMountedFileTree(true)
|
||||
else if (activeTab === "changes") setHasMountedChanges(true)
|
||||
else if (activeTab === "git_log") setHasMountedGitLog(true)
|
||||
}, [isOpen, activeTab])
|
||||
|
||||
const handleTabValueChange = useCallback(
|
||||
(value: string) => {
|
||||
const nextTab = value as AuxPanelTab
|
||||
|
||||
Reference in New Issue
Block a user