diff --git a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts index 9d6ef9d7..7b2b956f 100644 --- a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts +++ b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts @@ -74,7 +74,7 @@ export type StartApplyingOpts = { export type AddCtrlKOpts = { startLine: number, endLine: number, - uri: URI, + editor: ICodeEditor, } @@ -309,8 +309,8 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { } - private _addCtrlKZoneInput = async (editorId: string, ctrlKZone: CtrlKZone) => { - + private _addCtrlKZoneInput = async (ctrlKZone: CtrlKZone) => { + const { editorId } = ctrlKZone const editor = this._editorService.listCodeEditors().find(e => e.getId() === editorId) if (!editor) { console.error('editor not found') @@ -390,7 +390,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const diffArea = this.diffAreaOfId[diffareaid] if (diffArea.type !== 'CtrlKZone') continue if (!diffArea._mountInfo) { - diffArea._mountInfo = await this._addCtrlKZoneInput(diffArea.editorId, diffArea) + diffArea._mountInfo = await this._addCtrlKZoneInput(diffArea) } else { diffArea._mountInfo.refresh() @@ -522,11 +522,13 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { private _addToHistory(uri: URI) { const getCurrentSnapshot = (): HistorySnapshot => { - const diffAreaOfId = this.diffAreaOfId - const snapshottedDiffAreaOfId: Record = {} - for (const diffareaid in diffAreaOfId) { - const diffArea = diffAreaOfId[diffareaid] + + for (const diffareaid in this.diffAreaOfId) { + const diffArea = this.diffAreaOfId[diffareaid] + + if (diffArea._URI.fsPath !== uri.fsPath) continue + snapshottedDiffAreaOfId[diffareaid] = structuredClone( // a structured clone must be on a JSON object Object.fromEntries(diffAreaSnapshotKeys.map(key => [key, diffArea[key]])) ) as DiffAreaSnapshot @@ -539,7 +541,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { } const restoreDiffAreas = (snapshot: HistorySnapshot) => { - const { snapshottedDiffAreaOfId, entireFileCode: entireModelCode } = structuredClone(snapshot) // don't want to destroy the snapshot // for each diffarea in this uri, stop streaming if currently streaming for (const diffareaid in this.diffAreaOfId) { @@ -550,6 +551,10 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // delete all diffareas on this uri (clearing their styles) this._deleteAllDiffAreas(uri) + this.diffAreasOfURI[uri.fsPath].clear() + + console.log("RESTORING FOR", uri) + const { snapshottedDiffAreaOfId, entireFileCode: entireModelCode } = structuredClone(snapshot) // don't want to destroy the snapshot // restore diffAreaOfId and diffAreasOfModelId for (const diffareaid in snapshottedDiffAreaOfId) { @@ -857,10 +862,10 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // called first, then call startApplying - public addCtrlKZone({ startLine, endLine, uri }: AddCtrlKOpts) { + public addCtrlKZone({ startLine, endLine, editor }: AddCtrlKOpts) { - const editor = this._editorService.getActiveCodeEditor() - if (!editor) return + const uri = editor.getModel()?.uri + if (!uri) return // check if there's overlap with any other ctrlKZones and if so, focus them for (const diffareaid of this.diffAreasOfURI[uri.fsPath]) { diff --git a/src/vs/workbench/contrib/void/browser/quickEditActions.ts b/src/vs/workbench/contrib/void/browser/quickEditActions.ts index 5be84c66..6426f70c 100644 --- a/src/vs/workbench/contrib/void/browser/quickEditActions.ts +++ b/src/vs/workbench/contrib/void/browser/quickEditActions.ts @@ -54,12 +54,11 @@ registerAction2(class extends Action2 { const { startLineNumber: startLine, endLineNumber: endLine } = selection - const uri = model.uri // deselect - clear selection editor.setSelection({ startLineNumber: startLine, endLineNumber: startLine, startColumn: 1, endColumn: 1 }) const inlineDiffsService = accessor.get(IInlineDiffsService) - inlineDiffsService.addCtrlKZone({ startLine, endLine, uri }) + inlineDiffsService.addCtrlKZone({ startLine, endLine, editor }) } }); diff --git a/src/vs/workbench/contrib/void/browser/react/src/ctrl-k-tsx/CtrlKChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/ctrl-k-tsx/CtrlKChat.tsx index 114fb1f1..2cb76f82 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/ctrl-k-tsx/CtrlKChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/ctrl-k-tsx/CtrlKChat.tsx @@ -20,20 +20,13 @@ export const CtrlKChat = ({ diffareaid, onGetInputBox, onUserUpdateText, onChang const inputBoxRef: React.MutableRefObject = useRef(null); useEffect(() => { - console.log('mounting resize observer') const inputContainer = sizerRef.current if (!inputContainer) return; - - // inputBoxRef.current?.onDidHeightChange(height => { - // console.log('NEW HEIGHT',height) - // onChangeHeight(height + 40) - // }) // only observing 1 element let resizeObserver: ResizeObserver | undefined resizeObserver = new ResizeObserver((entries) => { const height = entries[0].borderBoxSize[0].blockSize - console.log('NEW HEIGHT', height) onChangeHeight(height) }) resizeObserver.observe(inputContainer);