diff --git a/apps/desktop/src-tauri/src/commands/settings.rs b/apps/desktop/src-tauri/src/commands/settings.rs index 298f5b60..3224cce7 100644 --- a/apps/desktop/src-tauri/src/commands/settings.rs +++ b/apps/desktop/src-tauri/src/commands/settings.rs @@ -24,7 +24,7 @@ fn acquire_app_settings_lock() -> std::sync::MutexGuard<'static, ()> { const DESKTOP_STATE_KEY: &str = "desktopState"; const DESKTOP_STATE_VERSION: u64 = 5; const MAX_RECENT_WORKSPACES: usize = 12; -const MIN_PANEL_WIDTH: f64 = 224.0; +const MIN_PANEL_WIDTH: f64 = 148.0; const MAX_PANEL_WIDTH: f64 = 480.0; const DEFAULT_LEFT_PANEL_WIDTH: f64 = 288.0; const DEFAULT_RIGHT_PANEL_WIDTH: f64 = 320.0; diff --git a/apps/desktop/src/commands/commandRegistry.test.ts b/apps/desktop/src/commands/commandRegistry.test.ts index 61a4285f..1f31f60d 100644 --- a/apps/desktop/src/commands/commandRegistry.test.ts +++ b/apps/desktop/src/commands/commandRegistry.test.ts @@ -16,6 +16,8 @@ const commandContext: DesktopCommandContext = { toggleAssistant: () => undefined, toggleBottomPanel: () => undefined, toggleLivePreview: () => undefined, + moveTabLeft: () => undefined, + moveTabRight: () => undefined, revealPanel: () => undefined, revealLeftPanel: () => undefined, openSettings: () => undefined, @@ -25,10 +27,23 @@ const commandContext: DesktopCommandContext = { }; describe("desktop command registry", () => { + it("runs tab movement through the shell and closes the palette", () => { + const moveTabLeft = vi.fn(); + const moveTabRight = vi.fn(); + const closePalette = vi.fn(); + const context = { ...commandContext, moveTabLeft, moveTabRight, closePalette }; + const registry = createDesktopCommandRegistry(); + registry.get("move-tab-left")?.handler(context); + registry.get("move-tab-right")?.handler(context); + expect(moveTabLeft).toHaveBeenCalledOnce(); + expect(moveTabRight).toHaveBeenCalledOnce(); + expect(closePalette).toHaveBeenCalledTimes(2); + }); it("provides the shell commands needed by the command palette", () => { const registry = createDesktopCommandRegistry(); expect(registry.entries().map((command) => command.id)).toEqual([ + "move-tab-left", "move-tab-right", "new-note", "search", "go-back", "go-forward", "toggle-live-preview", "toggle-theme", "toggle-explorer", "toggle-outline", "toggle-assistant", "toggle-bottom-panel", diff --git a/apps/desktop/src/commands/commandRegistry.ts b/apps/desktop/src/commands/commandRegistry.ts index 2949cc3d..8f5101a4 100644 --- a/apps/desktop/src/commands/commandRegistry.ts +++ b/apps/desktop/src/commands/commandRegistry.ts @@ -32,6 +32,8 @@ export interface DesktopCommandContext { readonly toggleAssistant: () => void; readonly toggleBottomPanel: () => void; readonly toggleLivePreview: () => void; + readonly moveTabLeft: () => void; + readonly moveTabRight: () => void; /** Reveals a panel by its fully-qualified id, opening its side popout — either dock. */ readonly revealPanel: (panelId: string) => void; /** Reveals a left-side panel by id; admits registered extension panels too. */ @@ -96,6 +98,18 @@ const withClosePalette = (action: NoArgContextAction) => (context: DesktopComman /** First-party command ownership and availability are explicit and testable. */ export const builtInDesktopCommands: readonly DesktopCommand[] = [ + available({ + id: "move-tab-left", + title: "Move tab left", + keywords: ["reorder"], + handler: withClosePalette("moveTabLeft") + }), + available({ + id: "move-tab-right", + title: "Move tab right", + keywords: ["reorder"], + handler: withClosePalette("moveTabRight") + }), available({ id: "new-note", title: "New note", diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index 359820ec..98c14886 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -186,25 +186,6 @@ } } -/* The explorer header's create actions stay hidden until the header is - hovered, focused into, on a coarse pointer, or has its ⋯ menu open - (`data-open`). Kept as one named state machine rather than variant - classes: a `focus-within:opacity-100` + `opacity-0` pair is exactly what - this is, but class-list conflict checkers can't see the intent. */ -@utility tn-explorer-create-reveal { - opacity: 0; - transition-property: opacity; - transition-duration: 150ms; - .group\/explorer-header:hover &, - &:focus-within, - &[data-open="true"] { - opacity: 1; - } - @media (pointer: coarse) { - opacity: 1; - } -} - /* CodeMirror's internal elements take layout and skin from the host div. Declared here rather than as `[&_.cm-*]` arbitrary variants so the host's own classes (`min-h-0`, `overflow-auto`, `cursor-text`) don't collide diff --git a/apps/desktop/src/settings/SettingsHeaderBar.tsx b/apps/desktop/src/settings/SettingsHeaderBar.tsx index 8fb95b4b..7da2e121 100644 --- a/apps/desktop/src/settings/SettingsHeaderBar.tsx +++ b/apps/desktop/src/settings/SettingsHeaderBar.tsx @@ -150,7 +150,7 @@ export function SettingsHeaderBar({ return (
diff --git a/apps/desktop/src/settings/SettingsImportExport.test.ts b/apps/desktop/src/settings/SettingsImportExport.test.ts index de0ce6a2..95fcb51e 100644 --- a/apps/desktop/src/settings/SettingsImportExport.test.ts +++ b/apps/desktop/src/settings/SettingsImportExport.test.ts @@ -47,6 +47,7 @@ const SEEDED_APP_VALUES: Record = { ...BASE_SEEDED_APP_VALUES, "appearance.shellMode": "auto", "editor.livePreview": true, + "editor.tabCycleOrder": "tab order", "sync.settleAutomatically": true, "sync.historyPolicy": "", "sync.automatically": true, @@ -144,7 +145,7 @@ describe("buildExportPayload", () => { expect(keys).toContain("settings.showAdvanced"); expect(keys).not.toContain("sync.trigger"); expect(keys).not.toContain("sync.destination"); - expect(keys).toHaveLength(19); + expect(keys).toHaveLength(20); }); }); diff --git a/apps/desktop/src/settings/desktopState.test.ts b/apps/desktop/src/settings/desktopState.test.ts index 805d1076..54ff3edb 100644 --- a/apps/desktop/src/settings/desktopState.test.ts +++ b/apps/desktop/src/settings/desktopState.test.ts @@ -114,7 +114,7 @@ describe("desktop state persistence", () => { ) ).toEqual({ ...DEFAULT_DESKTOP_STATE, - leftPanelWidth: 224, + leftPanelWidth: 148, rightPanelWidth: 480, bottomPanelOpen: true }); diff --git a/apps/desktop/src/settings/desktopState.ts b/apps/desktop/src/settings/desktopState.ts index 0bf894ad..2304a59b 100644 --- a/apps/desktop/src/settings/desktopState.ts +++ b/apps/desktop/src/settings/desktopState.ts @@ -4,7 +4,7 @@ import { isRecord } from "@thinkbrain/core"; const DESKTOP_STATE_VERSION = 5; export const DESKTOP_STATE_KEY = "desktopState"; const MAX_RECENT_WORKSPACES = 12; -const MIN_PANEL_WIDTH = 224; +const MIN_PANEL_WIDTH = 148; const MAX_PANEL_WIDTH = 480; export const DEFAULT_LEFT_PANEL_WIDTH = 288; export const DEFAULT_RIGHT_PANEL_WIDTH = 320; diff --git a/apps/desktop/src/shell/DesktopShell.tsx b/apps/desktop/src/shell/DesktopShell.tsx index fea40099..fdc7ccc6 100644 --- a/apps/desktop/src/shell/DesktopShell.tsx +++ b/apps/desktop/src/shell/DesktopShell.tsx @@ -164,7 +164,10 @@ export function DesktopShell({ shell }: { readonly shell: ShellState }) { onForward={() => dispatchTabs({ type: "goForward" })} onSelectTab={(tabId) => dispatchTabs({ type: "activate", tabId })} onRequestCloseTab={(tabId) => dispatchTabs({ type: "requestClose", tabId })} + onCloseOtherTabs={(tabId) => dispatchTabs({ type: "closeMultiple", tabId, scope: "others" })} + onCloseTabsToRight={(tabId) => dispatchTabs({ type: "closeMultiple", tabId, scope: "right" })} onKeepTab={(tabId) => dispatchTabs({ type: "keep", tabId })} + onReorderTab={(tabId, toIndex) => dispatchTabs({ type: "reorder", tabId, toIndex })} onNewTab={() => shell.openNewTab()} onToggleRightPanel={shell.toggleRightPanel} onOpenCommandPalette={shell.openPalette} diff --git a/apps/desktop/src/shell/ResizeHandle.tsx b/apps/desktop/src/shell/ResizeHandle.tsx index 57f7428a..f496d5b1 100644 --- a/apps/desktop/src/shell/ResizeHandle.tsx +++ b/apps/desktop/src/shell/ResizeHandle.tsx @@ -5,9 +5,14 @@ import { cn } from "../lib/utils"; /** * Thin draggable divider between shell panels. * - * Renders a 1px column-resize handle. Pointer and keyboard events are delegated - * to the parent so it can drive the resize logic. Hidden below the 760px - * breakpoint where the multi-column layout collapses. + * Renders a 1px column-resize handle whose *grab area* is wider than its + * visual line: an invisible pseudo-element overhangs 4px into the panels on + * both sides, so the edge is easy to hit without shifting any layout (the + * same overhang VS Code uses). On hover the line thickens via box-shadow — + * also layout-neutral — so the target is visible as well as hittable. + * Pointer and keyboard events are delegated to the parent so it can drive + * the resize logic. Hidden below the 760px breakpoint where the + * multi-column layout collapses. */ export function ResizeHandle({ label, @@ -29,7 +34,10 @@ export function ResizeHandle({ + {/* Square hover chip, matching the back/forward/menu buttons: + the fill makes the hitbox visible and the fixed size keeps + the target easy to hit. Sits a step from the tab's right + edge rather than inside the title's padding. */} ); @@ -394,6 +430,7 @@ export function TitleBar({ onClick={() => onToggleRightPanel(action.id)} onContextMenu={(event) => { event.preventDefault(); + setTabMenu(null); setPinMenu({ x: event.clientX, y: event.clientY, panel: action }); }} /> @@ -407,6 +444,7 @@ export function TitleBar({ className="inline-flex w-[1.6rem] h-[1.6rem] items-center justify-center rounded-small text-titlebar-foreground opacity-40" onContextMenu={(event) => { event.preventDefault(); + setTabMenu(null); setPinMenu({ x: event.clientX, y: event.clientY, panel: action }); }} > @@ -517,6 +555,17 @@ export function TitleBar({ )} + + {tabMenu && ( + setTabMenu(null)} + onRequestCloseTab={onRequestCloseTab} + onCloseOtherTabs={onCloseOtherTabs} + onCloseTabsToRight={onCloseTabsToRight} + /> + )}
); } diff --git a/apps/desktop/src/shell/WorkspaceHeaderBar.tsx b/apps/desktop/src/shell/WorkspaceHeaderBar.tsx index a4ed008a..ff4c5d5d 100644 --- a/apps/desktop/src/shell/WorkspaceHeaderBar.tsx +++ b/apps/desktop/src/shell/WorkspaceHeaderBar.tsx @@ -89,7 +89,7 @@ export function WorkspaceHeaderBar({ return (
diff --git a/apps/desktop/src/shell/useLocationHistory.ts b/apps/desktop/src/shell/useLocationHistory.ts index c36e4585..e778b872 100644 --- a/apps/desktop/src/shell/useLocationHistory.ts +++ b/apps/desktop/src/shell/useLocationHistory.ts @@ -58,6 +58,8 @@ import type { DocumentViewState } from "./shellTypes"; const DEPARTURE_ACTIONS: ReadonlySet = new Set([ "open", "activate", + // A multi-close activates the right-clicked tab first — same departure. + "closeMultiple", "goBack", "goForward", "restoreVisit", diff --git a/apps/desktop/src/shell/useShellCommands.ts b/apps/desktop/src/shell/useShellCommands.ts index 4e255e62..73757fc2 100644 --- a/apps/desktop/src/shell/useShellCommands.ts +++ b/apps/desktop/src/shell/useShellCommands.ts @@ -164,7 +164,9 @@ export function useShellCommands({ // pattern, driven by platform capabilities; this one is live history.) const paletteCommands = useMemo( () => - registeredCommands.map((command) => { + registeredCommands.filter((command) => + !["move-tab-left", "move-tab-right"].includes(command.id) || tabState.tabs.length > 1 + ).map((command) => { const canBack = surfaceAvail?.canGoBack ?? canGoBackInTabs(tabState); const canForward = surfaceAvail?.canGoForward ?? canGoForwardInTabs(tabState); if (command.id === "go-back" && !canBack) { @@ -237,6 +239,14 @@ export function useShellCommands({ toggleAssistant: () => toggleRightPanel("assistant"), toggleBottomPanel, toggleLivePreview, + moveTabLeft: () => dispatchTabs({ + type: "reorder", tabId: tabState.activeTabId ?? "", + toIndex: tabState.tabs.findIndex((tab) => tab.id === tabState.activeTabId) - 1 + }), + moveTabRight: () => dispatchTabs({ + type: "reorder", tabId: tabState.activeTabId ?? "", + toIndex: tabState.tabs.findIndex((tab) => tab.id === tabState.activeTabId) + 1 + }), // `panelId` is an unconstrained string at this boundary (see // `DesktopCommandContext`) so any extension can reveal a panel it // registered; narrow it against the live registry before it reaches @@ -270,7 +280,7 @@ export function useShellCommands({ .catch((error: unknown) => { console.error(`[commandRegistry] Command "${command.id}" failed.`, error); }); - }, [closePalette, dispatchTabs, openSettingsTab, requestNewNoteFocus, selectLeftPanel, setLeftPanel, setRightPanel, setTheme, showExplorer, theme, toggleBottomPanel, toggleLivePreview, toggleRightPanel]); + }, [closePalette, dispatchTabs, openSettingsTab, requestNewNoteFocus, selectLeftPanel, setLeftPanel, setRightPanel, setTheme, showExplorer, theme, toggleBottomPanel, toggleLivePreview, toggleRightPanel, tabState.activeTabId, tabState.tabs]); return { closePalette, diff --git a/apps/desktop/src/shell/useShellShortcuts.test.tsx b/apps/desktop/src/shell/useShellShortcuts.test.tsx index 4df6493e..fb0c2b60 100644 --- a/apps/desktop/src/shell/useShellShortcuts.test.tsx +++ b/apps/desktop/src/shell/useShellShortcuts.test.tsx @@ -4,7 +4,8 @@ import { createRoot, type Root } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import type { DesktopCommandContext } from "../commands/commandRegistry"; -import { initialDesktopTabState, type DesktopTabAction } from "../tabs/tabModel"; +import { createEditorTab, initialDesktopTabState, type DesktopTabAction } from "../tabs/tabModel"; +import { appSettingsRegistry, useSettingsStore } from "../settings/settingsStore"; import { useCommandSurface } from "./useShellCommands"; import { useShellShortcuts, type ShellShortcutsProps } from "./useShellShortcuts"; @@ -72,6 +73,47 @@ afterEach(async () => { root = null; container?.remove(); container = null; + vi.restoreAllMocks(); +}); + +describe("useShellShortcuts tab cycling", () => { + const tabs = ["a", "b", "c"].map((name) => + createEditorTab({ rootPath: "/notes", relativePath: `${name}.md` }) + ); + + it("cycles forward/reverse from editable targets and prevents default", async () => { + dispatchTabs = vi.fn(); + await mount({ tabState: { ...initialDesktopTabState, tabs, activeTabId: tabs[0]!.id } }); + const input = document.createElement("input"); + document.body.append(input); + const forward = new KeyboardEvent("keydown", { key: "Tab", ctrlKey: true, bubbles: true, cancelable: true }); + await act(async () => { input.dispatchEvent(forward); }); + expect(forward.defaultPrevented).toBe(true); + await keydown({ key: "Tab", ctrlKey: true, shiftKey: true }, input); + input.remove(); + expect(dispatchTabs).toHaveBeenNthCalledWith(1, { type: "activate", tabId: tabs[1]!.id }); + expect(dispatchTabs).toHaveBeenNthCalledWith(2, { type: "activate", tabId: tabs[2]!.id }); + }); + + it("reads the registered setting at keypress time, including the explicit MRU fallback", async () => { + expect(appSettingsRegistry.getDefinition("editor.tabCycleOrder")?.default).toBe("tab order"); + const getEffectiveValue = vi.spyOn(useSettingsStore.getState(), "getEffectiveValue"); + getEffectiveValue.mockReturnValue("last visited"); + dispatchTabs = vi.fn(); + await mount({ tabState: { ...initialDesktopTabState, tabs, activeTabId: tabs[1]!.id } }); + await keydown({ key: "Tab", ctrlKey: true }); + expect(getEffectiveValue).toHaveBeenCalledWith("editor.tabCycleOrder"); + expect(dispatchTabs).toHaveBeenCalledExactlyOnceWith({ type: "activate", tabId: tabs[2]!.id }); + }); + + it("ignores bare Tab and Alt-modified chords and safely handles no tabs", async () => { + dispatchTabs = vi.fn(); + await mount(); + await keydown({ key: "Tab" }); + await keydown({ key: "Tab", ctrlKey: true, altKey: true }); + await keydown({ key: "Tab", ctrlKey: true }); + expect(dispatchTabs).not.toHaveBeenCalled(); + }); }); describe("useShellShortcuts history navigation", () => { diff --git a/apps/desktop/src/shell/useShellShortcuts.ts b/apps/desktop/src/shell/useShellShortcuts.ts index b8ec50a4..d56b3834 100644 --- a/apps/desktop/src/shell/useShellShortcuts.ts +++ b/apps/desktop/src/shell/useShellShortcuts.ts @@ -11,6 +11,8 @@ import { useEffect, type Dispatch } from "react"; import type { DesktopTab, DesktopTabAction, DesktopTabState } from "../tabs/tabModel"; +import { nextCycledTabId } from "../tabs/tabCycle"; +import { useSettingsStore } from "../settings/settingsStore"; import type { LeftPanel } from "./shellTypes"; import { commandSurfaceEffect } from "./useShellCommands"; @@ -77,16 +79,16 @@ export function useShellShortcuts({ const onKeyDown = (event: KeyboardEvent) => { const modifier = event.ctrlKey || event.metaKey; const isTab = event.key === "Tab"; - if (modifier && isTab) { + if (modifier && isTab && !event.altKey) { event.preventDefault(); event.stopPropagation(); - if (tabState.tabs.length > 1) { - const currentIndex = tabState.tabs.findIndex((t) => t.id === tabState.activeTabId); - const delta = event.shiftKey ? -1 : 1; - const nextIndex = (currentIndex + delta + tabState.tabs.length) % tabState.tabs.length; - const nextTab = tabState.tabs[nextIndex]; - if (nextTab) dispatchTabs({ type: "activate", tabId: nextTab.id }); - } + const setting = useSettingsStore.getState().getEffectiveValue("editor.tabCycleOrder"); + const nextId = nextCycledTabId( + tabState.tabs, tabState.activeTabId, + setting === "last visited" ? "last visited" : "tab order", + event.shiftKey ? -1 : 1 + ); + if (nextId !== null) dispatchTabs({ type: "activate", tabId: nextId }); return; } if (modifier && event.key.toLowerCase() === "p") { diff --git a/apps/desktop/src/shell/useTabStripDrag.test.tsx b/apps/desktop/src/shell/useTabStripDrag.test.tsx new file mode 100644 index 00000000..0a4a1bbb --- /dev/null +++ b/apps/desktop/src/shell/useTabStripDrag.test.tsx @@ -0,0 +1,153 @@ +// @vitest-environment happy-dom +import { act, useEffect, useRef } from "react"; +import { createRoot, type Root } from "react-dom/client"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { createStaticTab } from "../tabs/tabModel"; +import { crossedTabDragThreshold, tabDragTarget, tabEdgeScroll, useTabStripDrag } from "./useTabStripDrag"; + +const slots = [ + { id: "a", left: 0, width: 100 }, + { id: "b", left: 102, width: 100 }, + { id: "c", left: 204, width: 100 } +]; + +describe("tab drag geometry", () => { + it("keeps presses below 6px as clicks", () => { + expect(crossedTabDragThreshold(5, 0)).toBe(false); + expect(crossedTabDragThreshold(3, 4)).toBe(false); + expect(crossedTabDragThreshold(-6, 0)).toBe(true); + expect(crossedTabDragThreshold(0, 6)).toBe(true); + }); + + it("crosses other tab midpoints, excluding the source slot", () => { + expect(tabDragTarget(slots, "b", 152)).toBe(1); + expect(tabDragTarget(slots, "a", 151)).toBe(0); + expect(tabDragTarget(slots, "a", 153)).toBe(1); + expect(tabDragTarget(slots, "a", 255)).toBe(2); + expect(tabDragTarget(slots, "c", -100)).toBe(0); + expect(tabDragTarget(slots, "a", 1000)).toBe(2); + }); + + it("scrolls only near edges and bounds its speed", () => { + expect(tabEdgeScroll(150, 0, 300)).toBe(0); + expect(tabEdgeScroll(0, 0, 300)).toBe(-12); + expect(tabEdgeScroll(400, 0, 300)).toBe(12); + expect(tabEdgeScroll(282, 0, 300)).toBe(6); + }); +}); + +let root: Root | null = null; +let host: HTMLDivElement | null = null; +const tabs = slots.map((slot) => ({ ...createStaticTab("settings", slot.id), id: slot.id })); +const reorder = vi.fn(); +let suppressClick = () => false; + +function Probe() { + const ref = useRef(null); + const drag = useTabStripDrag(ref, tabs, reorder); + useEffect(() => { suppressClick = drag.suppressClick; }); + return ; +} + +async function mount() { + vi.spyOn(window, "requestAnimationFrame").mockReturnValue(1); + host = document.createElement("div"); + document.body.append(host); + root = createRoot(host); + await act(async () => root?.render()); + const buttons = Array.from(host.querySelectorAll("button")); + buttons.forEach((button, index) => { + const slot = slots[index]!; + vi.spyOn(button, "getBoundingClientRect").mockReturnValue( + { left: slot.left, width: slot.width } as DOMRect + ); + }); + return buttons[0]!; +} + +async function pointer(target: EventTarget, type: string, x: number, pointerType = "mouse") { + await act(async () => { + target.dispatchEvent(new PointerEvent(type, { + bubbles: true, cancelable: true, pointerId: 1, pointerType, button: 0, clientX: x + })); + }); +} + +afterEach(async () => { + await act(async () => root?.unmount()); + host?.remove(); + root = null; + vi.restoreAllMocks(); + reorder.mockClear(); +}); + +describe("tab drag session", () => { + it("does not commit or suppress a click below threshold", async () => { + const button = await mount(); + await pointer(button, "pointerdown", 50); + await pointer(window, "pointermove", 55); + await pointer(window, "pointerup", 55); + expect(reorder).not.toHaveBeenCalled(); + expect(suppressClick()).toBe(false); + }); + + it("previews displacement then commits once and suppresses the trailing click", async () => { + const button = await mount(); + await pointer(button, "pointerdown", 50); + await pointer(window, "pointermove", 270); + expect(button.style.transform).toBe("translateX(220px)"); + expect(host?.querySelectorAll("button")[1]?.style.transform).toBe("translateX(-100px)"); + expect(reorder).not.toHaveBeenCalled(); + await pointer(window, "pointerup", 270); + expect(reorder).toHaveBeenCalledExactlyOnceWith(tabs[0]!.id, 2); + expect(suppressClick()).toBe(true); + expect(button.style.transform).toBe(""); + await pointer(window, "pointerup", 270); + expect(reorder).toHaveBeenCalledTimes(1); + }); + + it("cancels on Escape and ignores touch", async () => { + const button = await mount(); + await pointer(button, "pointerdown", 50, "touch"); + await pointer(window, "pointermove", 270, "touch"); + await pointer(window, "pointerup", 270, "touch"); + expect(reorder).not.toHaveBeenCalled(); + await pointer(button, "pointerdown", 50); + await pointer(window, "pointermove", 270); + await act(async () => { window.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" })); }); + await pointer(window, "pointerup", 270); + expect(reorder).not.toHaveBeenCalled(); + expect(button.style.transform).toBe(""); + }); + + it("accounts for edge scrolling while the pointer stays still", async () => { + const button = await mount(); + const strip = host!.querySelector("nav")!; + vi.spyOn(strip, "getBoundingClientRect").mockReturnValue({ left: 0, right: 200 } as DOMRect); + await pointer(button, "pointerdown", 50); + await pointer(window, "pointermove", 190); + const tick = vi.mocked(window.requestAnimationFrame).mock.calls.at(-1)![0]; + await act(async () => tick(16)); + expect(strip.scrollLeft).toBeGreaterThan(0); + expect(button.style.transform).not.toBe("translateX(140px)"); + await pointer(window, "pointerup", 190); + expect(reorder).toHaveBeenCalledExactlyOnceWith(tabs[0]!.id, 1); + }); + + it("restores selection and removes listeners on unmount", async () => { + document.body.style.userSelect = "text"; + const button = await mount(); + await pointer(button, "pointerdown", 50, "pen"); + await pointer(window, "pointermove", 270, "pen"); + expect(document.body.style.userSelect).toBe("none"); + await act(async () => root?.unmount()); + root = null; + expect(document.body.style.userSelect).toBe("text"); + await pointer(window, "pointerup", 270, "pen"); + expect(reorder).not.toHaveBeenCalled(); + document.body.style.userSelect = ""; + }); +}); diff --git a/apps/desktop/src/shell/useTabStripDrag.ts b/apps/desktop/src/shell/useTabStripDrag.ts new file mode 100644 index 00000000..2bb2b34a --- /dev/null +++ b/apps/desktop/src/shell/useTabStripDrag.ts @@ -0,0 +1,154 @@ +import { useEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent, type RefObject } from "react"; +import type { DesktopTab } from "../tabs/tabModel"; + +export const crossedTabDragThreshold = (dx: number, dy: number): boolean => Math.hypot(dx, dy) >= 6; + +export interface TabSlot { + readonly id: string; + readonly left: number; + readonly width: number; +} + +/** Slots stay in content coordinates, unaffected by scrolling or preview transforms. */ +export function tabDragTarget(slots: readonly TabSlot[], tabId: string, center: number): number { + return slots.filter((slot) => slot.id !== tabId && center > slot.left + slot.width / 2).length; +} + +export function tabEdgeScroll(x: number, left: number, right: number): number { + const edge = Math.min(36, (right - left) / 2); + if (edge <= 0) return 0; + if (x < left + edge) return -Math.min(1, (left + edge - x) / edge) * 12; + if (x > right - edge) return Math.min(1, (x - right + edge) / edge) * 12; + return 0; +} + +interface Preview { + readonly tabId: string; + readonly from: number; + readonly to: number; + readonly dx: number; + readonly stride: number; +} + +export function useTabStripDrag( + stripRef: RefObject, + tabs: readonly DesktopTab[], + onReorder: (tabId: string, toIndex: number) => void +) { + const [preview, setPreview] = useState(null); + const cleanupRef = useRef<(() => void) | null>(null); + const suppressedUntil = useRef(0); + const reorderRef = useRef(onReorder); + useEffect(() => { reorderRef.current = onReorder; }, [onReorder]); + useEffect(() => () => cleanupRef.current?.(), [tabs]); + + const onPointerDown = (event: ReactPointerEvent, tabId: string) => { + if (event.button !== 0 || !["mouse", "pen"].includes(event.pointerType) || tabs.length < 2) return; + cleanupRef.current?.(); + const strip = stripRef.current; + if (!strip) return; + const slots = Array.from(strip.querySelectorAll("[data-tab-id]"), (element) => ({ + id: element.dataset.tabId!, + left: element.getBoundingClientRect().left - strip.getBoundingClientRect().left + strip.scrollLeft, + width: element.getBoundingClientRect().width + })); + const from = slots.findIndex((slot) => slot.id === tabId); + const source = slots[from]; + if (!source) return; + const pointerId = event.pointerId; + const startX = event.clientX; + const startY = event.clientY; + const startScroll = strip.scrollLeft; + let x = startX; + let dragging = false; + let to = from; + let frame = 0; + const previousUserSelect = document.body.style.userSelect; + + const update = () => { + const dx = x - startX + strip.scrollLeft - startScroll; + to = tabDragTarget(slots, tabId, source.left + source.width / 2 + dx); + const gap = Number.parseFloat(getComputedStyle(strip).columnGap) || 0; + const stride = source.width + gap; + setPreview((previous) => + previous?.tabId === tabId && previous.to === to && previous.dx === dx && previous.stride === stride + ? previous : { tabId, from, to, dx, stride } + ); + }; + const tick = () => { + const rect = strip.getBoundingClientRect(); + strip.scrollLeft += tabEdgeScroll(x, rect.left, rect.right); + update(); + frame = requestAnimationFrame(tick); + }; + const cleanup = () => { + cancelAnimationFrame(frame); + window.removeEventListener("pointermove", move); + window.removeEventListener("pointerup", up); + window.removeEventListener("pointercancel", cancel); + window.removeEventListener("keydown", key); + window.removeEventListener("blur", cancel); + document.body.style.userSelect = previousUserSelect; + if (dragging) suppressedUntil.current = performance.now() + 400; + setPreview(null); + cleanupRef.current = null; + }; + const move = (e: PointerEvent) => { + if (e.pointerId !== pointerId) return; + x = e.clientX; + if (!dragging && crossedTabDragThreshold(x - startX, e.clientY - startY)) { + dragging = true; + document.body.style.userSelect = "none"; + frame = requestAnimationFrame(tick); + } + if (!dragging) return; + e.preventDefault(); + update(); + }; + const up = (e: PointerEvent) => { + if (e.pointerId !== pointerId) return; + if (dragging) { + x = e.clientX; + update(); + e.preventDefault(); + reorderRef.current(tabId, to); + } + cleanup(); + }; + const cancel = (e: Event) => { + if (e instanceof PointerEvent && e.pointerId !== pointerId) return; + cleanup(); + }; + const key = (e: KeyboardEvent) => { + if (e.key === "Escape") { + e.preventDefault(); + cleanup(); + } + }; + window.addEventListener("pointermove", move, { passive: false }); + window.addEventListener("pointerup", up); + window.addEventListener("pointercancel", cancel); + window.addEventListener("keydown", key); + window.addEventListener("blur", cancel); + cleanupRef.current = cleanup; + }; + + const tabStyle = (index: number): CSSProperties | undefined => { + if (!preview) return undefined; + const { from, to, dx, stride } = preview; + const offset = index === from ? dx + : from < index && index <= to ? -stride + : to <= index && index < from ? stride : 0; + return { + transform: `translateX(${offset}px)`, + transition: index === from ? "none" : "transform 150ms ease" + }; + }; + + return { + draggedTabId: preview?.tabId ?? null, + onPointerDown, + tabStyle, + suppressClick: () => performance.now() < suppressedUntil.current + }; +} diff --git a/apps/desktop/src/tabs/tabClose.test.ts b/apps/desktop/src/tabs/tabClose.test.ts new file mode 100644 index 00000000..a922677a --- /dev/null +++ b/apps/desktop/src/tabs/tabClose.test.ts @@ -0,0 +1,95 @@ +import { describe, expect, it } from "vitest"; +import { + createEditorTab, + desktopTabReducer, + initialDesktopTabState, + type DesktopTabState +} from "./tabModel"; + +const open = (state: DesktopTabState, name: string): DesktopTabState => + desktopTabReducer(state, { + type: "open", + tab: createEditorTab({ rootPath: "/notes", relativePath: `${name}.md` }) + }); + +const withTabs = (...names: readonly string[]): DesktopTabState => + names.reduce(open, initialDesktopTabState); + +const ids = (state: DesktopTabState): readonly string[] => state.tabs.map((tab) => tab.id); + +describe("closeMultiple", () => { + it("closes every clean tab except the clicked one and activates it", () => { + const state = withTabs("a", "b", "c"); + const target = state.tabs[0]!; + + const next = desktopTabReducer(state, { type: "closeMultiple", tabId: target.id, scope: "others" }); + + expect(ids(next)).toEqual([target.id]); + // The right-clicked tab is the survivor on screen, even though it was + // not the active one when the action landed. + expect(next.activeTabId).toBe(target.id); + }); + + it("closes only the clean tabs to the right of the clicked tab", () => { + const state = withTabs("a", "b", "c", "d"); + const target = state.tabs[1]!; + + const next = desktopTabReducer(state, { type: "closeMultiple", tabId: target.id, scope: "right" }); + + expect(ids(next)).toEqual([state.tabs[0]!.id, target.id]); + expect(next.activeTabId).toBe(target.id); + }); + + it("skips dirty targets instead of confirming them", () => { + let state = withTabs("a", "b", "c"); + const dirty = state.tabs[2]!; + state = desktopTabReducer(state, { type: "setDirty", tabId: dirty.id, isDirty: true }); + const target = state.tabs[0]!; + + const next = desktopTabReducer(state, { type: "closeMultiple", tabId: target.id, scope: "others" }); + + // b is gone; the dirty tab stays — closing it needs the dialog the + // menu declines to bypass. + expect(ids(next)).toEqual([target.id, dirty.id]); + expect(next.tabs[1]!.isDirty).toBe(true); + expect(next.activeTabId).toBe(target.id); + }); + + it("scrubs closed trails from history without touching the survivors'", () => { + const state = withTabs("a", "b", "c"); + const target = state.tabs[0]!; + + const next = desktopTabReducer(state, { type: "closeMultiple", tabId: target.id, scope: "others" }); + + // Only the surviving trail keeps visits; the cursor sits on its entry. + expect(next.history.entries).toHaveLength(1); + expect(next.history.entries[0]!.tab.id).toBe(target.id); + expect(next.history.cursor).toBe(0); + }); + + it("keeps a parked close request whose dirty tab survived", () => { + let state = withTabs("a", "b", "c"); + const dirty = state.tabs[2]!; + state = desktopTabReducer(state, { type: "setDirty", tabId: dirty.id, isDirty: true }); + state = desktopTabReducer(state, { type: "requestClose", tabId: dirty.id }); + expect(state.closeRequest?.tabId).toBe(dirty.id); + const target = state.tabs[0]!; + + const next = desktopTabReducer(state, { type: "closeMultiple", tabId: target.id, scope: "others" }); + + expect(ids(next)).toEqual([target.id, dirty.id]); + // The unanswered dialog belongs to a tab that is still open — it must + // not be swallowed by the removals around it. + expect(next.closeRequest?.tabId).toBe(dirty.id); + }); + + it("is a no-op for an unknown tab", () => { + const state = withTabs("a", "b"); + expect( + desktopTabReducer(state, { type: "closeMultiple", tabId: "missing", scope: "others" }) + ).toBe(state); + expect( + desktopTabReducer(state, { type: "closeMultiple", tabId: "missing", scope: "right" }) + ).toBe(state); + }); +}); diff --git a/apps/desktop/src/tabs/tabClose.ts b/apps/desktop/src/tabs/tabClose.ts new file mode 100644 index 00000000..0599e70d --- /dev/null +++ b/apps/desktop/src/tabs/tabClose.ts @@ -0,0 +1,42 @@ +import { activateExistingTab, removeTab } from "./tabHistory"; +import type { DesktopTabState } from "./tabModel"; + +/** Which neighbours of `tabId` a multi-close targets. */ +type TabCloseScope = "others" | "right"; + +export interface TabCloseMultipleAction { + readonly type: "closeMultiple"; + readonly tabId: string; + readonly scope: TabCloseScope; +} + +/** + * "Close other tabs" / "Close tabs to the right" from a tab's context menu. + * + * The clicked tab becomes the survivor on screen first — VS Code semantics — + * so `activeTabId` stays valid no matter which neighbours go. Dirty targets + * are *skipped*, not confirmed: no multi-tab dirty guard exists, and the menu + * refuses the action when one sits in the target set. Each removal runs the + * ordinary single-close helper, so trail scrubbing and preview handling can + * never drift from the close chip's behaviour. + */ +export function closeMultipleTabs( + state: DesktopTabState, + { tabId, scope }: TabCloseMultipleAction +): DesktopTabState { + const index = state.tabs.findIndex((tab) => tab.id === tabId); + if (index < 0) return state; + let next = activateExistingTab(state, tabId); + const targets = next.tabs.filter((tab, i) => { + if (tab.id === tabId || tab.isDirty) return false; + return scope === "others" || i > index; + }); + for (const tab of targets) next = removeTab(next, tab.id); + // removeTab clears closeRequest unconditionally; a request parked on a + // surviving (dirty) tab must keep its dialog rather than be swallowed. + const request = next.closeRequest ?? state.closeRequest; + if (request && next.tabs.some((tab) => tab.id === request.tabId)) { + next = { ...next, closeRequest: request }; + } + return next; +} diff --git a/apps/desktop/src/tabs/tabCycle.test.ts b/apps/desktop/src/tabs/tabCycle.test.ts new file mode 100644 index 00000000..2a85df3a --- /dev/null +++ b/apps/desktop/src/tabs/tabCycle.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from "vitest"; +import { nextCycledTabId, type TabCycleOrder } from "./tabCycle"; + +const tabs = [{ id: "a" }, { id: "b" }, { id: "c" }]; + +describe("tab cycling", () => { + it("cycles in strip order in either direction and wraps", () => { + expect(nextCycledTabId(tabs, "a", "tab order", 1)).toBe("b"); + expect(nextCycledTabId(tabs, "b", "tab order", -1)).toBe("a"); + expect(nextCycledTabId(tabs, "c", "tab order", 1)).toBe("a"); + expect(nextCycledTabId(tabs, "a", "tab order", -1)).toBe("c"); + }); + + it("follows reordered tabs without mutating the input", () => { + const reordered = [tabs[2]!, tabs[0]!, tabs[1]!]; + expect(nextCycledTabId(reordered, "c", "tab order", 1)).toBe("a"); + expect(reordered).toEqual([tabs[2], tabs[0], tabs[1]]); + }); + + it("explicitly falls back to strip order for the unimplemented MRU mode", () => { + expect(nextCycledTabId(tabs, "b", "last visited", 1)).toBe("c"); + expect(nextCycledTabId(tabs, "a", "last visited", -1)).toBe("c"); + }); + + it.each(["tab order", "last visited"])("handles empty, single, and missing selection in %s mode", (mode) => { + expect(nextCycledTabId([], null, mode, 1)).toBeNull(); + expect(nextCycledTabId([tabs[0]!], "a", mode, -1)).toBeNull(); + expect(nextCycledTabId(tabs, null, mode, 1)).toBe("a"); + expect(nextCycledTabId(tabs, "missing", mode, -1)).toBe("c"); + }); +}); diff --git a/apps/desktop/src/tabs/tabCycle.ts b/apps/desktop/src/tabs/tabCycle.ts new file mode 100644 index 00000000..aede0d68 --- /dev/null +++ b/apps/desktop/src/tabs/tabCycle.ts @@ -0,0 +1,24 @@ +import type { DesktopTab } from "./tabModel"; + +export type TabCycleOrder = "tab order" | "last visited"; + +/** Null means there is no other tab to select. Missing selection starts at the matching end. */ +export function nextCycledTabId( + tabs: readonly Pick[], + activeTabId: string | null, + mode: TabCycleOrder, + direction: -1 | 1 +): string | null { + if (tabs.length < 2) return null; + // MRU needs a separate activation ledger: location history restores old visits + // without recording recency. Until then the setting explicitly falls back. + switch (mode) { + case "last visited": + case "tab order": { + const current = tabs.findIndex((tab) => tab.id === activeTabId); + const index = current < 0 ? (direction === 1 ? 0 : tabs.length - 1) + : (current + direction + tabs.length) % tabs.length; + return tabs[index]!.id; + } + } +} diff --git a/apps/desktop/src/tabs/tabModel.ts b/apps/desktop/src/tabs/tabModel.ts index fffbf4ad..69526680 100644 --- a/apps/desktop/src/tabs/tabModel.ts +++ b/apps/desktop/src/tabs/tabModel.ts @@ -1,6 +1,8 @@ import type { Tab, TabKind, TabResource } from "@thinkbrain/core"; import { inferTabKind } from "@thinkbrain/core"; import type { ChangeDesc } from "@codemirror/state"; +import { reorderTab, type TabReorderAction } from "./tabReorder"; +import { closeMultipleTabs, type TabCloseMultipleAction } from "./tabClose"; import { activateExistingTab, @@ -84,15 +86,11 @@ export function isDocumentBackedKind(kind: string): boolean { return DOCUMENT_BACKED_KINDS.has(kind); } -interface CloseRequest { - readonly tabId: string; -} - export interface DesktopTabState { readonly tabs: readonly DesktopTab[]; readonly activeTabId: string | null; /** Present only when a dirty tab needs a save/discard/cancel decision. */ - readonly closeRequest: CloseRequest | null; + readonly closeRequest: { readonly tabId: string } | null; readonly history: DesktopTabHistory; } @@ -111,6 +109,8 @@ export interface DesktopTabState { export type TabOpenPlacement = "new" | "preview" | "replace-active"; export type DesktopTabAction = + | TabReorderAction + | TabCloseMultipleAction | { readonly type: "open"; readonly tab: DesktopTab; readonly placement?: TabOpenPlacement } | { readonly type: "keep"; readonly tabId: string } | { readonly type: "activate"; readonly tabId: string } @@ -358,6 +358,8 @@ export function desktopTabReducer( action: DesktopTabAction ): DesktopTabState { switch (action.type) { + case "reorder": return reorderTab(state, action); + case "closeMultiple": return closeMultipleTabs(state, action); case "open": { const prepared = prepareTabOpen(state, action.tab, action.placement); if (prepared.kind === "noop") return state; diff --git a/apps/desktop/src/tabs/tabReorder.test.ts b/apps/desktop/src/tabs/tabReorder.test.ts new file mode 100644 index 00000000..49f55527 --- /dev/null +++ b/apps/desktop/src/tabs/tabReorder.test.ts @@ -0,0 +1,33 @@ +import { describe, expect, it } from "vitest"; +import { createEditorTab, desktopTabReducer, initialDesktopTabState } from "./tabModel"; + +const state = ["a", "b", "c"].reduce( + (current, title) => desktopTabReducer(current, { + type: "open", tab: createEditorTab({ rootPath: "/notes", relativePath: `${title}.md` }) + }), + initialDesktopTabState +); + +describe("tab reorder", () => { + it("moves in both directions without changing identities, selection, or history", () => { + const moved = desktopTabReducer(state, { type: "reorder", tabId: state.tabs[0]!.id, toIndex: 2 }); + expect(moved.tabs).toEqual([state.tabs[1], state.tabs[2], state.tabs[0]]); + expect(moved.tabs[2]).toBe(state.tabs[0]); + expect(moved.activeTabId).toBe(state.activeTabId); + expect(moved.history).toBe(state.history); + expect(moved.closeRequest).toBe(state.closeRequest); + const restored = desktopTabReducer(moved, { type: "reorder", tabId: state.tabs[0]!.id, toIndex: 0 }); + expect(restored.tabs).toEqual(state.tabs); + }); + + it("clamps out-of-range indices and safely ignores invalid inputs", () => { + const first = state.tabs[0]!.id; + expect(desktopTabReducer(state, { type: "reorder", tabId: first, toIndex: -100 })).toBe(state); + expect(desktopTabReducer(state, { type: "reorder", tabId: first, toIndex: 100 }).tabs.at(-1)?.id).toBe(first); + for (const toIndex of [NaN, Infinity, -Infinity]) { + expect(desktopTabReducer(state, { type: "reorder", tabId: first, toIndex })).toBe(state); + } + expect(desktopTabReducer(state, { type: "reorder", tabId: "missing", toIndex: 1 })).toBe(state); + expect(desktopTabReducer(initialDesktopTabState, { type: "reorder", tabId: first, toIndex: 0 })).toBe(initialDesktopTabState); + }); +}); diff --git a/apps/desktop/src/tabs/tabReorder.ts b/apps/desktop/src/tabs/tabReorder.ts new file mode 100644 index 00000000..0773ad47 --- /dev/null +++ b/apps/desktop/src/tabs/tabReorder.ts @@ -0,0 +1,19 @@ +import type { DesktopTabState } from "./tabModel"; + +export interface TabReorderAction { + readonly type: "reorder"; + readonly tabId: string; + readonly toIndex: number; +} + +/** Reordering is purely visual: preserve tab objects and the entire navigation ledger. */ +export function reorderTab(state: DesktopTabState, { tabId, toIndex }: TabReorderAction): DesktopTabState { + const from = state.tabs.findIndex((tab) => tab.id === tabId); + if (from < 0 || !Number.isFinite(toIndex)) return state; + const to = Math.max(0, Math.min(state.tabs.length - 1, Math.trunc(toIndex))); + if (from === to) return state; + const tabs = [...state.tabs]; + const [tab] = tabs.splice(from, 1); + tabs.splice(to, 0, tab!); + return { ...state, tabs }; +} diff --git a/apps/desktop/src/workspace/WorkspaceExplorer.create.test.tsx b/apps/desktop/src/workspace/WorkspaceExplorer.create.test.tsx index 6b37351c..aa59249b 100644 --- a/apps/desktop/src/workspace/WorkspaceExplorer.create.test.tsx +++ b/apps/desktop/src/workspace/WorkspaceExplorer.create.test.tsx @@ -622,6 +622,8 @@ describe("desktop canonical New note command integration", () => { toggleAssistant: vi.fn(), toggleBottomPanel: vi.fn(), toggleLivePreview: vi.fn(), + moveTabLeft: vi.fn(), + moveTabRight: vi.fn(), revealPanel: vi.fn(), revealLeftPanel: vi.fn(), openSettings: vi.fn(), diff --git a/apps/desktop/src/workspace/WorkspaceExplorerView.tsx b/apps/desktop/src/workspace/WorkspaceExplorerView.tsx index 4ef55bbe..2de131a9 100644 --- a/apps/desktop/src/workspace/WorkspaceExplorerView.tsx +++ b/apps/desktop/src/workspace/WorkspaceExplorerView.tsx @@ -150,8 +150,7 @@ export function WorkspaceExplorerView({

{drag.announcement}

{/* One chrome row: the selector trigger when it lives in panel headers, otherwise the plain "Files" label — the root path survives - as its tooltip. Create icons hover-reveal on fine pointers; the ⋯ - menu is always visible so the row never looks action-less. */} + as its tooltip. */}
{showInlineSelector ? ( @@ -166,10 +165,7 @@ export function WorkspaceExplorerView({ )}
-
+
- {/* Always visible, unlike the hover-reveal create icons: ordering - is a standing preference, not an occasional action. */} + {/* Ordering is a standing preference, not an occasional action. */} { + const registry = createSettingsRegistry(); + registry.register(editorModule); + + it("registers app-scoped cycling with tab order as the default and an explicit MRU stub", () => { + expect(registry.getDefinition("editor.tabCycleOrder")).toMatchObject({ + type: "enum", + options: ["tab order", "last visited"], + default: "tab order", + scope: "app", + section: "editor.tabs" + }); + expect(registry.getDefinition("editor.tabCycleOrder")?.description).toContain("not yet implemented"); + }); + + it("accepts both registered modes and rejects unknown modes", () => { + expect(validateSettings(registry, { "editor.tabCycleOrder": "tab order" })).toEqual([]); + expect(validateSettings(registry, { "editor.tabCycleOrder": "last visited" })).toEqual([]); + expect(validateSettings(registry, { "editor.tabCycleOrder": "random" })).toHaveLength(1); + }); +}); diff --git a/packages/core/src/settings/modules/editor.ts b/packages/core/src/settings/modules/editor.ts index fdd3e636..5951b0cd 100644 --- a/packages/core/src/settings/modules/editor.ts +++ b/packages/core/src/settings/modules/editor.ts @@ -52,6 +52,23 @@ export const editorModule: SettingsModule = { "Render Markdown formatted inline, showing raw syntax only where the cursor is." } ] + }, + { + id: "editor.tabs", + label: "Tabs", + settings: [ + { + key: "tabCycleOrder", + type: "enum", + options: ["tab order", "last visited"], + default: "tab order", + scope: "app", + section: "editor.tabs", + label: "Tab cycling order", + description: + "Order for Ctrl+Tab and Ctrl+Shift+Tab. Last visited is not yet implemented; both modes currently use tab order." + } + ] } ] }; diff --git a/packages/core/src/settings/registry.test.ts b/packages/core/src/settings/registry.test.ts index 79e4338a..f4dd3a5e 100644 --- a/packages/core/src/settings/registry.test.ts +++ b/packages/core/src/settings/registry.test.ts @@ -450,6 +450,7 @@ describe("extractDefaults", () => { "editor.fontSize": 16, "editor.lineWrapping": true, "editor.livePreview": true, + "editor.tabCycleOrder": "tab order", "settings.autosave": false, "settings.showAdvanced": false, "sync.automatically": true,