diff --git a/src/app/displayable.ts b/src/app/displayable.ts index 4f8a7ef..b6a5796 100644 --- a/src/app/displayable.ts +++ b/src/app/displayable.ts @@ -22,7 +22,7 @@ export abstract class Displayable { setTimeout(() => this.installHandlers(0), 0); // Add general shortcuts - this.addShortcut("Ctrl-w", () => this.close()); + this.addShortcut("Alt-w", () => this.close()); this.addShortcut("Alt--", () => this.changeWidth(-100)); this.addShortcut("Alt-=", () => this.changeWidth(100)); } diff --git a/src/app/editor.ts b/src/app/editor.ts index 6bd62f4..a88c137 100644 --- a/src/app/editor.ts +++ b/src/app/editor.ts @@ -19,7 +19,7 @@ import { crosshairCursor, showPanel, } from "@codemirror/view"; -import { defaultKeymap, undo, redo } from "@codemirror/commands"; +import { defaultKeymap, undo, redo, indentWithTab } from "@codemirror/commands"; import { oneDark } from "@codemirror/theme-one-dark"; import { LanguageDescription, @@ -110,6 +110,7 @@ export class Editor extends Displayable { ...findReferencesKeymap, ...formatKeymap, ...renameKeymap, + indentWithTab, { key: "Mod-z", run: () => undo(file.target) }, { key: "Mod-shift-z", run: () => redo(file.target) }, { diff --git a/src/app/editorgrid.ts b/src/app/editorgrid.ts index 2ee262e..b36edff 100644 --- a/src/app/editorgrid.ts +++ b/src/app/editorgrid.ts @@ -17,28 +17,34 @@ const EditorWrapper = ( van.derive(() => { if (!editor || !editor.val) return; - const wrappedDelete = () => { - // TODO: find a better way to get the list containing this EditorWrapper + const findLeft = () => { const list = editors[currentTab.val] || []; - - // Find nearest non-empty neighbor (scan left then right) - let neighborState: Displayable | null = null; for (let i = k - 1; i >= 0; i--) { const c = list[i]; if (c) { - neighborState = c; - break; + return c; } } - if (!neighborState) { - for (let i = k + 1; i < list.length; i++) { - const c = list[i]; - if (c) { - neighborState = c; - break; - } + return null; + }; + + const findRight = () => { + const list = editors[currentTab.val] || []; + for (let i = k + 1; i < list.length; i++) { + const c = list[i]; + if (c) { + return c; } } + return null; + }; + + const wrappedDelete = () => { + // Find nearest non-empty neighbor (scan left then right) + let neighborState: Displayable | null = findLeft(); + if (!neighborState) { + neighborState = findRight(); + } // Call the original delete function which updates the reactive list / DOM del(); @@ -49,6 +55,8 @@ const EditorWrapper = ( } }; + editor.val.addShortcut("Alt-[", () => findLeft()?.focus()); + editor.val.addShortcut("Alt-]", () => findRight()?.focus()); editor.val.setDeleteFunction(wrappedDelete); }); diff --git a/src/app/lsp.ts b/src/app/lsp.ts index e378b54..50a98e3 100644 --- a/src/app/lsp.ts +++ b/src/app/lsp.ts @@ -96,12 +96,10 @@ class OpenFileWorkspace extends Workspace { // Look through known workspace files and update their docs/versions // based on the editor views or the OpenFile state when no view exists. - // TODO: fix (cause vibe coding is useless) syncFiles() { const result = []; for (const file of this.files) { const prevDoc = file.doc; - // TODO: get changes from rootState (tracked in OpenFile) rather than the view's LSPPlugin. const changes = file.changes; if (changes && !changes.empty) { result.push({ file, prevDoc, changes });