@@ -50,9 +50,9 @@ import { editWouldDeleteWhatWasJustInserted } from '../../inlineEdits/common/ghN
50
50
import { getOrDeduceSelectionFromLastEdit } from '../../inlineEdits/common/nearbyCursorInlineEditProvider' ;
51
51
import { IgnoreImportChangesAspect } from '../../inlineEdits/node/importFiltering' ;
52
52
import { createTaggedCurrentFileContentUsingPagedClipping , getUserPrompt , N_LINES_ABOVE , N_LINES_AS_CONTEXT , N_LINES_BELOW , nes41Miniv3SystemPrompt , PromptPieces , PromptTags , simplifiedPrompt , systemPromptTemplate , unifiedModelSystemPrompt , xtab275SystemPrompt } from '../common/promptCrafting' ;
53
+ import { CurrentDocument } from './xtabCurrentDocument' ;
53
54
import { XtabEndpoint } from './xtabEndpoint' ;
54
55
import { linesWithBackticksRemoved , toLines } from './xtabUtils' ;
55
- import { CurrentDocument } from './xtabCurrentDocument' ;
56
56
57
57
namespace ResponseTags {
58
58
export const NO_CHANGE = {
@@ -232,22 +232,22 @@ export class XtabProvider implements IStatelessNextEditProvider {
232
232
233
233
const currentDocument = new CurrentDocument ( activeDocument . documentAfterEdits , cursorPosition ) ;
234
234
235
- const cursorLine = currentDocument . lines . value [ currentDocument . cursorLineOffset ] ;
235
+ const cursorLine = currentDocument . lines [ currentDocument . cursorLineOffset ] ;
236
236
const isCursorAtEndOfLine = cursorPosition . column === cursorLine . trimEnd ( ) . length ;
237
237
if ( isCursorAtEndOfLine ) {
238
238
delaySession . setExtraDebounce ( this . configService . getExperimentBasedConfig ( ConfigKey . Internal . InlineEditsExtraDebounceEndOfLine , this . expService ) ) ;
239
239
}
240
240
telemetryBuilder . setIsCursorAtLineEnd ( isCursorAtEndOfLine ) ;
241
241
242
- const areaAroundEditWindowLinesRange = this . computeAreaAroundEditWindowLinesRange ( currentDocument . lines . value , currentDocument . cursorLineOffset ) ;
242
+ const areaAroundEditWindowLinesRange = this . computeAreaAroundEditWindowLinesRange ( currentDocument ) ;
243
243
244
- const editWindowLinesRange = this . computeEditWindowLinesRange ( currentDocument . lines . value , currentDocument . cursorLineOffset , request , retryState ) ;
244
+ const editWindowLinesRange = this . computeEditWindowLinesRange ( currentDocument , request , retryState ) ;
245
245
246
246
const cursorOriginalLinesOffset = Math . max ( 0 , currentDocument . cursorLineOffset - editWindowLinesRange . start ) ;
247
- const editWindowLastLineLength = activeDocument . documentAfterEdits . getTransformer ( ) . getLineLength ( editWindowLinesRange . endExclusive ) ;
248
- const editWindow = activeDocument . documentAfterEdits . getTransformer ( ) . getOffsetRange ( new Range ( editWindowLinesRange . start + 1 , 1 , editWindowLinesRange . endExclusive , editWindowLastLineLength + 1 ) ) ;
247
+ const editWindowLastLineLength = currentDocument . transformer . getLineLength ( editWindowLinesRange . endExclusive ) ;
248
+ const editWindow = currentDocument . transformer . getOffsetRange ( new Range ( editWindowLinesRange . start + 1 , 1 , editWindowLinesRange . endExclusive , editWindowLastLineLength + 1 ) ) ;
249
249
250
- const editWindowLines = currentDocument . lines . value . slice ( editWindowLinesRange . start , editWindowLinesRange . endExclusive ) ;
250
+ const editWindowLines = currentDocument . lines . slice ( editWindowLinesRange . start , editWindowLinesRange . endExclusive ) ;
251
251
252
252
// Expected: editWindow.substring(activeDocument.documentAfterEdits.value) === editWindowLines.join('\n')
253
253
@@ -390,8 +390,8 @@ export class XtabProvider implements IStatelessNextEditProvider {
390
390
] . join ( '\n' ) ;
391
391
392
392
const currentFileContentLines = opts . includeLineNumbers
393
- ? addLineNumbers ( currentDocument . lines . value )
394
- : currentDocument . lines . value ;
393
+ ? addLineNumbers ( currentDocument . lines )
394
+ : currentDocument . lines ;
395
395
396
396
let areaAroundCodeToEditForCurrentFile : string ;
397
397
if ( promptOptions . currentFile . includeTags ) {
@@ -816,14 +816,18 @@ export class XtabProvider implements IStatelessNextEditProvider {
816
816
return ;
817
817
}
818
818
819
- private computeAreaAroundEditWindowLinesRange ( currentDocLines : string [ ] , cursorLine : number ) : OffsetRange {
819
+ private computeAreaAroundEditWindowLinesRange ( currentDocument : CurrentDocument ) : OffsetRange {
820
+ const cursorLine = currentDocument . cursorLineOffset ;
820
821
const areaAroundStart = Math . max ( 0 , cursorLine - N_LINES_AS_CONTEXT ) ;
821
- const areaAroundEndExcl = Math . min ( currentDocLines . length , cursorLine + N_LINES_AS_CONTEXT + 1 ) ;
822
+ const areaAroundEndExcl = Math . min ( currentDocument . lines . length , cursorLine + N_LINES_AS_CONTEXT + 1 ) ;
822
823
823
824
return new OffsetRange ( areaAroundStart , areaAroundEndExcl ) ;
824
825
}
825
826
826
- private computeEditWindowLinesRange ( currentDocLines : string [ ] , cursorLine : number , request : StatelessNextEditRequest , retryState : RetryState ) : OffsetRange {
827
+ private computeEditWindowLinesRange ( currentDocument : CurrentDocument , request : StatelessNextEditRequest , retryState : RetryState ) : OffsetRange {
828
+ const currentDocLines = currentDocument . lines ;
829
+ const cursorLineOffset = currentDocument . cursorLineOffset ;
830
+
827
831
let nLinesAbove : number ;
828
832
{
829
833
const useVaryingLinesAbove = this . configService . getExperimentBasedConfig ( ConfigKey . Internal . InlineEditsXtabProviderUseVaryingLinesAbove , this . expService ) ;
@@ -832,7 +836,7 @@ export class XtabProvider implements IStatelessNextEditProvider {
832
836
nLinesAbove = 0 ; // default
833
837
834
838
for ( let i = 0 ; i < 8 ; ++ i ) {
835
- const lineIdx = cursorLine - i ;
839
+ const lineIdx = cursorLineOffset - i ;
836
840
if ( lineIdx < 0 ) {
837
841
break ;
838
842
}
@@ -867,8 +871,8 @@ export class XtabProvider implements IStatelessNextEditProvider {
867
871
nLinesBelow += this . configService . getExperimentBasedConfig ( ConfigKey . Internal . InlineEditsXtabProviderRetryWithNMoreLinesBelow , this . expService ) ?? 0 ;
868
872
}
869
873
870
- let codeToEditStart = Math . max ( 0 , cursorLine - nLinesAbove ) ;
871
- let codeToEditEndExcl = Math . min ( currentDocLines . length , cursorLine + nLinesBelow + 1 ) ;
874
+ let codeToEditStart = Math . max ( 0 , cursorLineOffset - nLinesAbove ) ;
875
+ let codeToEditEndExcl = Math . min ( currentDocLines . length , cursorLineOffset + nLinesBelow + 1 ) ;
872
876
873
877
const maxMergeConflictLines = this . configService . getExperimentBasedConfig ( ConfigKey . Internal . InlineEditsXtabMaxMergeConflictLines , this . expService ) ;
874
878
if ( maxMergeConflictLines ) {
0 commit comments