From da6710a079fcf360e46cb92d8e965b4e726b49e7 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Fri, 21 Mar 2025 21:45:17 -0700 Subject: [PATCH] current file fix will vs did --- .../void/browser/terminalToolService.ts | 2 +- .../void/browser/voidCommandBarService.ts | 22 ++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/terminalToolService.ts b/src/vs/workbench/contrib/void/browser/terminalToolService.ts index c9cbd178..5876e54b 100644 --- a/src/vs/workbench/contrib/void/browser/terminalToolService.ts +++ b/src/vs/workbench/contrib/void/browser/terminalToolService.ts @@ -143,8 +143,8 @@ export class TerminalToolService extends Disposable implements ITerminalToolServ openTerminal: ITerminalToolService['openTerminal'] = async (terminalId) => { if (!terminalId) return - const terminal = this.terminalInstanceOfId[terminalId] + if (!terminal) return // should never happen this.terminalService.setActiveInstance(terminal) await this.terminalService.focusActiveInstance() } diff --git a/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts b/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts index 4b298ac8..7711068d 100644 --- a/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts +++ b/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts @@ -103,12 +103,6 @@ export class VoidCommandBarService extends Disposable implements IVoidCommandBar - const updateActiveURI = () => { - const currentUri = this._codeEditorService.getActiveCodeEditor()?.getModel()?.uri ?? null - this.activeURI = currentUri - if (!currentUri) return; - this._onDidChangeActiveURI.fire({ uri: currentUri }) - } // for every new editor, add the floating widget and update active URI @@ -120,7 +114,11 @@ export class VoidCommandBarService extends Disposable implements IVoidCommandBar // mount the command bar const d1 = this._instantiationService.createInstance(AcceptRejectAllFloatingWidget, { editor }); disposablesOfEditorId[id].push(d1); - const d2 = editor.onWillChangeModel((e) => { if (e?.newModelUrl?.scheme === 'file') updateActiveURI() }) + const d2 = editor.onDidChangeModel((e) => { + if (e.newModelUrl?.scheme !== 'file') return + this.activeURI = e.newModelUrl; + this._onDidChangeActiveURI.fire({ uri: e.newModelUrl }) + }) disposablesOfEditorId[id].push(d2); } const onCodeEditorRemove = (editor: ICodeEditor) => { @@ -410,21 +408,15 @@ class AcceptRejectAllFloatingWidget extends Widget implements IOverlayWidget { editor.addOverlayWidget(this); this.instantiationService.invokeFunction(accessor => { - const uri = editor.getModel()?.uri || null - const res = mountVoidCommandBar(root, accessor, { uri, editor } satisfies VoidCommandBarProps) if (!res) return - this._register(toDisposable(() => res.dispose?.())) - - this._register(editor.onDidChangeModel((model) => { + this._register(editor.onWillChangeModel((model) => { const uri = model.newModelUrl res.rerender({ uri, editor } satisfies VoidCommandBarProps) })) - - }); - + }) }