Skip to content

Commit 40e1b40

Browse files
benibenjjoaomoreno
andauthored
Use line replacement view instead of word replacement view when inserting before cursor (microsoft#249955)
fixes microsoft/vscode-copilot#17749 Co-authored-by: João Moreno <[email protected]>
1 parent 0c6b128 commit 40e1b40

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,14 @@ export class InlineEditsView extends Disposable {
357357
if (
358358
isSingleInnerEdit
359359
&& this._useCodeShifting.read(reader) !== 'never'
360-
&& isSingleLineInsertionAfterPosition(diff, inlineEdit.cursorPosition)
361360
) {
362-
return 'insertionInline';
361+
if (isSingleLineInsertionAfterPosition(diff, inlineEdit.cursorPosition)) {
362+
return 'insertionInline';
363+
}
364+
365+
// If we have a single line insertion before the cursor position, we do not want to move the cursor by inserting
366+
// the suggestion inline. Use a line replacement view instead
367+
return 'lineReplacement';
363368
}
364369

365370
const innerValues = inner.map(m => ({ original: inlineEdit.originalText.getValueOfRange(m.originalRange), modified: newText.getValueOfRange(m.modifiedRange) }));

0 commit comments

Comments
 (0)