Fix types and formatting

This commit is contained in:
Quinten Kock 2025-11-30 02:49:23 +01:00
parent b7f51e099e
commit d9584e7543
2 changed files with 10 additions and 7 deletions

View File

@ -149,7 +149,9 @@ export class Editor implements Displayable {
// lintKeymap, // lintKeymap,
], ],
}); });
this.view.dom.addEventListener("focusin", () => this.view.dom.scrollIntoView({ behavior: "smooth", })); this.view.dom.addEventListener("focusin", () =>
this.view.dom.scrollIntoView({ behavior: "smooth" }),
);
van.derive(() => { van.derive(() => {
LanguageDescription.matchFilename(languages, file.filePath.val) LanguageDescription.matchFilename(languages, file.filePath.val)
@ -175,7 +177,7 @@ export class Editor implements Displayable {
} }
focus() { focus() {
this.view.dom.scrollIntoView({ behavior: "smooth", }); this.view.dom.scrollIntoView({ behavior: "smooth" });
this.view.focus(); this.view.focus();
} }

View File

@ -29,7 +29,7 @@ const EditorWrapper = (
const list = editors[currentTab.val] || []; const list = editors[currentTab.val] || [];
// Find nearest non-empty neighbor (scan left then right) // Find nearest non-empty neighbor (scan left then right)
let neighborState: State<Displayable> | null = null; let neighborState: Displayable | null = null;
for (let i = k - 1; i >= 0; i--) { for (let i = k - 1; i >= 0; i--) {
const c = list[i]; const c = list[i];
if (c) { if (c) {
@ -40,7 +40,7 @@ const EditorWrapper = (
if (!neighborState) { if (!neighborState) {
for (let i = k + 1; i < list.length; i++) { for (let i = k + 1; i < list.length; i++) {
const c = list[i]; const c = list[i];
if (c && c.val) { if (c) {
neighborState = c; neighborState = c;
break; break;
} }
@ -70,7 +70,8 @@ const EditorWrapper = (
); );
}; };
const editors = vanX.reactive([[]]); // give type to editors
const editors: Displayable[][] = vanX.reactive([[]]);
const currentTab = van.state(0); const currentTab = van.state(0);
export function addEditor(file: OpenFile) { export function addEditor(file: OpenFile) {
@ -79,8 +80,8 @@ export function addEditor(file: OpenFile) {
editor.focus(); editor.focus();
} }
export function addTab(file?: OpenFile) { export function addTab() {
editors.push(file ? [file] : []); editors.push([]);
} }
export function addTerminal() { export function addTerminal() {