From 63c32041550f526569094bdd78a938a37c94d0f4 Mon Sep 17 00:00:00 2001 From: Benjamin Christopher Simmonds <44439583+benibenj@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:50:30 +0100 Subject: [PATCH] Fix deletion decoration logic in inline diff view (#238377) fix deletion decoration --- .../browser/view/inlineEdits/inlineDiffView.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineDiffView.ts b/src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineDiffView.ts index 796e21e260f04..a910c8854d736 100644 --- a/src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineDiffView.ts +++ b/src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineDiffView.ts @@ -15,7 +15,7 @@ import { EditorOption } from '../../../../../common/config/editorOptions.js'; import { Range } from '../../../../../common/core/range.js'; import { AbstractText } from '../../../../../common/core/textEdit.js'; import { DetailedLineRangeMapping } from '../../../../../common/diff/rangeMapping.js'; -import { IModelDeltaDecoration, ITextModel } from '../../../../../common/model.js'; +import { EndOfLinePreference, IModelDeltaDecoration, ITextModel } from '../../../../../common/model.js'; import { ModelDecorationOptions } from '../../../../../common/model/textModel.js'; import { InlineDecoration, InlineDecorationType } from '../../../../../common/viewModel.js'; import { classNames } from './utils.js'; @@ -184,6 +184,7 @@ export class OriginalEditorInlineDiffView extends Disposable { for (const i of m.innerChanges || []) { // Don't show empty markers outside the line range if (m.original.contains(i.originalRange.startLineNumber)) { + const replacedText = this._originalEditor.getModel()?.getValueInRange(i.originalRange, EndOfLinePreference.LF); originalDecorations.push({ range: i.originalRange, options: { @@ -193,7 +194,7 @@ export class OriginalEditorInlineDiffView extends Disposable { 'inlineCompletions-char-delete', i.originalRange.isSingleLine() && diff.mode === 'ghostText' && 'single-line-inline', i.originalRange.isEmpty() && 'empty', - ((i.originalRange.isEmpty() || diff.mode === 'deletion') && showEmptyDecorations && !useInlineDiff) && 'diff-range-empty' + ((i.originalRange.isEmpty() || diff.mode === 'deletion' && replacedText === '\n') && showEmptyDecorations && !useInlineDiff) && 'diff-range-empty' ), inlineClassName: useInlineDiff ? classNames('strike-through', 'inlineCompletions') : null, zIndex: 1