mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
This commit is contained in:
committed by
Henning Dieterichs
parent
1c8a55c110
commit
8b01ac01a7
@@ -130,6 +130,7 @@ export type IModel = ITextModel;
|
|||||||
|
|
||||||
declare namespace monaco.languages {
|
declare namespace monaco.languages {
|
||||||
|
|
||||||
|
#include(vs/editor/common/textModelEditSource): EditDeltaInfo
|
||||||
#include(vs/base/common/glob): IRelativePattern
|
#include(vs/base/common/glob): IRelativePattern
|
||||||
#include(vs/editor/common/languageSelector): LanguageSelector, LanguageFilter
|
#include(vs/editor/common/languageSelector): LanguageSelector, LanguageFilter
|
||||||
#includeAll(vs/editor/standalone/browser/standaloneLanguages;languages.=>;editorCommon.=>editor.;model.=>editor.;IMarkerData=>editor.IMarkerData):
|
#includeAll(vs/editor/standalone/browser/standaloneLanguages;languages.=>;editorCommon.=>editor.;model.=>editor.;IMarkerData=>editor.IMarkerData):
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { ContiguousMultilineTokens } from './tokens/contiguousMultilineTokens.js
|
|||||||
import { localize } from '../../nls.js';
|
import { localize } from '../../nls.js';
|
||||||
import { ExtensionIdentifier } from '../../platform/extensions/common/extensions.js';
|
import { ExtensionIdentifier } from '../../platform/extensions/common/extensions.js';
|
||||||
import { IMarkerData } from '../../platform/markers/common/markers.js';
|
import { IMarkerData } from '../../platform/markers/common/markers.js';
|
||||||
|
import { EditDeltaInfo } from './textModelEditSource.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -886,7 +887,7 @@ export interface InlineCompletionsProvider<T extends InlineCompletions = InlineC
|
|||||||
* Will be called when an item is shown.
|
* Will be called when an item is shown.
|
||||||
* @param updatedInsertText Is useful to understand bracket completion.
|
* @param updatedInsertText Is useful to understand bracket completion.
|
||||||
*/
|
*/
|
||||||
handleItemDidShow?(completions: T, item: T['items'][number], updatedInsertText: string): void;
|
handleItemDidShow?(completions: T, item: T['items'][number], updatedInsertText: string, editDeltaInfo: EditDeltaInfo): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will be called when an item is partially accepted. TODO: also handle full acceptance here!
|
* Will be called when an item is partially accepted. TODO: also handle full acceptance here!
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ export class EditDeltaInfo {
|
|||||||
return new EditDeltaInfo(linesAdded, 0, charsAdded, 0);
|
return new EditDeltaInfo(linesAdded, 0, charsAdded, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
public static fromEdit(edit: BaseStringEdit, originalString: StringText): EditDeltaInfo {
|
public static fromEdit(edit: BaseStringEdit, originalString: StringText): EditDeltaInfo {
|
||||||
const lineEdit = LineEdit.fromStringEdit(edit, originalString);
|
const lineEdit = LineEdit.fromStringEdit(edit, originalString);
|
||||||
const linesAdded = sumBy(lineEdit.replacements, r => r.newLines.length);
|
const linesAdded = sumBy(lineEdit.replacements, r => r.newLines.length);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { CachedFunction } from '../../../../../base/common/cache.js';
|
|||||||
import { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';
|
import { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';
|
||||||
import { isDefined } from '../../../../../base/common/types.js';
|
import { isDefined } from '../../../../../base/common/types.js';
|
||||||
import { inlineCompletionIsVisible } from './inlineSuggestionItem.js';
|
import { inlineCompletionIsVisible } from './inlineSuggestionItem.js';
|
||||||
|
import { EditDeltaInfo } from '../../../../common/textModelEditSource.js';
|
||||||
|
|
||||||
export type InlineCompletionContextWithoutUuid = Omit<InlineCompletionContext, 'requestUuid'>;
|
export type InlineCompletionContextWithoutUuid = Omit<InlineCompletionContext, 'requestUuid'>;
|
||||||
|
|
||||||
@@ -331,7 +332,8 @@ export class InlineSuggestData {
|
|||||||
this._viewData.renderData = viewData;
|
this._viewData.renderData = viewData;
|
||||||
this._timeUntilShown = Date.now() - this._requestInfo.startTime;
|
this._timeUntilShown = Date.now() - this._requestInfo.startTime;
|
||||||
|
|
||||||
this.source.provider.handleItemDidShow?.(this.source.inlineSuggestions, this.sourceInlineCompletion, updatedInsertText);
|
const editDeltaInfo = new EditDeltaInfo(viewData.lineCountModified, viewData.lineCountOriginal, viewData.characterCountModified, viewData.characterCountOriginal);
|
||||||
|
this.source.provider.handleItemDidShow?.(this.source.inlineSuggestions, this.sourceInlineCompletion, updatedInsertText, editDeltaInfo);
|
||||||
|
|
||||||
if (this.sourceInlineCompletion.shownCommand) {
|
if (this.sourceInlineCompletion.shownCommand) {
|
||||||
await commandService.executeCommand(this.sourceInlineCompletion.shownCommand.id, ...(this.sourceInlineCompletion.shownCommand.arguments || []));
|
await commandService.executeCommand(this.sourceInlineCompletion.shownCommand.id, ...(this.sourceInlineCompletion.shownCommand.arguments || []));
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { IMonarchLanguage } from '../common/monarch/monarchTypes.js';
|
|||||||
import { IStandaloneThemeService } from '../common/standaloneTheme.js';
|
import { IStandaloneThemeService } from '../common/standaloneTheme.js';
|
||||||
import { IConfigurationService } from '../../../platform/configuration/common/configuration.js';
|
import { IConfigurationService } from '../../../platform/configuration/common/configuration.js';
|
||||||
import { IMarkerData, IMarkerService } from '../../../platform/markers/common/markers.js';
|
import { IMarkerData, IMarkerService } from '../../../platform/markers/common/markers.js';
|
||||||
|
import { EditDeltaInfo } from '../../common/textModelEditSource.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register information about a new language.
|
* Register information about a new language.
|
||||||
@@ -811,5 +812,6 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages {
|
|||||||
// classes
|
// classes
|
||||||
FoldingRangeKind: languages.FoldingRangeKind,
|
FoldingRangeKind: languages.FoldingRangeKind,
|
||||||
SelectedSuggestionInfo: <any>languages.SelectedSuggestionInfo,
|
SelectedSuggestionInfo: <any>languages.SelectedSuggestionInfo,
|
||||||
|
EditDeltaInfo: <any>EditDeltaInfo,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+11
-1
@@ -6517,6 +6517,16 @@ declare namespace monaco.editor {
|
|||||||
|
|
||||||
declare namespace monaco.languages {
|
declare namespace monaco.languages {
|
||||||
|
|
||||||
|
|
||||||
|
export class EditDeltaInfo {
|
||||||
|
readonly linesAdded: number;
|
||||||
|
readonly linesRemoved: number;
|
||||||
|
readonly charsAdded: number;
|
||||||
|
readonly charsRemoved: number;
|
||||||
|
static fromText(text: string): EditDeltaInfo;
|
||||||
|
static tryCreate(linesAdded: number | undefined, linesRemoved: number | undefined, charsAdded: number | undefined, charsRemoved: number | undefined): EditDeltaInfo | undefined;
|
||||||
|
constructor(linesAdded: number, linesRemoved: number, charsAdded: number, charsRemoved: number);
|
||||||
|
}
|
||||||
export interface IRelativePattern {
|
export interface IRelativePattern {
|
||||||
/**
|
/**
|
||||||
* A base file path to which this pattern will be matched against relatively.
|
* A base file path to which this pattern will be matched against relatively.
|
||||||
@@ -7589,7 +7599,7 @@ declare namespace monaco.languages {
|
|||||||
* Will be called when an item is shown.
|
* Will be called when an item is shown.
|
||||||
* @param updatedInsertText Is useful to understand bracket completion.
|
* @param updatedInsertText Is useful to understand bracket completion.
|
||||||
*/
|
*/
|
||||||
handleItemDidShow?(completions: T, item: T['items'][number], updatedInsertText: string): void;
|
handleItemDidShow?(completions: T, item: T['items'][number], updatedInsertText: string, editDeltaInfo: EditDeltaInfo): void;
|
||||||
/**
|
/**
|
||||||
* Will be called when an item is partially accepted. TODO: also handle full acceptance here!
|
* Will be called when an item is partially accepted. TODO: also handle full acceptance here!
|
||||||
* @param acceptedCharacters Deprecated. Use `info.acceptedCharacters` instead.
|
* @param acceptedCharacters Deprecated. Use `info.acceptedCharacters` instead.
|
||||||
|
|||||||
@@ -638,19 +638,21 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
|
|||||||
const result = await this._proxy.$provideInlineCompletions(handle, model.uri, position, context, token);
|
const result = await this._proxy.$provideInlineCompletions(handle, model.uri, position, context, token);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
handleItemDidShow: async (completions: IdentifiableInlineCompletions, item: IdentifiableInlineCompletion, updatedInsertText: string): Promise<void> => {
|
handleItemDidShow: async (completions: IdentifiableInlineCompletions, item: IdentifiableInlineCompletion, updatedInsertText: string, editDeltaInfo: EditDeltaInfo): Promise<void> => {
|
||||||
this._instantiationService.invokeFunction(accessor => {
|
this._instantiationService.invokeFunction(accessor => {
|
||||||
const aiEditTelemetryService = accessor.getIfExists(IAiEditTelemetryService);
|
const aiEditTelemetryService = accessor.getIfExists(IAiEditTelemetryService);
|
||||||
item.suggestionId = aiEditTelemetryService?.createSuggestionId({
|
if (item.suggestionId === undefined) {
|
||||||
applyCodeBlockSuggestionId: undefined,
|
item.suggestionId = aiEditTelemetryService?.createSuggestionId({
|
||||||
feature: 'inlineSuggestion',
|
applyCodeBlockSuggestionId: undefined,
|
||||||
source: providerId,
|
feature: 'inlineSuggestion',
|
||||||
languageId: completions.languageId,
|
source: providerId,
|
||||||
editDeltaInfo: new EditDeltaInfo(1, 1, -1, -1), // TODO@hediet, fix this approximation.
|
languageId: completions.languageId,
|
||||||
modeId: undefined,
|
editDeltaInfo: editDeltaInfo,
|
||||||
modelId: undefined,
|
modeId: undefined,
|
||||||
presentation: item.isInlineEdit ? 'nextEditSuggestion' : 'inlineCompletion',
|
modelId: undefined,
|
||||||
});
|
presentation: item.isInlineEdit ? 'nextEditSuggestion' : 'inlineCompletion',
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (supportsHandleEvents) {
|
if (supportsHandleEvents) {
|
||||||
@@ -681,23 +683,25 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
|
|||||||
if (reason.kind === languages.InlineCompletionEndOfLifeReasonKind.Accepted) {
|
if (reason.kind === languages.InlineCompletionEndOfLifeReasonKind.Accepted) {
|
||||||
this._instantiationService.invokeFunction(accessor => {
|
this._instantiationService.invokeFunction(accessor => {
|
||||||
const aiEditTelemetryService = accessor.getIfExists(IAiEditTelemetryService);
|
const aiEditTelemetryService = accessor.getIfExists(IAiEditTelemetryService);
|
||||||
aiEditTelemetryService?.handleCodeAccepted({
|
if (item.suggestionId !== undefined) {
|
||||||
suggestionId: item.suggestionId,
|
aiEditTelemetryService?.handleCodeAccepted({
|
||||||
feature: 'inlineSuggestion',
|
suggestionId: item.suggestionId,
|
||||||
source: providerId,
|
feature: 'inlineSuggestion',
|
||||||
languageId: completions.languageId,
|
source: providerId,
|
||||||
editDeltaInfo: EditDeltaInfo.tryCreate(
|
languageId: completions.languageId,
|
||||||
lifetimeSummary.lineCountModified,
|
editDeltaInfo: EditDeltaInfo.tryCreate(
|
||||||
lifetimeSummary.lineCountOriginal,
|
lifetimeSummary.lineCountModified,
|
||||||
lifetimeSummary.characterCountModified,
|
lifetimeSummary.lineCountOriginal,
|
||||||
lifetimeSummary.characterCountOriginal,
|
lifetimeSummary.characterCountModified,
|
||||||
),
|
lifetimeSummary.characterCountOriginal,
|
||||||
modeId: undefined,
|
),
|
||||||
modelId: undefined,
|
modeId: undefined,
|
||||||
presentation: item.isInlineEdit ? 'nextEditSuggestion' : 'inlineCompletion',
|
modelId: undefined,
|
||||||
acceptanceMethod: 'accept',
|
presentation: item.isInlineEdit ? 'nextEditSuggestion' : 'inlineCompletion',
|
||||||
applyCodeBlockSuggestionId: undefined,
|
acceptanceMethod: 'accept',
|
||||||
});
|
applyCodeBlockSuggestionId: undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user