Skip to content

Commit d60ffdc

Browse files
authored
fix: set isNESForAnotherDoc correctly for cross-file NES (#310794)
Previously isNESForAnotherDoc was only set inside addNotebookTelemetry, so non-notebook cross-file NES always reported false. - Set the flag on the main edit path for all cases (notebook and non-notebook) - Set the flag on the jump-to-position path when targetDocumentId differs - Set the flag and status 'noEdit:crossFileTargetNotFound' when cross-file target document is not found in the workspace - Remove redundant setIsNESForOtherEditor call from addNotebookTelemetry
1 parent 8bae860 commit d60ffdc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

extensions/copilot/src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ export class InlineCompletionProviderImpl extends Disposable implements InlineCo
354354
const positionToJumpOneBased = suggestionInfo.suggestion.result.jumpToPosition;
355355
const jumpToPosition = new Position(positionToJumpOneBased.lineNumber - 1, positionToJumpOneBased.column - 1);
356356
const targetDocumentId = suggestionInfo.suggestion.result.targetDocumentId;
357+
telemetryBuilder.setIsNESForOtherEditor(!!targetDocumentId && targetDocumentId !== doc.id);
357358
const jumpToPositionCompletionItem: NesCompletionItem = {
358359
insertText: undefined as unknown as string,
359360
info: suggestionInfo,
@@ -388,6 +389,8 @@ export class InlineCompletionProviderImpl extends Disposable implements InlineCo
388389
resolveDoc = targetObsDoc;
389390
} else {
390391
logger.trace('no next edit suggestion: cross-file target document not found in workspace');
392+
telemetryBuilder.setIsNESForOtherEditor(true);
393+
telemetryBuilder.setStatus('noEdit:crossFileTargetNotFound');
391394
this.telemetrySender.scheduleSendingEnhancedTelemetry(suggestionInfo.suggestion, telemetryBuilder);
392395
return emptyList;
393396
}
@@ -396,6 +399,7 @@ export class InlineCompletionProviderImpl extends Disposable implements InlineCo
396399
const [targetDocument, range] = documents.length ? documents[0] : [undefined, undefined];
397400

398401
addNotebookTelemetry(document, position, result.edit.newText, documents, telemetryBuilder);
402+
telemetryBuilder.setIsNESForOtherEditor(targetDocument !== undefined && targetDocument !== document);
399403
telemetryBuilder.setIsActiveDocument(window.activeTextEditor?.document === targetDocument);
400404

401405
if (!targetDocument) {
@@ -769,6 +773,5 @@ function addNotebookTelemetry(document: TextDocument, position: Position, newTex
769773
.setIsNextEditorVisible(!!nextEditor)
770774
.setIsNextEditorRangeVisible(!!isNextEditorRangeVisible)
771775
.setNotebookCellLines(lineCounts)
772-
.setNotebookId(notebookId)
773-
.setIsNESForOtherEditor(documents[0][0] !== document);
776+
.setNotebookId(notebookId);
774777
}

0 commit comments

Comments
 (0)