From e6177d44c6146fa9d55f1988fc89c4789e4bd65c Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 16 Nov 2024 23:13:59 -0800 Subject: [PATCH] fix overlapping green styles --- .../void/browser/registerInlineDiffs.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts index e6f417de..d3412461 100644 --- a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts +++ b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts @@ -10,7 +10,7 @@ import { sendLLMMessage } from './react/out/util/sendLLMMessage.js'; import { IVoidConfigStateService } from './registerConfig.js'; import { writeFileWithDiffInstructions } from './prompt/systemPrompts.js'; import { BaseDiff, findDiffs } from './findDiffs.js'; -import { EndOfLinePreference, IModelDeltaDecoration, ITextModel } from '../../../../editor/common/model.js'; +import { EndOfLinePreference, ITextModel } from '../../../../editor/common/model.js'; import { IRange } from '../../../../editor/common/core/range.js'; import { EditorOption } from '../../../../editor/common/config/editorOptions.js'; import { registerColor } from '../../../../platform/theme/common/colorUtils.js'; @@ -262,10 +262,13 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { private _addInlineDiffZone = (model: ITextModel, redText: string, greenRange: IRange, type: 'insertion' | 'deletion' | 'edit', diffid: number) => { const _addInlineDiffZoneToEditor = (editor: ICodeEditor) => { + + // green decoration and gutter decoration - const greenDecoration: IModelDeltaDecoration[] = [{ - range: greenRange, - options: { + let decorationId: string | null = null + editor.changeDecorations(accessor => { + if (type === 'deletion') return + decorationId = accessor.addDecoration(greenRange, { className: 'void-greenBG line-insert', // .monaco-editor .line-insert description: 'void-greenBG', isWholeLine: true, @@ -277,9 +280,8 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { color: { id: 'editorOverviewRuler.addedForeground' }, position: 7 } - } - }]; - const decorationsCollection = editor.createDecorationsCollection(greenDecoration) + }) + }) // red in a view zone @@ -337,7 +339,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { }); const dispose = () => { - decorationsCollection.clear() + editor.changeDecorations(accessor => { if (decorationId) accessor.removeDecoration(decorationId) }) editor.changeViewZones(accessor => { if (zoneId) accessor.removeZone(zoneId); }); } return dispose