Skip to content

Commit 65ea9a6

Browse files
authored
Prevent showing indentation changes in word replacement view (microsoft#259512)
1 parent dc0e191 commit 65ea9a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,17 @@ export class InlineEditsView extends Disposable {
394394

395395
const allInnerChangesNotTooLong = inner.every(m => TextLength.ofRange(m.originalRange).columnCount < InlineEditsWordReplacementView.MAX_LENGTH && TextLength.ofRange(m.modifiedRange).columnCount < InlineEditsWordReplacementView.MAX_LENGTH);
396396
if (allInnerChangesNotTooLong && isSingleInnerEdit && numOriginalLines === 1 && numModifiedLines === 1) {
397-
// Make sure there is no insertion, even if we grow them
398-
if (
399-
!inner.some(m => m.originalRange.isEmpty()) ||
400-
!growEditsUntilWhitespace(inner.map(m => new TextReplacement(m.originalRange, '')), inlineEdit.originalText).some(e => e.range.isEmpty() && TextLength.ofRange(e.range).columnCount < InlineEditsWordReplacementView.MAX_LENGTH)
401-
) {
402-
return InlineCompletionViewKind.WordReplacements;
397+
// Do not show indentation changes with word replacement view
398+
const modifiedText = inner.map(m => newText.getValueOfRange(m.modifiedRange));
399+
const originalText = inner.map(m => model.inlineEdit.originalText.getValueOfRange(m.originalRange));
400+
if (!modifiedText.some(v => v.includes('\t')) && !originalText.some(v => v.includes('\t'))) {
401+
// Make sure there is no insertion, even if we grow them
402+
if (
403+
!inner.some(m => m.originalRange.isEmpty()) ||
404+
!growEditsUntilWhitespace(inner.map(m => new TextReplacement(m.originalRange, '')), inlineEdit.originalText).some(e => e.range.isEmpty() && TextLength.ofRange(e.range).columnCount < InlineEditsWordReplacementView.MAX_LENGTH)
405+
) {
406+
return InlineCompletionViewKind.WordReplacements;
407+
}
403408
}
404409
}
405410
}

0 commit comments

Comments
 (0)