@@ -138,7 +138,7 @@ export class SuggestController implements IEditorContribution {
138138 this . _toDispose . add ( widget . onDidFocus ( ( { item } ) => {
139139
140140 const position = this . _editor . getPosition ( ) ! ;
141- const startColumn = item . completion . range . startColumn ;
141+ const startColumn = item . editStart . column ;
142142 const endColumn = position . column ;
143143 let value = true ;
144144 if (
@@ -241,7 +241,8 @@ export class SuggestController implements IEditorContribution {
241241
242242 const model = this . _editor . getModel ( ) ;
243243 const modelVersionNow = model . getAlternativeVersionId ( ) ;
244- const { completion : suggestion , position } = event . item ;
244+ const { item } = event ;
245+ const { completion : suggestion , position } = item ;
245246 const columnDelta = this . _editor . getPosition ( ) . column - position . column ;
246247
247248 // pushing undo stops *before* additional text edits and
@@ -255,33 +256,20 @@ export class SuggestController implements IEditorContribution {
255256 }
256257
257258 // keep item in memory
258- this . _memoryService . memorize ( model , this . _editor . getPosition ( ) , event . item ) ;
259+ this . _memoryService . memorize ( model , this . _editor . getPosition ( ) , item ) ;
259260
260261 let { insertText } = suggestion ;
261262 if ( ! ( suggestion . insertTextRules ! & CompletionItemInsertTextRule . InsertAsSnippet ) ) {
262263 insertText = SnippetParser . escape ( insertText ) ;
263264 }
264265
265- let overwriteBefore = position . column - suggestion . range . startColumn ;
266- let overwriteAfter = suggestion . range . endColumn - position . column ;
267- let suffixDelta = this . _lineSuffix . value ? this . _lineSuffix . value . delta ( this . _editor . getPosition ( ) ) : 0 ;
268- let word = model . getWordAtPosition ( this . _editor . getPosition ( ) ) ;
269-
270266 const overwriteConfig = flags & InsertFlags . AlternativeOverwriteConfig
271267 ? ! this . _editor . getOption ( EditorOption . suggest ) . overwriteOnAccept
272268 : this . _editor . getOption ( EditorOption . suggest ) . overwriteOnAccept ;
273- if ( ! overwriteConfig ) {
274- if ( overwriteAfter > 0 && word && suggestion . range . endColumn === word . endColumn ) {
275- // don't overwrite anything right of the cursor, overrule extension even when the
276- // completion only replaces a word...
277- overwriteAfter = 0 ;
278- }
279- } else {
280- if ( overwriteAfter === 0 && word ) {
281- // compute fallback overwrite length
282- overwriteAfter = word . endColumn - this . _editor . getPosition ( ) . column ;
283- }
284- }
269+
270+ const overwriteBefore = position . column - item . editStart . column ;
271+ const overwriteAfter = ( overwriteConfig ? item . editReplaceEnd . column : item . editInsertEnd . column ) - position . column ;
272+ const suffixDelta = this . _lineSuffix . value ? this . _lineSuffix . value . delta ( this . _editor . getPosition ( ) ) : 0 ;
285273
286274 SnippetController2 . get ( this . _editor ) . insert ( insertText , {
287275 overwriteBefore : overwriteBefore + columnDelta ,
@@ -367,7 +355,7 @@ export class SuggestController implements IEditorContribution {
367355 return true ;
368356 }
369357 const position = this . _editor . getPosition ( ) ! ;
370- const startColumn = item . completion . range . startColumn ;
358+ const startColumn = item . editStart . column ;
371359 const endColumn = position . column ;
372360 if ( endColumn - startColumn !== item . completion . insertText . length ) {
373361 // unequal lengths -> makes edit
0 commit comments