From 4193d46d0db6c80556dd78190463f98754499759 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Fri, 20 Jun 2025 19:51:03 -0500 Subject: [PATCH] Fixing command pakllet call; fixing session swap session defaulting --- src/app/common/configs/keybindings.config.ts | 2 +- src/app/editor/editors.component.ts | 22 ++++++++++++++----- .../newton-editor/newton-editor.base.ts | 2 +- .../newton-editor/newton-editor.component.ts | 2 ++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/app/common/configs/keybindings.config.ts b/src/app/common/configs/keybindings.config.ts index 6c33f78..913604d 100644 --- a/src/app/common/configs/keybindings.config.ts +++ b/src/app/common/configs/keybindings.config.ts @@ -16,7 +16,7 @@ export const Keybindings: Array<{}> = [ bindKey: {win: "ctrl-shift-k", mac: "command-shift-k"}, readOnly: false }, { - name: "openCommandPalette", + name: "openCommandPalette2", bindKey: {linux: "Command-shift-/|F1", win: "ctrl-shift-/|F1"}, readOnly: false }, { diff --git a/src/app/editor/editors.component.ts b/src/app/editor/editors.component.ts index 66f7cb7..2d511b9 100644 --- a/src/app/editor/editors.component.ts +++ b/src/app/editor/editors.component.ts @@ -54,6 +54,11 @@ export class EditorsComponent { rightEditor.instance.leftSiblingUUID = leftEditor.instance.uuid; } + ngOnDestroy() { + this.unsubscribe.next(); + this.unsubscribe.complete(); + } + loadSubscribers() { this.editorsService.getMessage$().pipe( @@ -72,23 +77,31 @@ export class EditorsComponent { } else if (message.action === "move-session-left") { let editorComponent = this.editorsService.get(message.editorUUID); if (!editorComponent.leftSiblingUUID) return; + let siblingComponent = this.editorsService.get(editorComponent.leftSiblingUUID); let session = editorComponent.editor.getSession(); let siblingSession = siblingComponent.editor.getSession(); if (session == siblingSession) return; + siblingComponent.editor.setSession(session); + siblingComponent.activeFile = editorComponent.activeFile; + editorComponent.newBuffer(); siblingComponent.editor.focus() } else if (message.action === "move-session-right") { let editorComponent = this.editorsService.get(message.editorUUID); if (!editorComponent.rightSiblingUUID) return; + let siblingComponent = this.editorsService.get(editorComponent.rightSiblingUUID); let session = editorComponent.editor.getSession(); let siblingSession = siblingComponent.editor.getSession(); if (session == siblingSession) return; + siblingComponent.editor.setSession(session); + siblingComponent.activeFile = editorComponent.activeFile; + editorComponent.newBuffer(); siblingComponent.editor.focus() } else if (message.action === "set-active-editor") { @@ -207,11 +220,6 @@ export class EditorsComponent { }); } - ngOnDestroy() { - this.unsubscribe.next(); - this.unsubscribe.complete(); - } - // Note: Only really works with 2 editors and very brittle logic. protected setEditorSize(event: any) { let lEditorComponent = null; @@ -248,6 +256,10 @@ export class EditorsComponent { } } + this.resizeAndFocus(lEditorComponent, lSize, rEditorComponent, rSize); + } + + private resizeAndFocus(lEditorComponent: any, lSize: number, rEditorComponent: any, rSize: number) { let lElm = lEditorComponent.editorElm.nativeElement.parentElement; let rElm = rEditorComponent.editorElm.nativeElement.parentElement; diff --git a/src/app/editor/newton-editor/newton-editor.base.ts b/src/app/editor/newton-editor/newton-editor.base.ts index db4c92c..0d8825b 100644 --- a/src/app/editor/newton-editor/newton-editor.base.ts +++ b/src/app/editor/newton-editor/newton-editor.base.ts @@ -34,7 +34,7 @@ export class NewtonEditorBase { this.editorElm.nativeElement.classList.remove("active-editor") } - public openCommandPalette() { + public openCommandPalette2() { this.editor.execCommand("openCommandPalette"); } diff --git a/src/app/editor/newton-editor/newton-editor.component.ts b/src/app/editor/newton-editor/newton-editor.component.ts index 04803a2..bb7fd5e 100644 --- a/src/app/editor/newton-editor/newton-editor.component.ts +++ b/src/app/editor/newton-editor/newton-editor.component.ts @@ -127,6 +127,8 @@ export class NewtonEditorComponent extends NewtonEditorBase { }); this.editor.on("change", () => { + if (!this.activeFile) return; + let message = new ServiceMessage(); message.action = "file-changed"; message.filePath = this.activeFile.path;