diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index ff8bbb85..9bc3a7f1 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -223,6 +223,11 @@ export class BaseEditorSimpleWorker implements IDisposable, IWorkerTextModelSync private static readonly _diffLimit = 100000; public async $computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): Promise { + return this.$Void_computeMoreMinimalEdits(modelUrl, edits, pretty) + } + + // Void added this as non async + public $Void_computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): TextEdit[] { const model = this._getModel(modelUrl); if (!model) { return edits; diff --git a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts index 090de24a..d62b5f3d 100644 --- a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts +++ b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts @@ -37,9 +37,9 @@ import { LLMMessage } from '../../../../platform/void/common/llmMessageTypes.js' import { IModelContentChangedEvent } from '../../../../editor/common/textModelEvents.js'; import { extractCodeFromFIM, extractCodeFromRegular } from './helpers/extractCodeFromResult.js'; import { IMetricsService } from '../../../../platform/void/common/metricsService.js'; -import { IEditorWorkerService } from '../../../../editor/common/services/editorWorker.js'; import { InlineDecorationType } from '../../../../editor/common/viewModel.js'; import { filenameToVscodeLanguage } from './helpers/detectLanguage.js'; +import { BaseEditorSimpleWorker } from '../../../../editor/common/services/editorSimpleWorker.js'; const configOfBG = (color: Color) => { return { dark: color, light: color, hcDark: color, hcLight: color, } @@ -202,7 +202,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { @IInstantiationService private readonly _instantiationService: IInstantiationService, @IConsistentEditorItemService private readonly _consistentEditorItemService: IConsistentEditorItemService, @IMetricsService private readonly _metricsService: IMetricsService, - @IEditorWorkerService private readonly _editorWorkerService: IEditorWorkerService, ) { super(); @@ -249,7 +248,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { private _onInternalChangeContent(uri: URI, { shouldRealign }: { shouldRealign: false | { newText: string, oldRange: IRange } }) { if (shouldRealign) { const { newText, oldRange } = shouldRealign - console.log('realiging', newText, oldRange) + // console.log('realiging', newText, oldRange) this._realignAllDiffAreasLines(uri, newText, oldRange) } this._refreshStylesAndDiffsInURI(uri) @@ -411,7 +410,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { if (diffArea.type !== 'CtrlKZone') continue if (!diffArea._mountInfo) { diffArea._mountInfo = this._addCtrlKZoneInput(diffArea) - console.log('MOUNTED', diffArea.diffareaid) + // console.log('MOUNTED', diffArea.diffareaid) } else { diffArea._mountInfo.refresh() @@ -539,6 +538,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { } weAreWriting = false + worker = new BaseEditorSimpleWorker() private async _writeText(uri: URI, text: string, range: IRange, { shouldRealignDiffAreas }: { shouldRealignDiffAreas: boolean }) { const model = this._getModel(uri) if (!model) return @@ -546,7 +546,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { if (!uriStr) return // minimal edits so not so flashy - const edits = await this._editorWorkerService.computeMoreMinimalEdits(uri, [{ range, text }]) + // __TODO__ THIS IS NOT INSIDE A WORKER, SO IT MIGHT BE SLOW, we should instead just do an optimal write ourselves + const edits = this.worker.$Void_computeMoreMinimalEdits(uri.toString(), [{ range, text }], false) + if (edits) { this.weAreWriting = true model.applyEdits(edits) @@ -592,7 +594,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { 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 @@ -1105,9 +1106,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const { prefix, suffix } = ctrlKStream_prefixAndSuffix({ fullFileStr: currentFileStr, startLine, endLine }) const language = filenameToVscodeLanguage(uri.fsPath) ?? '' const userContent = ctrlKStream_prompt({ selection: originalCode, userMessage, prefix, suffix, ollamaStyleFIM, fimTags: modelFimTags, language }) - console.log('PREFIX:\n', prefix) - console.log('SUFFIX:\n', suffix) - console.log('USER CONTENT:\n', userContent) + // console.log('PREFIX:\n', prefix) + // console.log('SUFFIX:\n', suffix) + // console.log('USER CONTENT:\n', userContent) messages = [ // TODO include more context too (LSP, file history, etc) { role: 'system', content: ctrlKStream_systemMessage, }, @@ -1157,7 +1158,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // at the end, re-write whole thing to make sure no sync errors this._writeText(uri, extractText(fullText), { startLineNumber: diffZone.startLine, startColumn: 1, endLineNumber: diffZone.endLine, endColumn: Number.MAX_SAFE_INTEGER }, // 1-indexed - { shouldRealignDiffAreas: false } + { shouldRealignDiffAreas: true } ) onDone() }, @@ -1396,12 +1397,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { throw new Error(`Void error: ${diff}.type not recognized`) } - console.log('REJECTION start, end:', diffArea.startLine, diffArea.endLine) // update the file this._writeText(uri, writeText, toRange, { shouldRealignDiffAreas: true }) - console.log('2REJECTION start, end:', diffArea.startLine, diffArea.endLine) - // originalCode does not change! // delete the diff diff --git a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx index a18bcbce..fca06caa 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx @@ -3,7 +3,8 @@ * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. *--------------------------------------------------------------------------------------*/ -import { ReactNode } from 'react' +import React from 'react'; + import { VoidCodeEditor, VoidCodeEditorProps } from '../util/inputs.js'; @@ -11,16 +12,21 @@ export const BlockCode = ({ buttonsOnHover, ...codeEditorProps }: { buttonsOnHov const isSingleLine = !codeEditorProps.initValue.includes('\n') - return (<> -
- {buttonsOnHover === null ? null : ( -
-
{buttonsOnHover}
-
- )} - -
- + return ( + <> +
+ + {buttonsOnHover === null ? null : ( +
+
+ {buttonsOnHover} +
+
+ )} + + + +
+ ) } - diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 226a8050..aa4eecc7 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -289,7 +289,7 @@ export const SelectedFiles = ( const isThisSelectionOpened = !!(selection.selectionStr && selectionIsOpened[i]) const isThisSelectionAFile = selection.selectionStr === null - return
{/* selection summary */}