@@ -8,6 +8,7 @@ import { isNonEmptyArray } from 'vs/base/common/arrays';
88import { onUnexpectedError } from 'vs/base/common/errors' ;
99import { KeyCode , KeyMod , SimpleKeybinding } from 'vs/base/common/keyCodes' ;
1010import { dispose , IDisposable , DisposableStore , toDisposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
11+ import { StableEditorScrollState } from 'vs/editor/browser/core/editorState' ;
1112import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
1213import { EditorAction , EditorCommand , registerEditorAction , registerEditorCommand , registerEditorContribution , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
1314import { EditOperation } from 'vs/editor/common/core/editOperation' ;
@@ -273,6 +274,8 @@ export class SuggestController implements IEditorContribution {
273274 // keep item in memory
274275 this . _memoryService . memorize ( model , this . editor . getPosition ( ) , item ) ;
275276
277+ const scrollState = StableEditorScrollState . capture ( this . editor ) ;
278+
276279 if ( Array . isArray ( suggestion . additionalTextEdits ) ) {
277280 this . editor . executeEdits ( 'suggestController.additionalTextEdits' , suggestion . additionalTextEdits . map ( edit => EditOperation . replace ( Range . lift ( edit . range ) , edit . text ) ) ) ;
278281 }
@@ -290,6 +293,8 @@ export class SuggestController implements IEditorContribution {
290293 adjustWhitespace : ! ( suggestion . insertTextRules ! & CompletionItemInsertTextRule . KeepWhitespace )
291294 } ) ;
292295
296+ scrollState . restoreRelativeVerticalPositionOfCursor ( this . editor ) ;
297+
293298 if ( ! ( flags & InsertFlags . NoAfterUndoStop ) ) {
294299 this . editor . pushUndoStop ( ) ;
295300 }
0 commit comments