fix(app): navigate to tabs when opening file

This commit is contained in:
adamelmore
2026-01-27 08:17:00 -06:00
parent 3297e5230e
commit eac2d4c699
2 changed files with 29 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ type Entry = {
type DialogSelectFileMode = "all" | "files"
export function DialogSelectFile(props: { mode?: DialogSelectFileMode }) {
export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFile?: (path: string) => void }) {
const command = useCommand()
const language = useLanguage()
const layout = useLayout()
@@ -164,6 +164,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode }) {
tabs().open(value)
file.load(path)
view().reviewPanel.open()
props.onOpenFile?.(path)
}
const handleSelect = (item: Entry | undefined) => {

View File

@@ -650,7 +650,7 @@ export default function Page() {
category: language.t("command.category.file"),
keybind: "mod+p",
slash: "open",
onSelect: () => dialog.show(() => <DialogSelectFile />),
onSelect: () => dialog.show(() => <DialogSelectFile onOpenFile={() => showAllFiles()} />),
},
{
id: "context.addSelection",
@@ -1084,11 +1084,31 @@ export default function Page() {
const pendingDiff = () => tree.pendingDiff
const setPendingDiff = (value: string | undefined) => setTree("pendingDiff", value)
const showAllFiles = () => {
if (!layout.fileTree.opened()) return
if (fileTreeTab() !== "changes") return
setFileTreeTab("all")
}
createEffect(() => {
if (!layout.fileTree.opened()) return
setFileTreeTab("changes")
})
createEffect(
on(
() => tabs().active(),
(active) => {
if (!active) return
if (!layout.fileTree.opened()) return
if (fileTreeTab() !== "changes") return
if (!file.pathFromTab(active)) return
showAllFiles()
},
{ defer: true },
),
)
const setFileTreeTabValue = (value: string) => {
if (value !== "changes" && value !== "all") return
setFileTreeTab(value)
@@ -1702,6 +1722,7 @@ export default function Page() {
focusedComment={comments.focus()}
onFocusedCommentChange={comments.setFocus}
onViewFile={(path) => {
showAllFiles()
const value = file.tab(path)
tabs().open(value)
file.load(path)
@@ -2068,7 +2089,9 @@ export default function Page() {
icon="plus-small"
variant="ghost"
iconSize="large"
onClick={() => dialog.show(() => <DialogSelectFile mode="files" />)}
onClick={() =>
dialog.show(() => <DialogSelectFile mode="files" onOpenFile={() => showAllFiles()} />)
}
aria-label={language.t("command.file.open")}
/>
</TooltipKeybind>
@@ -2100,6 +2123,7 @@ export default function Page() {
focusedComment={comments.focus()}
onFocusedCommentChange={comments.setFocus}
onViewFile={(path) => {
showAllFiles()
const value = file.tab(path)
tabs().open(value)
file.load(path)
@@ -2679,6 +2703,7 @@ export default function Page() {
focusedComment={comments.focus()}
onFocusedCommentChange={comments.setFocus}
onViewFile={(path) => {
showAllFiles()
const value = file.tab(path)
tabs().open(value)
file.load(path)