feat(tui): default tabs to cwd scope
This commit is contained in:
parent
9ee337469d
commit
4bd16d6f47
2 changed files with 10 additions and 2 deletions
|
|
@ -101,6 +101,14 @@ export const settings: Setting[] = [
|
||||||
values: [false, true],
|
values: [false, true],
|
||||||
labels: ["off", "on"],
|
labels: ["off", "on"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Scope",
|
||||||
|
category: "Tabs",
|
||||||
|
path: ["tabs", "scope"],
|
||||||
|
default: "cwd",
|
||||||
|
values: ["cwd", "global"],
|
||||||
|
labels: ["current directory", "global"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Layout",
|
title: "Layout",
|
||||||
category: "Diffs",
|
category: "Diffs",
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ export const { use: useSessionTabs, provider: SessionTabsProvider } = createSimp
|
||||||
let history: SessionTabHistory = { entries: [], index: -1 }
|
let history: SessionTabHistory = { entries: [], index: -1 }
|
||||||
|
|
||||||
function state() {
|
function state() {
|
||||||
if (config.tabs?.scope !== "cwd") return store.global
|
if (config.tabs?.scope === "global") return store.global
|
||||||
return store.cwd[paths.cwd] ?? fallback
|
return store.cwd[paths.cwd] ?? fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(mutation: (draft: TabsState) => void) {
|
function update(mutation: (draft: TabsState) => void) {
|
||||||
const scope = config.tabs?.scope ?? "global"
|
const scope = config.tabs?.scope ?? "cwd"
|
||||||
void updateStore((draft) => mutation(scope === "cwd" ? (draft.cwd[paths.cwd] ??= empty()) : draft.global)).catch(
|
void updateStore((draft) => mutation(scope === "cwd" ? (draft.cwd[paths.cwd] ??= empty()) : draft.global)).catch(
|
||||||
() => {},
|
() => {},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue