From 01839654d4044a8ac10b3d1117a8d9f9135da015 Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Mon, 13 Jan 2025 22:10:46 -0800 Subject: [PATCH] acceptall rejectall widget draft --- .../void/browser/inlineDiffsService.ts | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts index 29fcb56c..74d9bac8 100644 --- a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts +++ b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts @@ -521,6 +521,27 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { + const id2 = this._consistentItemService.addConsistentItemToURI({ + uri, + fn: (editor) => { + const buttonsWidget = new AcceptAllRejectAllWidget({ + editor, + onAccept: () => { + this.acceptDiff({ diffid }) + this._metricsService.capture('Accept Diff', { batch: false }) + }, + onReject: () => { + this.rejectDiff({ diffid }) + this._metricsService.capture('Reject Diff', { batch: false }) + }, + }) + return () => { buttonsWidget.dispose() } + } + }) + disposeInThisEditorFns.push(() => { this._consistentItemService.removeConsistentItemFromURI(id2) }) + + + const disposeInEditor = () => { disposeInThisEditorFns.forEach(f => f()) } return disposeInEditor; @@ -843,6 +864,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // 4. refresh ctrlK zones this._refreshCtrlKInputs(uri) + + // 5. + // this.removeDiffAreas({ uri, behavior: 'reject' }) } @@ -1635,6 +1659,61 @@ class AcceptRejectWidget extends Widget implements IOverlayWidget { + + +class AcceptAllRejectAllWidget extends Widget implements IOverlayWidget { + private readonly _domNode: HTMLElement; + private readonly editor: ICodeEditor; + private readonly ID: string; + + constructor({ editor, onAccept, onReject, }: { editor: ICodeEditor, onAccept: () => void, onReject: () => void, }) { + super(); + this.editor = editor; + this.ID = 'my.centered.widget'; + + // Create container div + this._domNode = document.createElement('div'); + + // Style the container to center it + this._domNode.style.position = 'fixed'; // fixed instead of absolute + this._domNode.style.left = '50%'; + this._domNode.style.top = '50%'; + this._domNode.style.transform = 'translate(-50%, -50%)'; + this._domNode.style.zIndex = '1000'; + + // Style the blue box + this._domNode.style.backgroundColor = '#007ACC'; + this._domNode.style.padding = '20px'; + this._domNode.style.color = 'white'; + this._domNode.style.borderRadius = '4px'; + + // Add some content + this._domNode.textContent = 'Centered Widget'; + + // Mount the widget + editor.addOverlayWidget(this); + } + + public getId(): string { + return this.ID; + } + + public getDomNode(): HTMLElement { + return this._domNode; + } + + public getPosition(): null { + return null; // null position lets us position it absolutely + } + + public override dispose(): void { + this.editor.removeOverlayWidget(this); + super.dispose(); + } +} + + + // registerAction2(class extends Action2 { // constructor() { // super({