diff options
| author | christine betts <[email protected]> | 2025-08-08 15:21:50 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-08 15:21:50 +0000 |
| commit | 407393b1285ed648be6594395429a802e876b20c (patch) | |
| tree | 22727e20c07360286b6739974bd743a8763cfd80 /packages/vscode-ide-companion/src/diff-manager.ts | |
| parent | 51d09e720b7563fcd395f8e520bbc7ed365912d8 (diff) | |
[ide-mode] Hide diff options when active diff is not focused (#5808)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/vscode-ide-companion/src/diff-manager.ts')
| -rw-r--r-- | packages/vscode-ide-companion/src/diff-manager.ts | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/packages/vscode-ide-companion/src/diff-manager.ts b/packages/vscode-ide-companion/src/diff-manager.ts index d2a53b54..9c7afc1d 100644 --- a/packages/vscode-ide-companion/src/diff-manager.ts +++ b/packages/vscode-ide-companion/src/diff-manager.ts @@ -54,11 +54,25 @@ export class DiffManager { new vscode.EventEmitter<JSONRPCNotification>(); readonly onDidChange = this.onDidChangeEmitter.event; private diffDocuments = new Map<string, DiffInfo>(); + private readonly subscriptions: vscode.Disposable[] = []; constructor( private readonly log: (message: string) => void, private readonly diffContentProvider: DiffContentProvider, - ) {} + ) { + this.subscriptions.push( + vscode.window.onDidChangeActiveTextEditor((editor) => { + this.onActiveEditorChange(editor); + }), + ); + this.onActiveEditorChange(vscode.window.activeTextEditor); + } + + dispose() { + for (const subscription of this.subscriptions) { + subscription.dispose(); + } + } /** * Creates and shows a new diff view. @@ -199,6 +213,18 @@ export class DiffManager { ); } + private async onActiveEditorChange(editor: vscode.TextEditor | undefined) { + const isVisible = + !!editor && + editor.document.uri.scheme === DIFF_SCHEME && + this.diffDocuments.has(editor.document.uri.toString()); + await vscode.commands.executeCommand( + 'setContext', + 'gemini.diff.isVisible', + isVisible, + ); + } + private addDiffDocument(uri: vscode.Uri, diffInfo: DiffInfo) { this.diffDocuments.set(uri.toString(), diffInfo); } |
