@@ -421,6 +421,9 @@ export class InlineCompletionsModel extends Disposable {
421
421
const partialGhostTextVal = ghostTextVal . substring ( 0 , acceptUntilIndexExclusive ) ;
422
422
423
423
const positions = this . _positions . get ( ) ;
424
+ if ( positions . length === 0 ) {
425
+ return ;
426
+ }
424
427
const cursorPosition = positions [ 0 ] ;
425
428
426
429
// Executing the edit might free the completion, so we have to hold a reference on it.
@@ -470,6 +473,10 @@ export class InlineCompletionsModel extends Disposable {
470
473
}
471
474
472
475
export function getSecondaryEdits ( textModel : ITextModel , positions : readonly Position [ ] , primaryEdit : SingleTextEdit ) : SingleTextEdit [ ] {
476
+ if ( positions . length === 1 ) {
477
+ // No secondary cursor positions
478
+ return [ ] ;
479
+ }
473
480
const primaryPosition = positions [ 0 ] ;
474
481
const secondaryPositions = positions . slice ( 1 ) ;
475
482
const primaryEditStartPosition = primaryEdit . range . getStartPosition ( ) ;
@@ -478,6 +485,9 @@ export function getSecondaryEdits(textModel: ITextModel, positions: readonly Pos
478
485
Range . fromPositions ( primaryPosition , primaryEditEndPosition )
479
486
) ;
480
487
const positionWithinTextEdit = subtractPositions ( primaryPosition , primaryEditStartPosition ) ;
488
+ if ( positionWithinTextEdit . lineNumber < 1 ) {
489
+ return [ ] ;
490
+ }
481
491
const secondaryEditText = substringPos ( primaryEdit . text , positionWithinTextEdit ) ;
482
492
return secondaryPositions . map ( pos => {
483
493
const posEnd = addPositions ( subtractPositions ( pos , primaryEditStartPosition ) , primaryEditEndPosition ) ;
0 commit comments