Skip to content

Commit 92d3278

Browse files
authored
add preceeded flag (microsoft#255891)
1 parent c758ad4 commit 92d3278

File tree

7 files changed

+19
-2
lines changed

7 files changed

+19
-2
lines changed

src/vs/editor/common/languages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ export type LifetimeSummary = {
992992
editorType: string;
993993
viewKind: string | undefined;
994994
error: string | undefined;
995+
preceeded: boolean;
995996
languageId: string;
996997
requestReason: string;
997998
cursorColumnDistance?: number;

src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ class InlineCompletionsState extends Disposable {
422422
if (oldItem && oldItem !== i) {
423423
item = i.withIdentity(oldItem.identity);
424424
oldItem.setEndOfLifeReason({ kind: InlineCompletionEndOfLifeReasonKind.Ignored, userTypingDisagreed: false, supersededBy: i.getSourceCompletion() });
425+
i.setIsPreceeded();
425426
} else {
426427
item = i;
427428
}

src/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ abstract class InlineSuggestionItemBase {
120120
this._data.reportInlineEditError(reason);
121121
}
122122

123+
public setIsPreceeded(): void {
124+
this._data.setIsPreceeded();
125+
}
126+
123127
/**
124128
* Avoid using this method. Instead introduce getters for the needed properties.
125129
*/

src/vs/editor/contrib/inlineCompletions/browser/model/provideInlineCompletions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export class InlineSuggestData {
267267
private _viewData: InlineSuggestViewData;
268268
private _didReportEndOfLife = false;
269269
private _lastSetEndOfLifeReason: InlineCompletionEndOfLifeReason | undefined = undefined;
270+
private _isPreceeded = false;
270271
private _partiallyAcceptedCount = 0;
271272

272273
constructor(
@@ -347,6 +348,7 @@ export class InlineSuggestData {
347348
shown: this._didShow,
348349
shownDuration: this._shownDuration,
349350
shownDurationUncollapsed: this._showUncollapsedDuration,
351+
preceeded: this._isPreceeded,
350352
timeUntilShown: this._timeUntilShown,
351353
editorType: this._viewData.editorType,
352354
languageId: this._requestInfo.languageId,
@@ -369,6 +371,10 @@ export class InlineSuggestData {
369371
}
370372
}
371373

374+
public setIsPreceeded(): void {
375+
this._isPreceeded = true;
376+
}
377+
372378
/**
373379
* Sets the end of life reason, but does not send the event to the provider yet.
374380
*/

src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,16 @@ export class InlineEditsView extends Disposable {
446446
}));
447447

448448
const cursorPosition = inlineEdit.cursorPosition;
449+
const startsWithEOL = stringChanges[0].modified.startsWith(textModel.getEOL());
449450
const viewData: InlineCompletionViewData = {
450451
cursorColumnDistance: inlineEdit.edit.replacements[0].range.getStartPosition().column - cursorPosition.column,
451-
cursorLineDistance: inlineEdit.lineEdit.lineRange.startLineNumber - cursorPosition.lineNumber,
452+
cursorLineDistance: inlineEdit.lineEdit.lineRange.startLineNumber - cursorPosition.lineNumber + (startsWithEOL && inlineEdit.lineEdit.lineRange.startLineNumber >= cursorPosition.lineNumber ? 1 : 0),
452453
lineCountOriginal: inlineEdit.lineEdit.lineRange.length,
453454
lineCountModified: inlineEdit.lineEdit.newLines.length,
454455
characterCountOriginal: stringChanges.reduce((acc, r) => acc + r.original.length, 0),
455456
characterCountModified: stringChanges.reduce((acc, r) => acc + r.modified.length, 0),
456457
disjointReplacements: stringChanges.length,
457-
sameShapeReplacements: stringChanges.length > 1 ? stringChanges.every(r => r.original === stringChanges[0].original && r.modified === stringChanges[0].modified) : undefined,
458+
sameShapeReplacements: stringChanges.every(r => r.original === stringChanges[0].original && r.modified === stringChanges[0].modified),
458459
};
459460

460461
switch (view) {

src/vs/monaco.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7565,6 +7565,7 @@ declare namespace monaco.languages {
75657565
editorType: string;
75667566
viewKind: string | undefined;
75677567
error: string | undefined;
7568+
preceeded: boolean;
75687569
languageId: string;
75697570
requestReason: string;
75707571
cursorColumnDistance?: number;

src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
655655
timeUntilShown: lifetimeSummary.timeUntilShown,
656656
editorType: lifetimeSummary.editorType,
657657
viewKind: lifetimeSummary.viewKind,
658+
preceeded: lifetimeSummary.preceeded,
658659
requestReason: lifetimeSummary.requestReason,
659660
error: lifetimeSummary.error,
660661
typingInterval: lifetimeSummary.typingInterval,
@@ -1308,6 +1309,7 @@ type InlineCompletionEndOfLifeEvent = {
13081309
timeUntilShown: number | undefined;
13091310
reason: 'accepted' | 'rejected' | 'ignored';
13101311
partiallyAccepted: number;
1312+
preceeded: boolean;
13111313
requestReason: string;
13121314
languageId: string;
13131315
error: string | undefined;
@@ -1338,6 +1340,7 @@ type InlineCompletionsEndOfLifeClassification = {
13381340
timeUntilShown: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The time it took for the inline completion to be shown after the request' };
13391341
reason: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The reason for the inline completion ending' };
13401342
partiallyAccepted: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'How often the inline completion was partially accepted by the user' };
1343+
preceeded: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the inline completion was preceeded by another one' };
13411344
languageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language ID of the document where the inline completion was shown' };
13421345
requestReason: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The reason for the inline completion request' };
13431346
error: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The error message if the inline completion failed' };

0 commit comments

Comments
 (0)