monaco-editor-core 0.55.0-dev-20251026 → 0.55.0-dev-20251028

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/esm/nls.keys.json +1 -1
  2. package/esm/nls.messages.cs.js +2 -2
  3. package/esm/nls.messages.de.js +2 -2
  4. package/esm/nls.messages.es.js +2 -2
  5. package/esm/nls.messages.fr.js +2 -2
  6. package/esm/nls.messages.it.js +2 -2
  7. package/esm/nls.messages.ja.js +2 -2
  8. package/esm/nls.messages.js +1 -1
  9. package/esm/nls.messages.json +1 -1
  10. package/esm/nls.messages.ko.js +2 -2
  11. package/esm/nls.messages.pl.js +2 -2
  12. package/esm/nls.messages.pt-br.js +2 -2
  13. package/esm/nls.messages.ru.js +2 -2
  14. package/esm/nls.messages.tr.js +2 -2
  15. package/esm/nls.messages.zh-cn.js +2 -2
  16. package/esm/nls.messages.zh-tw.js +2 -2
  17. package/esm/nls.metadata.json +2 -0
  18. package/esm/vs/base/browser/ui/actionbar/actionbar.js +17 -0
  19. package/esm/vs/base/browser/ui/actionbar/actionbar.js.map +1 -1
  20. package/esm/vs/base/browser/ui/iconLabel/iconLabel.js +2 -1
  21. package/esm/vs/base/browser/ui/iconLabel/iconLabel.js.map +1 -1
  22. package/esm/vs/base/browser/ui/scrollbar/media/scrollbars.css +4 -0
  23. package/esm/vs/base/browser/ui/toolbar/toolbar.css +11 -0
  24. package/esm/vs/base/browser/ui/toolbar/toolbar.js +115 -2
  25. package/esm/vs/base/browser/ui/toolbar/toolbar.js.map +1 -1
  26. package/esm/vs/base/common/jsonSchema.js.map +1 -1
  27. package/esm/vs/editor/common/cursor/cursorWordOperations.js +14 -4
  28. package/esm/vs/editor/common/cursor/cursorWordOperations.js.map +1 -1
  29. package/esm/vs/editor/common/languages/textToHtmlTokenizer.js +21 -10
  30. package/esm/vs/editor/common/languages/textToHtmlTokenizer.js.map +1 -1
  31. package/esm/vs/editor/common/languages.js +5 -5
  32. package/esm/vs/editor/common/languages.js.map +1 -1
  33. package/esm/vs/editor/common/standalone/standaloneEnums.js +5 -5
  34. package/esm/vs/editor/common/standalone/standaloneEnums.js.map +1 -1
  35. package/esm/vs/editor/contrib/codeAction/browser/codeActionCommands.js.map +1 -1
  36. package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js.map +1 -1
  37. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +5 -5
  38. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js.map +1 -1
  39. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js +2 -2
  40. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js.map +1 -1
  41. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.js +22 -24
  42. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.js.map +1 -1
  43. package/esm/vs/editor/contrib/inlineCompletions/browser/model/provideInlineCompletions.js +16 -22
  44. package/esm/vs/editor/contrib/inlineCompletions/browser/model/provideInlineCompletions.js.map +1 -1
  45. package/esm/vs/editor/contrib/inlineCompletions/browser/telemetry.js.map +1 -1
  46. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditWithChanges.js.map +1 -1
  47. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsModel.js +1 -6
  48. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsModel.js.map +1 -1
  49. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js +6 -2
  50. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js.map +1 -1
  51. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViewInterface.js.map +1 -1
  52. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsCustomView.js +6 -6
  53. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsCustomView.js.map +1 -1
  54. package/esm/vs/editor/contrib/semanticTokens/browser/viewportSemanticTokens.js +6 -0
  55. package/esm/vs/editor/contrib/semanticTokens/browser/viewportSemanticTokens.js.map +1 -1
  56. package/esm/vs/editor/contrib/suggest/browser/suggestInlineCompletions.js +2 -2
  57. package/esm/vs/editor/contrib/suggest/browser/suggestInlineCompletions.js.map +1 -1
  58. package/esm/vs/editor/editor.api.d.ts +20 -18
  59. package/esm/vs/editor/standalone/browser/standaloneLanguages.js +1 -1
  60. package/esm/vs/editor/standalone/browser/standaloneLanguages.js.map +1 -1
  61. package/esm/vs/platform/theme/common/colorUtils.js +2 -2
  62. package/esm/vs/platform/theme/common/colors/miscColors.js +5 -4
  63. package/esm/vs/platform/theme/common/colors/miscColors.js.map +1 -1
  64. package/esm/vs/platform/theme/common/colors/quickpickColors.js +9 -9
  65. package/esm/vs/platform/theme/common/colors/searchColors.js +3 -3
  66. package/esm/vs/platform/theme/common/iconRegistry.js +6 -6
  67. package/esm/vs/platform/undoRedo/common/undoRedoService.js +20 -20
  68. package/esm/vs/platform/workspace/common/workspace.js +1 -1
  69. package/monaco.d.ts +20 -18
  70. package/package.json +2 -2
@@ -102,6 +102,7 @@ let InlineCompletionsSource = class InlineCompletionsSource extends Disposable {
102
102
  }
103
103
  }));
104
104
  }
105
+ this._state.recomputeInitiallyAndOnChange(this._store);
105
106
  }
106
107
  _updateCompletionsEnablement(enalementSetting) {
107
108
  const result = this._configurationService.getValue(enalementSetting);
@@ -216,7 +217,7 @@ let InlineCompletionsSource = class InlineCompletionsSource extends Disposable {
216
217
  const result = suggestions.map(c => ({
217
218
  range: c.editRange.toString(),
218
219
  text: c.insertText,
219
- displayLocation: c.displayLocation ? { label: c.displayLocation.label, range: c.displayLocation.range.toString(), kind: c.displayLocation.kind, jumpToEdit: c.displayLocation.jumpToEdit } : undefined,
220
+ hint: c.hint,
220
221
  isInlineEdit: c.isInlineEdit,
221
222
  showInlineEditMenu: c.showInlineEditMenu,
222
223
  providerId: c.source.provider.providerId?.toString(),
@@ -350,7 +351,6 @@ let InlineCompletionsSource = class InlineCompletionsSource extends Disposable {
350
351
  timeUntilProviderResponse: undefined,
351
352
  viewKind: undefined,
352
353
  preceeded: undefined,
353
- error: undefined,
354
354
  superseded: undefined,
355
355
  reason: undefined,
356
356
  correlationId: undefined,
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts","vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;AAEhG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAChI,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAe,iBAAiB,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACpI,OAAO,EAAE,OAAO,EAAoD,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACtK,iEAAiE;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,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AAI,IAAO,EAAE,KAAU;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","file":"inlineCompletionsSource.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { booleanComparator, compareBy, compareUndefinedSmallest, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findLastMax } from '../../../../../base/common/arraysFind.js';\nimport { RunOnceScheduler } from '../../../../../base/common/async.js';\nimport { CancellationTokenSource } from '../../../../../base/common/cancellation.js';\nimport { equalsIfDefined, itemEquals } from '../../../../../base/common/equals.js';\nimport { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';\nimport { derived, IObservable, IObservableWithChange, ITransaction, observableValue, recordChangesLazy, transaction } from '../../../../../base/common/observable.js';\n// eslint-disable-next-line local/code-no-deep-import-of-internal\nimport { observableReducerSettable } from '../../../../../base/common/observableInternal/experimental/reducer.js';\nimport { isDefined, isObject } from '../../../../../base/common/types.js';\nimport { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';\nimport { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';\nimport { DataChannelForwardingTelemetryService, forwardToChannelIf, isCopilotLikeExtension } from '../../../../../platform/dataChannel/browser/forwardingTelemetryService.js';\nimport { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';\nimport { ILogService } from '../../../../../platform/log/common/log.js';\nimport { observableConfigValue } from '../../../../../platform/observable/common/platformObservableUtils.js';\nimport product from '../../../../../platform/product/common/product.js';\nimport { StringEdit } from '../../../../common/core/edits/stringEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { InlineCompletionEndOfLifeReasonKind, InlineCompletionTriggerKind, InlineCompletionsProvider } from '../../../../common/languages.js';\nimport { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { offsetEditFromContentChanges } from '../../../../common/model/textModelStringEdit.js';\nimport { IFeatureDebounceInformation } from '../../../../common/services/languageFeatureDebounce.js';\nimport { IModelContentChangedEvent } from '../../../../common/textModelEvents.js';\nimport { formatRecordableLogEntry, IRecordableEditorLogEntry, IRecordableLogEntry, StructuredLogger } from '../structuredLogger.js';\nimport { InlineCompletionEndOfLifeEvent, sendInlineCompletionsEndOfLifeTelemetry } from '../telemetry.js';\nimport { wait } from '../utils.js';\nimport { InlineSuggestionIdentity, InlineSuggestionItem } from './inlineSuggestionItem.js';\nimport { InlineCompletionContextWithoutUuid, InlineSuggestRequestInfo, provideInlineCompletions, runWhenCancelled } from './provideInlineCompletions.js';\n\nexport class InlineCompletionsSource extends Disposable {\n\tprivate static _requestId = 0;\n\n\tprivate readonly _updateOperation = this._register(new MutableDisposable<UpdateOperation>());\n\n\tprivate readonly _loggingEnabled;\n\tprivate readonly _sendRequestData;\n\n\tprivate readonly _structuredFetchLogger;\n\n\tprivate readonly _state = observableReducerSettable(this, {\n\t\tinitial: () => ({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t}),\n\t\tdisposeFinal: (values) => {\n\t\t\tvalues.inlineCompletions.dispose();\n\t\t\tvalues.suggestWidgetInlineCompletions.dispose();\n\t\t},\n\t\tchangeTracker: recordChangesLazy(() => ({ versionId: this._versionId })),\n\t\tupdate: (reader, previousValue, changes) => {\n\t\t\tconst edit = StringEdit.compose(changes.changes.map(c => c.change ? offsetEditFromContentChanges(c.change.changes) : StringEdit.empty).filter(isDefined));\n\n\t\t\tif (edit.isEmpty()) {\n\t\t\t\treturn previousValue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tinlineCompletions: previousValue.inlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t\tsuggestWidgetInlineCompletions: previousValue.suggestWidgetInlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tpreviousValue.inlineCompletions.dispose();\n\t\t\t\tpreviousValue.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t}\n\t});\n\n\tpublic readonly inlineCompletions = this._state.map(this, v => v.inlineCompletions);\n\tpublic readonly suggestWidgetInlineCompletions = this._state.map(this, v => v.suggestWidgetInlineCompletions);\n\n\tprivate _completionsEnabled: Record<string, boolean> | undefined = undefined;\n\n\tconstructor(\n\t\tprivate readonly _textModel: ITextModel,\n\t\tprivate readonly _versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined>,\n\t\tprivate readonly _debounceValue: IFeatureDebounceInformation,\n\t\tprivate readonly _cursorPosition: IObservable<Position>,\n\t\t@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,\n\t\t@ILogService private readonly _logService: ILogService,\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService,\n\t\t@IContextKeyService private readonly _contextKeyService: IContextKeyService,\n\t) {\n\t\tsuper();\n\t\tthis._loggingEnabled = observableConfigValue('editor.inlineSuggest.logFetch', false, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._sendRequestData = observableConfigValue('editor.inlineSuggest.emptyResponseInformation', true, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._structuredFetchLogger = this._register(this._instantiationService.createInstance(StructuredLogger.cast<\n\t\t\t{ kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry\n\t\t\t| { kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry\n\t\t>(),\n\t\t\t'editor.inlineSuggest.logFetch.commandId'\n\t\t));\n\n\t\tthis.clearOperationOnTextModelChange.recomputeInitiallyAndOnChange(this._store);\n\n\t\tconst enablementSetting = product.defaultChatAgent?.completionsEnablementSetting ?? undefined;\n\t\tif (enablementSetting) {\n\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => {\n\t\t\t\tif (e.affectsConfiguration(enablementSetting)) {\n\t\t\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\t}\n\n\tprivate _updateCompletionsEnablement(enalementSetting: string) {\n\t\tconst result = this._configurationService.getValue<Record<string, boolean>>(enalementSetting);\n\t\tif (!isObject(result)) {\n\t\t\tthis._completionsEnabled = undefined;\n\t\t} else {\n\t\t\tthis._completionsEnabled = result;\n\t\t}\n\t}\n\n\tpublic readonly clearOperationOnTextModelChange = derived(this, reader => {\n\t\tthis._versionId.read(reader);\n\t\tthis._updateOperation.clear();\n\t\treturn undefined; // always constant\n\t});\n\n\tprivate _log(entry:\n\t\t{ sourceId: string; kind: 'start'; requestId: number; context: unknown; provider: string | undefined } & IRecordableEditorLogEntry\n\t\t| { sourceId: string; kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number; didAllProvidersReturn: boolean } & IRecordableLogEntry\n\t) {\n\t\tif (this._loggingEnabled.get()) {\n\t\t\tthis._logService.info(formatRecordableLogEntry(entry));\n\t\t}\n\t\tthis._structuredFetchLogger.log(entry);\n\t}\n\n\tprivate readonly _loadingCount = observableValue(this, 0);\n\n\tpublic fetch(\n\t\tproviders: InlineCompletionsProvider[],\n\t\tprovidersLabel: string | undefined,\n\t\tcontext: InlineCompletionContextWithoutUuid,\n\t\tactiveInlineCompletion: InlineSuggestionIdentity | undefined,\n\t\twithDebounce: boolean,\n\t\tuserJumpedToActiveCompletion: IObservable<boolean>,\n\t\trequestInfo: InlineSuggestRequestInfo\n\t): Promise<boolean> {\n\t\tconst position = this._cursorPosition.get();\n\t\tconst request = new UpdateRequest(position, context, this._textModel.getVersionId(), new Set(providers));\n\n\t\tconst target = context.selectedSuggestionInfo ? this.suggestWidgetInlineCompletions.get() : this.inlineCompletions.get();\n\n\t\tif (this._updateOperation.value?.request.satisfies(request)) {\n\t\t\treturn this._updateOperation.value.promise;\n\t\t} else if (target?.request?.satisfies(request)) {\n\t\t\treturn Promise.resolve(true);\n\t\t}\n\n\t\tconst updateOngoing = !!this._updateOperation.value;\n\t\tthis._updateOperation.clear();\n\n\t\tconst source = new CancellationTokenSource();\n\n\t\tconst promise = (async () => {\n\t\t\tconst store = new DisposableStore();\n\n\t\t\tthis._loadingCount.set(this._loadingCount.get() + 1, undefined);\n\t\t\tlet didDecrease = false;\n\t\t\tconst decreaseLoadingCount = () => {\n\t\t\t\tif (!didDecrease) {\n\t\t\t\t\tdidDecrease = true;\n\t\t\t\t\tthis._loadingCount.set(this._loadingCount.get() - 1, undefined);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst loadingReset = store.add(new RunOnceScheduler(() => decreaseLoadingCount(), 10 * 1000));\n\t\t\tloadingReset.schedule();\n\n\t\t\tconst inlineSuggestionsProviders = providers.filter(p => p.providerId);\n\t\t\tconst requestResponseInfo = new RequestResponseData(context, requestInfo, inlineSuggestionsProviders);\n\n\n\t\t\ttry {\n\t\t\t\tconst recommendedDebounceValue = this._debounceValue.get(this._textModel);\n\t\t\t\tconst debounceValue = findLastMax(\n\t\t\t\t\tproviders.map(p => p.debounceDelayMs),\n\t\t\t\t\tcompareUndefinedSmallest(numberComparator)\n\t\t\t\t) ?? recommendedDebounceValue;\n\n\t\t\t\t// Debounce in any case if update is ongoing\n\t\t\t\tconst shouldDebounce = updateOngoing || (withDebounce && context.triggerKind === InlineCompletionTriggerKind.Automatic);\n\t\t\t\tif (shouldDebounce) {\n\t\t\t\t\t// This debounces the operation\n\t\t\t\t\tawait wait(debounceValue, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:beforeFetch');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst requestId = InlineCompletionsSource._requestId++;\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tthis._log({\n\t\t\t\t\t\tsourceId: 'InlineCompletions.fetch',\n\t\t\t\t\t\tkind: 'start',\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\tmodelUri: this._textModel.uri,\n\t\t\t\t\t\tmodelVersion: this._textModel.getVersionId(),\n\t\t\t\t\t\tcontext: { triggerKind: context.triggerKind, suggestInfo: context.selectedSuggestionInfo ? true : undefined },\n\t\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\t\tprovider: providersLabel,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst startTime = new Date();\n\t\t\t\tconst providerResult = provideInlineCompletions(providers, this._cursorPosition.get(), this._textModel, context, requestInfo, this._languageConfigurationService);\n\n\t\t\t\trunWhenCancelled(source.token, () => providerResult.cancelAndDispose({ kind: 'tokenCancellation' }));\n\n\t\t\t\tlet shouldStopEarly = false;\n\t\t\t\tlet producedSuggestion = false;\n\n\t\t\t\tconst suggestions: InlineSuggestionItem[] = [];\n\t\t\t\tfor await (const list of providerResult.lists) {\n\t\t\t\t\tif (!list) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlist.addRef();\n\t\t\t\t\tstore.add(toDisposable(() => list.removeRef(list.inlineSuggestionsData.length === 0 ? { kind: 'empty' } : { kind: 'notTaken' })));\n\n\t\t\t\t\tfor (const item of list.inlineSuggestionsData) {\n\t\t\t\t\t\tproducedSuggestion = true;\n\t\t\t\t\t\tif (!context.includeInlineEdits && (item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineEditRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!context.includeInlineCompletions && !(item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineCompletionRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst i = InlineSuggestionItem.create(item, this._textModel);\n\t\t\t\t\t\tsuggestions.push(i);\n\t\t\t\t\t\t// Stop after first visible inline completion\n\t\t\t\t\t\tif (!i.isInlineEdit && !i.showInlineEditMenu && context.triggerKind === InlineCompletionTriggerKind.Automatic) {\n\t\t\t\t\t\t\tif (i.isVisible(this._textModel, this._cursorPosition.get())) {\n\t\t\t\t\t\t\t\tshouldStopEarly = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldStopEarly) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tproviderResult.cancelAndDispose({ kind: 'lostRace' });\n\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tconst didAllProvidersReturn = providerResult.didAllProvidersReturn;\n\t\t\t\t\tlet error: string | undefined = undefined;\n\t\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\t\terror = 'canceled';\n\t\t\t\t\t}\n\t\t\t\t\tconst result = suggestions.map(c => ({\n\t\t\t\t\t\trange: c.editRange.toString(),\n\t\t\t\t\t\ttext: c.insertText,\n\t\t\t\t\t\tdisplayLocation: c.displayLocation ? { label: c.displayLocation.label, range: c.displayLocation.range.toString(), kind: c.displayLocation.kind, jumpToEdit: c.displayLocation.jumpToEdit } : undefined,\n\t\t\t\t\t\tisInlineEdit: c.isInlineEdit,\n\t\t\t\t\t\tshowInlineEditMenu: c.showInlineEditMenu,\n\t\t\t\t\t\tproviderId: c.source.provider.providerId?.toString(),\n\t\t\t\t\t}));\n\t\t\t\t\tthis._log({ sourceId: 'InlineCompletions.fetch', kind: 'end', requestId, durationMs: (Date.now() - startTime.getTime()), error, result, time: Date.now(), didAllProvidersReturn });\n\t\t\t\t}\n\n\t\t\t\trequestResponseInfo.setRequestUuid(providerResult.contextWithUuid.requestUuid);\n\t\t\t\tif (producedSuggestion) {\n\t\t\t\t\trequestResponseInfo.setHasProducedSuggestion();\n\t\t\t\t\tif (suggestions.length > 0 && source.token.isCancellationRequested) {\n\t\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet('canceled:whileAwaitingOtherProviders'));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (source.token.isCancellationRequested) {\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:whileFetching');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst completionsQuotaExceeded = this._contextKeyService.getContextKeyValue<boolean>('completionsQuotaExceeded');\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet(completionsQuotaExceeded ? 'completionsQuotaExceeded' : 'noSuggestion');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst remainingTimeToWait = context.earliestShownDateTime - Date.now();\n\t\t\t\tif (remainingTimeToWait > 0) {\n\t\t\t\t\tawait wait(remainingTimeToWait, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId\n\t\t\t\t\t|| userJumpedToActiveCompletion.get() /* In the meantime the user showed interest for the active completion so dont hide it */) {\n\t\t\t\t\tconst notShownReason =\n\t\t\t\t\t\tsource.token.isCancellationRequested ? 'canceled:afterMinShowDelay' :\n\t\t\t\t\t\t\tthis._store.isDisposed ? 'canceled:disposed' :\n\t\t\t\t\t\t\t\tthis._textModel.getVersionId() !== request.versionId ? 'canceled:documentChanged' :\n\t\t\t\t\t\t\t\t\tuserJumpedToActiveCompletion.get() ? 'canceled:userJumped' :\n\t\t\t\t\t\t\t\t\t\t'unknown';\n\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet(notShownReason));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst endTime = new Date();\n\t\t\t\tthis._debounceValue.update(this._textModel, endTime.getTime() - startTime.getTime());\n\n\t\t\t\tconst cursorPosition = this._cursorPosition.get();\n\t\t\t\tthis._updateOperation.clear();\n\t\t\t\ttransaction(tx => {\n\t\t\t\t\t/** @description Update completions with provider result */\n\t\t\t\t\tconst v = this._state.get();\n\n\t\t\t\t\tif (context.selectedSuggestionInfo) {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: v.suggestWidgetInlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: v.inlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t}\n\n\t\t\t\t\tv.inlineCompletions.dispose();\n\t\t\t\t\tv.suggestWidgetInlineCompletions.dispose();\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tstore.dispose();\n\t\t\t\tdecreaseLoadingCount();\n\t\t\t\tthis.sendInlineCompletionsRequestTelemetry(requestResponseInfo);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tconst updateOperation = new UpdateOperation(request, source, promise);\n\t\tthis._updateOperation.value = updateOperation;\n\n\t\treturn promise;\n\t}\n\n\tpublic clear(tx: ITransaction): void {\n\t\tthis._updateOperation.clear();\n\t\tconst v = this._state.get();\n\t\tthis._state.set({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty()\n\t\t}, tx);\n\t\tv.inlineCompletions.dispose();\n\t\tv.suggestWidgetInlineCompletions.dispose();\n\t}\n\n\tpublic seedInlineCompletionsWithSuggestWidget(): void {\n\t\tconst inlineCompletions = this.inlineCompletions.get();\n\t\tconst suggestWidgetInlineCompletions = this.suggestWidgetInlineCompletions.get();\n\t\tif (!suggestWidgetInlineCompletions) {\n\t\t\treturn;\n\t\t}\n\t\ttransaction(tx => {\n\t\t\t/** @description Seed inline completions with (newer) suggest widget inline completions */\n\t\t\tif (!inlineCompletions || (suggestWidgetInlineCompletions.request?.versionId ?? -1) > (inlineCompletions.request?.versionId ?? -1)) {\n\t\t\t\tinlineCompletions?.dispose();\n\t\t\t\tconst s = this._state.get();\n\t\t\t\tthis._state.set({\n\t\t\t\t\tinlineCompletions: suggestWidgetInlineCompletions.clone(),\n\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t}, tx);\n\t\t\t\ts.inlineCompletions.dispose();\n\t\t\t\ts.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t\tthis.clearSuggestWidgetInlineCompletions(tx);\n\t\t});\n\t}\n\n\tprivate sendInlineCompletionsRequestTelemetry(\n\t\trequestResponseInfo: RequestResponseData\n\t): void {\n\t\tif (!this._sendRequestData.get() && !this._contextKeyService.getContextKeyValue<boolean>('isRunningUnificationExperiment')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (requestResponseInfo.requestUuid === undefined || requestResponseInfo.hasProducedSuggestion) {\n\t\t\treturn;\n\t\t}\n\n\n\t\tif (!isCompletionsEnabled(this._completionsEnabled, this._textModel.getLanguageId())) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst emptyEndOfLifeEvent: InlineCompletionEndOfLifeEvent = {\n\t\t\topportunityId: requestResponseInfo.requestUuid,\n\t\t\tnoSuggestionReason: requestResponseInfo.noSuggestionReason ?? 'unknown',\n\t\t\textensionId: 'vscode-core',\n\t\t\textensionVersion: '0.0.0',\n\t\t\tgroupId: 'empty',\n\t\t\tshown: false,\n\t\t\teditorType: requestResponseInfo.requestInfo.editorType,\n\t\t\trequestReason: requestResponseInfo.requestInfo.reason,\n\t\t\ttypingInterval: requestResponseInfo.requestInfo.typingInterval,\n\t\t\ttypingIntervalCharacterCount: requestResponseInfo.requestInfo.typingIntervalCharacterCount,\n\t\t\tlanguageId: requestResponseInfo.requestInfo.languageId,\n\t\t\tselectedSuggestionInfo: !!requestResponseInfo.context.selectedSuggestionInfo,\n\t\t\tavailableProviders: requestResponseInfo.providers.map(p => p.providerId?.toString()).filter(isDefined).join(','),\n\t\t\t...forwardToChannelIf(requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))),\n\t\t\ttimeUntilProviderRequest: undefined,\n\t\t\ttimeUntilProviderResponse: undefined,\n\t\t\tviewKind: undefined,\n\t\t\tpreceeded: undefined,\n\t\t\terror: undefined,\n\t\t\tsuperseded: undefined,\n\t\t\treason: undefined,\n\t\t\tcorrelationId: undefined,\n\t\t\tshownDuration: undefined,\n\t\t\tshownDurationUncollapsed: undefined,\n\t\t\ttimeUntilShown: undefined,\n\t\t\tpartiallyAccepted: undefined,\n\t\t\tpartiallyAcceptedCountSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedRatioSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedCharactersSinceOriginal: undefined,\n\t\t\tcursorColumnDistance: undefined,\n\t\t\tcursorLineDistance: undefined,\n\t\t\tlineCountOriginal: undefined,\n\t\t\tlineCountModified: undefined,\n\t\t\tcharacterCountOriginal: undefined,\n\t\t\tcharacterCountModified: undefined,\n\t\t\tdisjointReplacements: undefined,\n\t\t\tsameShapeReplacements: undefined,\n\t\t\tnotShownReason: undefined,\n\t\t};\n\n\t\tconst dataChannel = this._instantiationService.createInstance(DataChannelForwardingTelemetryService);\n\t\tsendInlineCompletionsEndOfLifeTelemetry(dataChannel, emptyEndOfLifeEvent);\n\t}\n\n\tpublic clearSuggestWidgetInlineCompletions(tx: ITransaction): void {\n\t\tif (this._updateOperation.value?.request.context.selectedSuggestionInfo) {\n\t\t\tthis._updateOperation.clear();\n\t\t}\n\t}\n\n\tpublic cancelUpdate(): void {\n\t\tthis._updateOperation.clear();\n\t}\n}\n\nclass UpdateRequest {\n\tconstructor(\n\t\tpublic readonly position: Position,\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly providers: Set<InlineCompletionsProvider>,\n\t) {\n\t}\n\n\tpublic satisfies(other: UpdateRequest): boolean {\n\t\treturn this.position.equals(other.position)\n\t\t\t&& equalsIfDefined(this.context.selectedSuggestionInfo, other.context.selectedSuggestionInfo, itemEquals())\n\t\t\t&& (other.context.triggerKind === InlineCompletionTriggerKind.Automatic\n\t\t\t\t|| this.context.triggerKind === InlineCompletionTriggerKind.Explicit)\n\t\t\t&& this.versionId === other.versionId\n\t\t\t&& isSubset(other.providers, this.providers);\n\t}\n}\n\nclass RequestResponseData {\n\tpublic requestUuid: string | undefined;\n\tpublic noSuggestionReason: string | undefined;\n\tpublic hasProducedSuggestion = false;\n\n\tconstructor(\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly requestInfo: InlineSuggestRequestInfo,\n\t\tpublic readonly providers: InlineCompletionsProvider[],\n\t) { }\n\n\tsetRequestUuid(uuid: string) {\n\t\tthis.requestUuid = uuid;\n\t}\n\n\tsetNoSuggestionReasonIfNotSet(type: string) {\n\t\tthis.noSuggestionReason ??= type;\n\t}\n\n\tsetHasProducedSuggestion() {\n\t\tthis.hasProducedSuggestion = true;\n\t}\n}\n\nfunction isSubset<T>(set1: Set<T>, set2: Set<T>): boolean {\n\treturn [...set1].every(item => set2.has(item));\n}\n\nfunction isCompletionsEnabled(completionsEnablementObject: Record<string, boolean> | undefined, modeId: string = '*'): boolean {\n\tif (completionsEnablementObject === undefined) {\n\t\treturn false; // default to disabled if setting is not available\n\t}\n\n\tif (typeof completionsEnablementObject[modeId] !== 'undefined') {\n\t\treturn Boolean(completionsEnablementObject[modeId]); // go with setting if explicitly defined\n\t}\n\n\treturn Boolean(completionsEnablementObject['*']); // fallback to global setting otherwise\n}\n\nclass UpdateOperation implements IDisposable {\n\tconstructor(\n\t\tpublic readonly request: UpdateRequest,\n\t\tpublic readonly cancellationTokenSource: CancellationTokenSource,\n\t\tpublic readonly promise: Promise<boolean>,\n\t) {\n\t}\n\n\tdispose() {\n\t\tthis.cancellationTokenSource.cancel();\n\t}\n}\n\nclass InlineCompletionsState extends Disposable {\n\tpublic static createEmpty(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState([], undefined);\n\t}\n\n\tconstructor(\n\t\tpublic readonly inlineCompletions: readonly InlineSuggestionItem[],\n\t\tpublic readonly request: UpdateRequest | undefined,\n\t) {\n\t\tfor (const inlineCompletion of inlineCompletions) {\n\t\t\tinlineCompletion.addRef();\n\t\t}\n\n\t\tsuper();\n\n\t\tthis._register({\n\t\t\tdispose: () => {\n\t\t\t\tfor (const inlineCompletion of this.inlineCompletions) {\n\t\t\t\t\tinlineCompletion.removeRef();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate _findById(id: InlineSuggestionIdentity): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.identity === id);\n\t}\n\n\tprivate _findByHash(hash: string): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.hash === hash);\n\t}\n\n\t/**\n\t * Applies the edit on the state.\n\t*/\n\tpublic createStateWithAppliedEdit(edit: StringEdit, textModel: ITextModel): InlineCompletionsState {\n\t\tconst newInlineCompletions = this.inlineCompletions.map(i => i.withEdit(edit, textModel)).filter(isDefined);\n\t\treturn new InlineCompletionsState(newInlineCompletions, this.request);\n\t}\n\n\tpublic createStateWithAppliedResults(updatedSuggestions: InlineSuggestionItem[], request: UpdateRequest, textModel: ITextModel, cursorPosition: Position, itemIdToPreserveAtTop: InlineSuggestionIdentity | undefined): InlineCompletionsState {\n\t\tlet itemToPreserve: InlineSuggestionItem | undefined = undefined;\n\t\tif (itemIdToPreserveAtTop) {\n\t\t\tconst itemToPreserveCandidate = this._findById(itemIdToPreserveAtTop);\n\t\t\tif (itemToPreserveCandidate && itemToPreserveCandidate.canBeReused(textModel, request.position)) {\n\t\t\t\titemToPreserve = itemToPreserveCandidate;\n\n\t\t\t\tconst updatedItemToPreserve = updatedSuggestions.find(i => i.hash === itemToPreserveCandidate.hash);\n\t\t\t\tif (updatedItemToPreserve) {\n\t\t\t\t\tupdatedSuggestions = moveToFront(updatedItemToPreserve, updatedSuggestions);\n\t\t\t\t} else {\n\t\t\t\t\tupdatedSuggestions = [itemToPreserveCandidate, ...updatedSuggestions];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst preferInlineCompletions = itemToPreserve\n\t\t\t// itemToPreserve has precedence\n\t\t\t? !itemToPreserve.isInlineEdit\n\t\t\t// Otherwise: prefer inline completion if there is a visible one\n\t\t\t: updatedSuggestions.some(i => !i.isInlineEdit && i.isVisible(textModel, cursorPosition));\n\n\t\tlet updatedItems: InlineSuggestionItem[] = [];\n\t\tfor (const i of updatedSuggestions) {\n\t\t\tconst oldItem = this._findByHash(i.hash);\n\t\t\tlet item;\n\t\t\tif (oldItem && oldItem !== i) {\n\t\t\t\titem = i.withIdentity(oldItem.identity);\n\t\t\t\ti.setIsPreceeded(oldItem);\n\t\t\t\toldItem.setEndOfLifeReason({ kind: InlineCompletionEndOfLifeReasonKind.Ignored, userTypingDisagreed: false, supersededBy: i.getSourceCompletion() });\n\t\t\t} else {\n\t\t\t\titem = i;\n\t\t\t}\n\t\t\tif (preferInlineCompletions !== item.isInlineEdit) {\n\t\t\t\tupdatedItems.push(item);\n\t\t\t}\n\t\t}\n\n\t\tupdatedItems.sort(compareBy(i => i.showInlineEditMenu, booleanComparator));\n\t\tupdatedItems = distinctByKey(updatedItems, i => i.semanticId);\n\n\t\treturn new InlineCompletionsState(updatedItems, request);\n\t}\n\n\tpublic clone(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState(this.inlineCompletions, this.request);\n\t}\n}\n\n/** Keeps the first item in case of duplicates. */\nfunction distinctByKey<T>(items: T[], key: (item: T) => unknown): T[] {\n\tconst seen = new Set();\n\treturn items.filter(item => {\n\t\tconst k = key(item);\n\t\tif (seen.has(k)) {\n\t\t\treturn false;\n\t\t}\n\t\tseen.add(k);\n\t\treturn true;\n\t});\n}\n\nfunction moveToFront<T>(item: T, items: T[]): T[] {\n\tconst index = items.indexOf(item);\n\tif (index > -1) {\n\t\treturn [item, ...items.slice(0, index), ...items.slice(index + 1)];\n\t}\n\treturn items;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { booleanComparator, compareBy, compareUndefinedSmallest, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findLastMax } from '../../../../../base/common/arraysFind.js';\nimport { RunOnceScheduler } from '../../../../../base/common/async.js';\nimport { CancellationTokenSource } from '../../../../../base/common/cancellation.js';\nimport { equalsIfDefined, itemEquals } from '../../../../../base/common/equals.js';\nimport { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';\nimport { derived, IObservable, IObservableWithChange, ITransaction, observableValue, recordChangesLazy, transaction } from '../../../../../base/common/observable.js';\n// eslint-disable-next-line local/code-no-deep-import-of-internal\nimport { observableReducerSettable } from '../../../../../base/common/observableInternal/experimental/reducer.js';\nimport { isDefined, isObject } from '../../../../../base/common/types.js';\nimport { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';\nimport { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';\nimport { DataChannelForwardingTelemetryService, forwardToChannelIf, isCopilotLikeExtension } from '../../../../../platform/dataChannel/browser/forwardingTelemetryService.js';\nimport { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';\nimport { ILogService } from '../../../../../platform/log/common/log.js';\nimport { observableConfigValue } from '../../../../../platform/observable/common/platformObservableUtils.js';\nimport product from '../../../../../platform/product/common/product.js';\nimport { StringEdit } from '../../../../common/core/edits/stringEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { InlineCompletionEndOfLifeReasonKind, InlineCompletionTriggerKind, InlineCompletionsProvider } from '../../../../common/languages.js';\nimport { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { offsetEditFromContentChanges } from '../../../../common/model/textModelStringEdit.js';\nimport { IFeatureDebounceInformation } from '../../../../common/services/languageFeatureDebounce.js';\nimport { IModelContentChangedEvent } from '../../../../common/textModelEvents.js';\nimport { formatRecordableLogEntry, IRecordableEditorLogEntry, IRecordableLogEntry, StructuredLogger } from '../structuredLogger.js';\nimport { InlineCompletionEndOfLifeEvent, sendInlineCompletionsEndOfLifeTelemetry } from '../telemetry.js';\nimport { wait } from '../utils.js';\nimport { InlineSuggestionIdentity, InlineSuggestionItem } from './inlineSuggestionItem.js';\nimport { InlineCompletionContextWithoutUuid, InlineSuggestRequestInfo, provideInlineCompletions, runWhenCancelled } from './provideInlineCompletions.js';\n\nexport class InlineCompletionsSource extends Disposable {\n\tprivate static _requestId = 0;\n\n\tprivate readonly _updateOperation = this._register(new MutableDisposable<UpdateOperation>());\n\n\tprivate readonly _loggingEnabled;\n\tprivate readonly _sendRequestData;\n\n\tprivate readonly _structuredFetchLogger;\n\n\tprivate readonly _state = observableReducerSettable(this, {\n\t\tinitial: () => ({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t}),\n\t\tdisposeFinal: (values) => {\n\t\t\tvalues.inlineCompletions.dispose();\n\t\t\tvalues.suggestWidgetInlineCompletions.dispose();\n\t\t},\n\t\tchangeTracker: recordChangesLazy(() => ({ versionId: this._versionId })),\n\t\tupdate: (reader, previousValue, changes) => {\n\t\t\tconst edit = StringEdit.compose(changes.changes.map(c => c.change ? offsetEditFromContentChanges(c.change.changes) : StringEdit.empty).filter(isDefined));\n\n\t\t\tif (edit.isEmpty()) {\n\t\t\t\treturn previousValue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tinlineCompletions: previousValue.inlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t\tsuggestWidgetInlineCompletions: previousValue.suggestWidgetInlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tpreviousValue.inlineCompletions.dispose();\n\t\t\t\tpreviousValue.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t}\n\t});\n\n\tpublic readonly inlineCompletions = this._state.map(this, v => v.inlineCompletions);\n\tpublic readonly suggestWidgetInlineCompletions = this._state.map(this, v => v.suggestWidgetInlineCompletions);\n\n\tprivate _completionsEnabled: Record<string, boolean> | undefined = undefined;\n\n\tconstructor(\n\t\tprivate readonly _textModel: ITextModel,\n\t\tprivate readonly _versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined>,\n\t\tprivate readonly _debounceValue: IFeatureDebounceInformation,\n\t\tprivate readonly _cursorPosition: IObservable<Position>,\n\t\t@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,\n\t\t@ILogService private readonly _logService: ILogService,\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService,\n\t\t@IContextKeyService private readonly _contextKeyService: IContextKeyService,\n\t) {\n\t\tsuper();\n\t\tthis._loggingEnabled = observableConfigValue('editor.inlineSuggest.logFetch', false, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._sendRequestData = observableConfigValue('editor.inlineSuggest.emptyResponseInformation', true, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._structuredFetchLogger = this._register(this._instantiationService.createInstance(StructuredLogger.cast<\n\t\t\t{ kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry\n\t\t\t| { kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry\n\t\t>(),\n\t\t\t'editor.inlineSuggest.logFetch.commandId'\n\t\t));\n\n\t\tthis.clearOperationOnTextModelChange.recomputeInitiallyAndOnChange(this._store);\n\n\t\tconst enablementSetting = product.defaultChatAgent?.completionsEnablementSetting ?? undefined;\n\t\tif (enablementSetting) {\n\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => {\n\t\t\t\tif (e.affectsConfiguration(enablementSetting)) {\n\t\t\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\t}\n\n\tprivate _updateCompletionsEnablement(enalementSetting: string) {\n\t\tconst result = this._configurationService.getValue<Record<string, boolean>>(enalementSetting);\n\t\tif (!isObject(result)) {\n\t\t\tthis._completionsEnabled = undefined;\n\t\t} else {\n\t\t\tthis._completionsEnabled = result;\n\t\t}\n\t}\n\n\tpublic readonly clearOperationOnTextModelChange = derived(this, reader => {\n\t\tthis._versionId.read(reader);\n\t\tthis._updateOperation.clear();\n\t\treturn undefined; // always constant\n\t});\n\n\tprivate _log(entry:\n\t\t{ sourceId: string; kind: 'start'; requestId: number; context: unknown; provider: string | undefined } & IRecordableEditorLogEntry\n\t\t| { sourceId: string; kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number; didAllProvidersReturn: boolean } & IRecordableLogEntry\n\t) {\n\t\tif (this._loggingEnabled.get()) {\n\t\t\tthis._logService.info(formatRecordableLogEntry(entry));\n\t\t}\n\t\tthis._structuredFetchLogger.log(entry);\n\t}\n\n\tprivate readonly _loadingCount = observableValue(this, 0);\n\n\tpublic fetch(\n\t\tproviders: InlineCompletionsProvider[],\n\t\tprovidersLabel: string | undefined,\n\t\tcontext: InlineCompletionContextWithoutUuid,\n\t\tactiveInlineCompletion: InlineSuggestionIdentity | undefined,\n\t\twithDebounce: boolean,\n\t\tuserJumpedToActiveCompletion: IObservable<boolean>,\n\t\trequestInfo: InlineSuggestRequestInfo\n\t): Promise<boolean> {\n\t\tconst position = this._cursorPosition.get();\n\t\tconst request = new UpdateRequest(position, context, this._textModel.getVersionId(), new Set(providers));\n\n\t\tconst target = context.selectedSuggestionInfo ? this.suggestWidgetInlineCompletions.get() : this.inlineCompletions.get();\n\n\t\tif (this._updateOperation.value?.request.satisfies(request)) {\n\t\t\treturn this._updateOperation.value.promise;\n\t\t} else if (target?.request?.satisfies(request)) {\n\t\t\treturn Promise.resolve(true);\n\t\t}\n\n\t\tconst updateOngoing = !!this._updateOperation.value;\n\t\tthis._updateOperation.clear();\n\n\t\tconst source = new CancellationTokenSource();\n\n\t\tconst promise = (async () => {\n\t\t\tconst store = new DisposableStore();\n\n\t\t\tthis._loadingCount.set(this._loadingCount.get() + 1, undefined);\n\t\t\tlet didDecrease = false;\n\t\t\tconst decreaseLoadingCount = () => {\n\t\t\t\tif (!didDecrease) {\n\t\t\t\t\tdidDecrease = true;\n\t\t\t\t\tthis._loadingCount.set(this._loadingCount.get() - 1, undefined);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst loadingReset = store.add(new RunOnceScheduler(() => decreaseLoadingCount(), 10 * 1000));\n\t\t\tloadingReset.schedule();\n\n\t\t\tconst inlineSuggestionsProviders = providers.filter(p => p.providerId);\n\t\t\tconst requestResponseInfo = new RequestResponseData(context, requestInfo, inlineSuggestionsProviders);\n\n\n\t\t\ttry {\n\t\t\t\tconst recommendedDebounceValue = this._debounceValue.get(this._textModel);\n\t\t\t\tconst debounceValue = findLastMax(\n\t\t\t\t\tproviders.map(p => p.debounceDelayMs),\n\t\t\t\t\tcompareUndefinedSmallest(numberComparator)\n\t\t\t\t) ?? recommendedDebounceValue;\n\n\t\t\t\t// Debounce in any case if update is ongoing\n\t\t\t\tconst shouldDebounce = updateOngoing || (withDebounce && context.triggerKind === InlineCompletionTriggerKind.Automatic);\n\t\t\t\tif (shouldDebounce) {\n\t\t\t\t\t// This debounces the operation\n\t\t\t\t\tawait wait(debounceValue, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:beforeFetch');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst requestId = InlineCompletionsSource._requestId++;\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tthis._log({\n\t\t\t\t\t\tsourceId: 'InlineCompletions.fetch',\n\t\t\t\t\t\tkind: 'start',\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\tmodelUri: this._textModel.uri,\n\t\t\t\t\t\tmodelVersion: this._textModel.getVersionId(),\n\t\t\t\t\t\tcontext: { triggerKind: context.triggerKind, suggestInfo: context.selectedSuggestionInfo ? true : undefined },\n\t\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\t\tprovider: providersLabel,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst startTime = new Date();\n\t\t\t\tconst providerResult = provideInlineCompletions(providers, this._cursorPosition.get(), this._textModel, context, requestInfo, this._languageConfigurationService);\n\n\t\t\t\trunWhenCancelled(source.token, () => providerResult.cancelAndDispose({ kind: 'tokenCancellation' }));\n\n\t\t\t\tlet shouldStopEarly = false;\n\t\t\t\tlet producedSuggestion = false;\n\n\t\t\t\tconst suggestions: InlineSuggestionItem[] = [];\n\t\t\t\tfor await (const list of providerResult.lists) {\n\t\t\t\t\tif (!list) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlist.addRef();\n\t\t\t\t\tstore.add(toDisposable(() => list.removeRef(list.inlineSuggestionsData.length === 0 ? { kind: 'empty' } : { kind: 'notTaken' })));\n\n\t\t\t\t\tfor (const item of list.inlineSuggestionsData) {\n\t\t\t\t\t\tproducedSuggestion = true;\n\t\t\t\t\t\tif (!context.includeInlineEdits && (item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineEditRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!context.includeInlineCompletions && !(item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineCompletionRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst i = InlineSuggestionItem.create(item, this._textModel);\n\t\t\t\t\t\tsuggestions.push(i);\n\t\t\t\t\t\t// Stop after first visible inline completion\n\t\t\t\t\t\tif (!i.isInlineEdit && !i.showInlineEditMenu && context.triggerKind === InlineCompletionTriggerKind.Automatic) {\n\t\t\t\t\t\t\tif (i.isVisible(this._textModel, this._cursorPosition.get())) {\n\t\t\t\t\t\t\t\tshouldStopEarly = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldStopEarly) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tproviderResult.cancelAndDispose({ kind: 'lostRace' });\n\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tconst didAllProvidersReturn = providerResult.didAllProvidersReturn;\n\t\t\t\t\tlet error: string | undefined = undefined;\n\t\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\t\terror = 'canceled';\n\t\t\t\t\t}\n\t\t\t\t\tconst result = suggestions.map(c => ({\n\t\t\t\t\t\trange: c.editRange.toString(),\n\t\t\t\t\t\ttext: c.insertText,\n\t\t\t\t\t\tdisplayLocation: c.displayLocation ? { label: c.displayLocation.label, range: c.displayLocation.range.toString(), kind: c.displayLocation.kind, jumpToEdit: c.displayLocation.jumpToEdit } : undefined,\n\t\t\t\t\t\tisInlineEdit: c.isInlineEdit,\n\t\t\t\t\t\tshowInlineEditMenu: c.showInlineEditMenu,\n\t\t\t\t\t\tproviderId: c.source.provider.providerId?.toString(),\n\t\t\t\t\t}));\n\t\t\t\t\tthis._log({ sourceId: 'InlineCompletions.fetch', kind: 'end', requestId, durationMs: (Date.now() - startTime.getTime()), error, result, time: Date.now(), didAllProvidersReturn });\n\t\t\t\t}\n\n\t\t\t\trequestResponseInfo.setRequestUuid(providerResult.contextWithUuid.requestUuid);\n\t\t\t\tif (producedSuggestion) {\n\t\t\t\t\trequestResponseInfo.setHasProducedSuggestion();\n\t\t\t\t\tif (suggestions.length > 0 && source.token.isCancellationRequested) {\n\t\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet('canceled:whileAwaitingOtherProviders'));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (source.token.isCancellationRequested) {\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:whileFetching');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst completionsQuotaExceeded = this._contextKeyService.getContextKeyValue<boolean>('completionsQuotaExceeded');\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet(completionsQuotaExceeded ? 'completionsQuotaExceeded' : 'noSuggestion');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst remainingTimeToWait = context.earliestShownDateTime - Date.now();\n\t\t\t\tif (remainingTimeToWait > 0) {\n\t\t\t\t\tawait wait(remainingTimeToWait, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId\n\t\t\t\t\t|| userJumpedToActiveCompletion.get() /* In the meantime the user showed interest for the active completion so dont hide it */) {\n\t\t\t\t\tconst notShownReason =\n\t\t\t\t\t\tsource.token.isCancellationRequested ? 'canceled:afterMinShowDelay' :\n\t\t\t\t\t\t\tthis._store.isDisposed ? 'canceled:disposed' :\n\t\t\t\t\t\t\t\tthis._textModel.getVersionId() !== request.versionId ? 'canceled:documentChanged' :\n\t\t\t\t\t\t\t\t\tuserJumpedToActiveCompletion.get() ? 'canceled:userJumped' :\n\t\t\t\t\t\t\t\t\t\t'unknown';\n\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet(notShownReason));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst endTime = new Date();\n\t\t\t\tthis._debounceValue.update(this._textModel, endTime.getTime() - startTime.getTime());\n\n\t\t\t\tconst cursorPosition = this._cursorPosition.get();\n\t\t\t\tthis._updateOperation.clear();\n\t\t\t\ttransaction(tx => {\n\t\t\t\t\t/** @description Update completions with provider result */\n\t\t\t\t\tconst v = this._state.get();\n\n\t\t\t\t\tif (context.selectedSuggestionInfo) {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: v.suggestWidgetInlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: v.inlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t}\n\n\t\t\t\t\tv.inlineCompletions.dispose();\n\t\t\t\t\tv.suggestWidgetInlineCompletions.dispose();\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tstore.dispose();\n\t\t\t\tdecreaseLoadingCount();\n\t\t\t\tthis.sendInlineCompletionsRequestTelemetry(requestResponseInfo);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tconst updateOperation = new UpdateOperation(request, source, promise);\n\t\tthis._updateOperation.value = updateOperation;\n\n\t\treturn promise;\n\t}\n\n\tpublic clear(tx: ITransaction): void {\n\t\tthis._updateOperation.clear();\n\t\tconst v = this._state.get();\n\t\tthis._state.set({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty()\n\t\t}, tx);\n\t\tv.inlineCompletions.dispose();\n\t\tv.suggestWidgetInlineCompletions.dispose();\n\t}\n\n\tpublic seedInlineCompletionsWithSuggestWidget(): void {\n\t\tconst inlineCompletions = this.inlineCompletions.get();\n\t\tconst suggestWidgetInlineCompletions = this.suggestWidgetInlineCompletions.get();\n\t\tif (!suggestWidgetInlineCompletions) {\n\t\t\treturn;\n\t\t}\n\t\ttransaction(tx => {\n\t\t\t/** @description Seed inline completions with (newer) suggest widget inline completions */\n\t\t\tif (!inlineCompletions || (suggestWidgetInlineCompletions.request?.versionId ?? -1) > (inlineCompletions.request?.versionId ?? -1)) {\n\t\t\t\tinlineCompletions?.dispose();\n\t\t\t\tconst s = this._state.get();\n\t\t\t\tthis._state.set({\n\t\t\t\t\tinlineCompletions: suggestWidgetInlineCompletions.clone(),\n\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t}, tx);\n\t\t\t\ts.inlineCompletions.dispose();\n\t\t\t\ts.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t\tthis.clearSuggestWidgetInlineCompletions(tx);\n\t\t});\n\t}\n\n\tprivate sendInlineCompletionsRequestTelemetry(\n\t\trequestResponseInfo: RequestResponseData\n\t): void {\n\t\tif (!this._sendRequestData.get() && !this._contextKeyService.getContextKeyValue<boolean>('isRunningUnificationExperiment')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (requestResponseInfo.requestUuid === undefined || requestResponseInfo.hasProducedSuggestion) {\n\t\t\treturn;\n\t\t}\n\n\n\t\tif (!isCompletionsEnabled(this._completionsEnabled, this._textModel.getLanguageId())) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst emptyEndOfLifeEvent: InlineCompletionEndOfLifeEvent = {\n\t\t\topportunityId: requestResponseInfo.requestUuid,\n\t\t\tnoSuggestionReason: requestResponseInfo.noSuggestionReason ?? 'unknown',\n\t\t\textensionId: 'vscode-core',\n\t\t\textensionVersion: '0.0.0',\n\t\t\tgroupId: 'empty',\n\t\t\tshown: false,\n\t\t\teditorType: requestResponseInfo.requestInfo.editorType,\n\t\t\trequestReason: requestResponseInfo.requestInfo.reason,\n\t\t\ttypingInterval: requestResponseInfo.requestInfo.typingInterval,\n\t\t\ttypingIntervalCharacterCount: requestResponseInfo.requestInfo.typingIntervalCharacterCount,\n\t\t\tlanguageId: requestResponseInfo.requestInfo.languageId,\n\t\t\tselectedSuggestionInfo: !!requestResponseInfo.context.selectedSuggestionInfo,\n\t\t\tavailableProviders: requestResponseInfo.providers.map(p => p.providerId?.toString()).filter(isDefined).join(','),\n\t\t\t...forwardToChannelIf(requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))),\n\t\t\ttimeUntilProviderRequest: undefined,\n\t\t\ttimeUntilProviderResponse: undefined,\n\t\t\tviewKind: undefined,\n\t\t\tpreceeded: undefined,\n\t\t\terror: undefined,\n\t\t\tsuperseded: undefined,\n\t\t\treason: undefined,\n\t\t\tcorrelationId: undefined,\n\t\t\tshownDuration: undefined,\n\t\t\tshownDurationUncollapsed: undefined,\n\t\t\ttimeUntilShown: undefined,\n\t\t\tpartiallyAccepted: undefined,\n\t\t\tpartiallyAcceptedCountSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedRatioSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedCharactersSinceOriginal: undefined,\n\t\t\tcursorColumnDistance: undefined,\n\t\t\tcursorLineDistance: undefined,\n\t\t\tlineCountOriginal: undefined,\n\t\t\tlineCountModified: undefined,\n\t\t\tcharacterCountOriginal: undefined,\n\t\t\tcharacterCountModified: undefined,\n\t\t\tdisjointReplacements: undefined,\n\t\t\tsameShapeReplacements: undefined,\n\t\t\tnotShownReason: undefined,\n\t\t};\n\n\t\tconst dataChannel = this._instantiationService.createInstance(DataChannelForwardingTelemetryService);\n\t\tsendInlineCompletionsEndOfLifeTelemetry(dataChannel, emptyEndOfLifeEvent);\n\t}\n\n\tpublic clearSuggestWidgetInlineCompletions(tx: ITransaction): void {\n\t\tif (this._updateOperation.value?.request.context.selectedSuggestionInfo) {\n\t\t\tthis._updateOperation.clear();\n\t\t}\n\t}\n\n\tpublic cancelUpdate(): void {\n\t\tthis._updateOperation.clear();\n\t}\n}\n\nclass UpdateRequest {\n\tconstructor(\n\t\tpublic readonly position: Position,\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly providers: Set<InlineCompletionsProvider>,\n\t) {\n\t}\n\n\tpublic satisfies(other: UpdateRequest): boolean {\n\t\treturn this.position.equals(other.position)\n\t\t\t&& equalsIfDefined(this.context.selectedSuggestionInfo, other.context.selectedSuggestionInfo, itemEquals())\n\t\t\t&& (other.context.triggerKind === InlineCompletionTriggerKind.Automatic\n\t\t\t\t|| this.context.triggerKind === InlineCompletionTriggerKind.Explicit)\n\t\t\t&& this.versionId === other.versionId\n\t\t\t&& isSubset(other.providers, this.providers);\n\t}\n}\n\nclass RequestResponseData {\n\tpublic requestUuid: string | undefined;\n\tpublic noSuggestionReason: string | undefined;\n\tpublic hasProducedSuggestion = false;\n\n\tconstructor(\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly requestInfo: InlineSuggestRequestInfo,\n\t\tpublic readonly providers: InlineCompletionsProvider[],\n\t) { }\n\n\tsetRequestUuid(uuid: string) {\n\t\tthis.requestUuid = uuid;\n\t}\n\n\tsetNoSuggestionReasonIfNotSet(type: string) {\n\t\tthis.noSuggestionReason ??= type;\n\t}\n\n\tsetHasProducedSuggestion() {\n\t\tthis.hasProducedSuggestion = true;\n\t}\n}\n\nfunction isSubset<T>(set1: Set<T>, set2: Set<T>): boolean {\n\treturn [...set1].every(item => set2.has(item));\n}\n\nfunction isCompletionsEnabled(completionsEnablementObject: Record<string, boolean> | undefined, modeId: string = '*'): boolean {\n\tif (completionsEnablementObject === undefined) {\n\t\treturn false; // default to disabled if setting is not available\n\t}\n\n\tif (typeof completionsEnablementObject[modeId] !== 'undefined') {\n\t\treturn Boolean(completionsEnablementObject[modeId]); // go with setting if explicitly defined\n\t}\n\n\treturn Boolean(completionsEnablementObject['*']); // fallback to global setting otherwise\n}\n\nclass UpdateOperation implements IDisposable {\n\tconstructor(\n\t\tpublic readonly request: UpdateRequest,\n\t\tpublic readonly cancellationTokenSource: CancellationTokenSource,\n\t\tpublic readonly promise: Promise<boolean>,\n\t) {\n\t}\n\n\tdispose() {\n\t\tthis.cancellationTokenSource.cancel();\n\t}\n}\n\nclass InlineCompletionsState extends Disposable {\n\tpublic static createEmpty(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState([], undefined);\n\t}\n\n\tconstructor(\n\t\tpublic readonly inlineCompletions: readonly InlineSuggestionItem[],\n\t\tpublic readonly request: UpdateRequest | undefined,\n\t) {\n\t\tfor (const inlineCompletion of inlineCompletions) {\n\t\t\tinlineCompletion.addRef();\n\t\t}\n\n\t\tsuper();\n\n\t\tthis._register({\n\t\t\tdispose: () => {\n\t\t\t\tfor (const inlineCompletion of this.inlineCompletions) {\n\t\t\t\t\tinlineCompletion.removeRef();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate _findById(id: InlineSuggestionIdentity): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.identity === id);\n\t}\n\n\tprivate _findByHash(hash: string): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.hash === hash);\n\t}\n\n\t/**\n\t * Applies the edit on the state.\n\t*/\n\tpublic createStateWithAppliedEdit(edit: StringEdit, textModel: ITextModel): InlineCompletionsState {\n\t\tconst newInlineCompletions = this.inlineCompletions.map(i => i.withEdit(edit, textModel)).filter(isDefined);\n\t\treturn new InlineCompletionsState(newInlineCompletions, this.request);\n\t}\n\n\tpublic createStateWithAppliedResults(updatedSuggestions: InlineSuggestionItem[], request: UpdateRequest, textModel: ITextModel, cursorPosition: Position, itemIdToPreserveAtTop: InlineSuggestionIdentity | undefined): InlineCompletionsState {\n\t\tlet itemToPreserve: InlineSuggestionItem | undefined = undefined;\n\t\tif (itemIdToPreserveAtTop) {\n\t\t\tconst itemToPreserveCandidate = this._findById(itemIdToPreserveAtTop);\n\t\t\tif (itemToPreserveCandidate && itemToPreserveCandidate.canBeReused(textModel, request.position)) {\n\t\t\t\titemToPreserve = itemToPreserveCandidate;\n\n\t\t\t\tconst updatedItemToPreserve = updatedSuggestions.find(i => i.hash === itemToPreserveCandidate.hash);\n\t\t\t\tif (updatedItemToPreserve) {\n\t\t\t\t\tupdatedSuggestions = moveToFront(updatedItemToPreserve, updatedSuggestions);\n\t\t\t\t} else {\n\t\t\t\t\tupdatedSuggestions = [itemToPreserveCandidate, ...updatedSuggestions];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst preferInlineCompletions = itemToPreserve\n\t\t\t// itemToPreserve has precedence\n\t\t\t? !itemToPreserve.isInlineEdit\n\t\t\t// Otherwise: prefer inline completion if there is a visible one\n\t\t\t: updatedSuggestions.some(i => !i.isInlineEdit && i.isVisible(textModel, cursorPosition));\n\n\t\tlet updatedItems: InlineSuggestionItem[] = [];\n\t\tfor (const i of updatedSuggestions) {\n\t\t\tconst oldItem = this._findByHash(i.hash);\n\t\t\tlet item;\n\t\t\tif (oldItem && oldItem !== i) {\n\t\t\t\titem = i.withIdentity(oldItem.identity);\n\t\t\t\ti.setIsPreceeded(oldItem);\n\t\t\t\toldItem.setEndOfLifeReason({ kind: InlineCompletionEndOfLifeReasonKind.Ignored, userTypingDisagreed: false, supersededBy: i.getSourceCompletion() });\n\t\t\t} else {\n\t\t\t\titem = i;\n\t\t\t}\n\t\t\tif (preferInlineCompletions !== item.isInlineEdit) {\n\t\t\t\tupdatedItems.push(item);\n\t\t\t}\n\t\t}\n\n\t\tupdatedItems.sort(compareBy(i => i.showInlineEditMenu, booleanComparator));\n\t\tupdatedItems = distinctByKey(updatedItems, i => i.semanticId);\n\n\t\treturn new InlineCompletionsState(updatedItems, request);\n\t}\n\n\tpublic clone(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState(this.inlineCompletions, this.request);\n\t}\n}\n\n/** Keeps the first item in case of duplicates. */\nfunction distinctByKey<T>(items: T[], key: (item: T) => unknown): T[] {\n\tconst seen = new Set();\n\treturn items.filter(item => {\n\t\tconst k = key(item);\n\t\tif (seen.has(k)) {\n\t\t\treturn false;\n\t\t}\n\t\tseen.add(k);\n\t\treturn true;\n\t});\n}\n\nfunction moveToFront<T>(item: T, items: T[]): T[] {\n\tconst index = items.indexOf(item);\n\tif (index > -1) {\n\t\treturn [item, ...items.slice(0, index), ...items.slice(index + 1)];\n\t}\n\treturn items;\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts","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O,IAAI,sBAAsB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;CACD;AAED,kDAAkD;AAClD,SAAS,aAAa,CAAI,KAAU,EAAE,GAAyB;IAC9D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAI,IAAO,EAAE,KAAU;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","file":"inlineCompletionsSource.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { booleanComparator, compareBy, compareUndefinedSmallest, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findLastMax } from '../../../../../base/common/arraysFind.js';\nimport { RunOnceScheduler } from '../../../../../base/common/async.js';\nimport { CancellationTokenSource } from '../../../../../base/common/cancellation.js';\nimport { equalsIfDefined, itemEquals } from '../../../../../base/common/equals.js';\nimport { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';\nimport { derived, IObservable, IObservableWithChange, ITransaction, observableValue, recordChangesLazy, transaction } from '../../../../../base/common/observable.js';\n// eslint-disable-next-line local/code-no-deep-import-of-internal\nimport { observableReducerSettable } from '../../../../../base/common/observableInternal/experimental/reducer.js';\nimport { isDefined, isObject } from '../../../../../base/common/types.js';\nimport { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';\nimport { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';\nimport { DataChannelForwardingTelemetryService, forwardToChannelIf, isCopilotLikeExtension } from '../../../../../platform/dataChannel/browser/forwardingTelemetryService.js';\nimport { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';\nimport { ILogService } from '../../../../../platform/log/common/log.js';\nimport { observableConfigValue } from '../../../../../platform/observable/common/platformObservableUtils.js';\nimport product from '../../../../../platform/product/common/product.js';\nimport { StringEdit } from '../../../../common/core/edits/stringEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { InlineCompletionEndOfLifeReasonKind, InlineCompletionTriggerKind, InlineCompletionsProvider } from '../../../../common/languages.js';\nimport { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { offsetEditFromContentChanges } from '../../../../common/model/textModelStringEdit.js';\nimport { IFeatureDebounceInformation } from '../../../../common/services/languageFeatureDebounce.js';\nimport { IModelContentChangedEvent } from '../../../../common/textModelEvents.js';\nimport { formatRecordableLogEntry, IRecordableEditorLogEntry, IRecordableLogEntry, StructuredLogger } from '../structuredLogger.js';\nimport { InlineCompletionEndOfLifeEvent, sendInlineCompletionsEndOfLifeTelemetry } from '../telemetry.js';\nimport { wait } from '../utils.js';\nimport { InlineSuggestionIdentity, InlineSuggestionItem } from './inlineSuggestionItem.js';\nimport { InlineCompletionContextWithoutUuid, InlineSuggestRequestInfo, provideInlineCompletions, runWhenCancelled } from './provideInlineCompletions.js';\n\nexport class InlineCompletionsSource extends Disposable {\n\tprivate static _requestId = 0;\n\n\tprivate readonly _updateOperation = this._register(new MutableDisposable<UpdateOperation>());\n\n\tprivate readonly _loggingEnabled;\n\tprivate readonly _sendRequestData;\n\n\tprivate readonly _structuredFetchLogger;\n\n\tprivate readonly _state = observableReducerSettable(this, {\n\t\tinitial: () => ({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t}),\n\t\tdisposeFinal: (values) => {\n\t\t\tvalues.inlineCompletions.dispose();\n\t\t\tvalues.suggestWidgetInlineCompletions.dispose();\n\t\t},\n\t\tchangeTracker: recordChangesLazy(() => ({ versionId: this._versionId })),\n\t\tupdate: (reader, previousValue, changes) => {\n\t\t\tconst edit = StringEdit.compose(changes.changes.map(c => c.change ? offsetEditFromContentChanges(c.change.changes) : StringEdit.empty).filter(isDefined));\n\n\t\t\tif (edit.isEmpty()) {\n\t\t\t\treturn previousValue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tinlineCompletions: previousValue.inlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t\tsuggestWidgetInlineCompletions: previousValue.suggestWidgetInlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tpreviousValue.inlineCompletions.dispose();\n\t\t\t\tpreviousValue.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t}\n\t});\n\n\tpublic readonly inlineCompletions = this._state.map(this, v => v.inlineCompletions);\n\tpublic readonly suggestWidgetInlineCompletions = this._state.map(this, v => v.suggestWidgetInlineCompletions);\n\n\tprivate _completionsEnabled: Record<string, boolean> | undefined = undefined;\n\n\tconstructor(\n\t\tprivate readonly _textModel: ITextModel,\n\t\tprivate readonly _versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined>,\n\t\tprivate readonly _debounceValue: IFeatureDebounceInformation,\n\t\tprivate readonly _cursorPosition: IObservable<Position>,\n\t\t@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,\n\t\t@ILogService private readonly _logService: ILogService,\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService,\n\t\t@IContextKeyService private readonly _contextKeyService: IContextKeyService,\n\t) {\n\t\tsuper();\n\t\tthis._loggingEnabled = observableConfigValue('editor.inlineSuggest.logFetch', false, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._sendRequestData = observableConfigValue('editor.inlineSuggest.emptyResponseInformation', true, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._structuredFetchLogger = this._register(this._instantiationService.createInstance(StructuredLogger.cast<\n\t\t\t{ kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry\n\t\t\t| { kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry\n\t\t>(),\n\t\t\t'editor.inlineSuggest.logFetch.commandId'\n\t\t));\n\n\t\tthis.clearOperationOnTextModelChange.recomputeInitiallyAndOnChange(this._store);\n\n\t\tconst enablementSetting = product.defaultChatAgent?.completionsEnablementSetting ?? undefined;\n\t\tif (enablementSetting) {\n\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => {\n\t\t\t\tif (e.affectsConfiguration(enablementSetting)) {\n\t\t\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\n\t\tthis._state.recomputeInitiallyAndOnChange(this._store);\n\t}\n\n\tprivate _updateCompletionsEnablement(enalementSetting: string) {\n\t\tconst result = this._configurationService.getValue<Record<string, boolean>>(enalementSetting);\n\t\tif (!isObject(result)) {\n\t\t\tthis._completionsEnabled = undefined;\n\t\t} else {\n\t\t\tthis._completionsEnabled = result;\n\t\t}\n\t}\n\n\tpublic readonly clearOperationOnTextModelChange = derived(this, reader => {\n\t\tthis._versionId.read(reader);\n\t\tthis._updateOperation.clear();\n\t\treturn undefined; // always constant\n\t});\n\n\tprivate _log(entry:\n\t\t{ sourceId: string; kind: 'start'; requestId: number; context: unknown; provider: string | undefined } & IRecordableEditorLogEntry\n\t\t| { sourceId: string; kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number; didAllProvidersReturn: boolean } & IRecordableLogEntry\n\t) {\n\t\tif (this._loggingEnabled.get()) {\n\t\t\tthis._logService.info(formatRecordableLogEntry(entry));\n\t\t}\n\t\tthis._structuredFetchLogger.log(entry);\n\t}\n\n\tprivate readonly _loadingCount = observableValue(this, 0);\n\n\tpublic fetch(\n\t\tproviders: InlineCompletionsProvider[],\n\t\tprovidersLabel: string | undefined,\n\t\tcontext: InlineCompletionContextWithoutUuid,\n\t\tactiveInlineCompletion: InlineSuggestionIdentity | undefined,\n\t\twithDebounce: boolean,\n\t\tuserJumpedToActiveCompletion: IObservable<boolean>,\n\t\trequestInfo: InlineSuggestRequestInfo\n\t): Promise<boolean> {\n\t\tconst position = this._cursorPosition.get();\n\t\tconst request = new UpdateRequest(position, context, this._textModel.getVersionId(), new Set(providers));\n\n\t\tconst target = context.selectedSuggestionInfo ? this.suggestWidgetInlineCompletions.get() : this.inlineCompletions.get();\n\n\t\tif (this._updateOperation.value?.request.satisfies(request)) {\n\t\t\treturn this._updateOperation.value.promise;\n\t\t} else if (target?.request?.satisfies(request)) {\n\t\t\treturn Promise.resolve(true);\n\t\t}\n\n\t\tconst updateOngoing = !!this._updateOperation.value;\n\t\tthis._updateOperation.clear();\n\n\t\tconst source = new CancellationTokenSource();\n\n\t\tconst promise = (async () => {\n\t\t\tconst store = new DisposableStore();\n\n\t\t\tthis._loadingCount.set(this._loadingCount.get() + 1, undefined);\n\t\t\tlet didDecrease = false;\n\t\t\tconst decreaseLoadingCount = () => {\n\t\t\t\tif (!didDecrease) {\n\t\t\t\t\tdidDecrease = true;\n\t\t\t\t\tthis._loadingCount.set(this._loadingCount.get() - 1, undefined);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst loadingReset = store.add(new RunOnceScheduler(() => decreaseLoadingCount(), 10 * 1000));\n\t\t\tloadingReset.schedule();\n\n\t\t\tconst inlineSuggestionsProviders = providers.filter(p => p.providerId);\n\t\t\tconst requestResponseInfo = new RequestResponseData(context, requestInfo, inlineSuggestionsProviders);\n\n\n\t\t\ttry {\n\t\t\t\tconst recommendedDebounceValue = this._debounceValue.get(this._textModel);\n\t\t\t\tconst debounceValue = findLastMax(\n\t\t\t\t\tproviders.map(p => p.debounceDelayMs),\n\t\t\t\t\tcompareUndefinedSmallest(numberComparator)\n\t\t\t\t) ?? recommendedDebounceValue;\n\n\t\t\t\t// Debounce in any case if update is ongoing\n\t\t\t\tconst shouldDebounce = updateOngoing || (withDebounce && context.triggerKind === InlineCompletionTriggerKind.Automatic);\n\t\t\t\tif (shouldDebounce) {\n\t\t\t\t\t// This debounces the operation\n\t\t\t\t\tawait wait(debounceValue, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:beforeFetch');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst requestId = InlineCompletionsSource._requestId++;\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tthis._log({\n\t\t\t\t\t\tsourceId: 'InlineCompletions.fetch',\n\t\t\t\t\t\tkind: 'start',\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\tmodelUri: this._textModel.uri,\n\t\t\t\t\t\tmodelVersion: this._textModel.getVersionId(),\n\t\t\t\t\t\tcontext: { triggerKind: context.triggerKind, suggestInfo: context.selectedSuggestionInfo ? true : undefined },\n\t\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\t\tprovider: providersLabel,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst startTime = new Date();\n\t\t\t\tconst providerResult = provideInlineCompletions(providers, this._cursorPosition.get(), this._textModel, context, requestInfo, this._languageConfigurationService);\n\n\t\t\t\trunWhenCancelled(source.token, () => providerResult.cancelAndDispose({ kind: 'tokenCancellation' }));\n\n\t\t\t\tlet shouldStopEarly = false;\n\t\t\t\tlet producedSuggestion = false;\n\n\t\t\t\tconst suggestions: InlineSuggestionItem[] = [];\n\t\t\t\tfor await (const list of providerResult.lists) {\n\t\t\t\t\tif (!list) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlist.addRef();\n\t\t\t\t\tstore.add(toDisposable(() => list.removeRef(list.inlineSuggestionsData.length === 0 ? { kind: 'empty' } : { kind: 'notTaken' })));\n\n\t\t\t\t\tfor (const item of list.inlineSuggestionsData) {\n\t\t\t\t\t\tproducedSuggestion = true;\n\t\t\t\t\t\tif (!context.includeInlineEdits && (item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineEditRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!context.includeInlineCompletions && !(item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineCompletionRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst i = InlineSuggestionItem.create(item, this._textModel);\n\t\t\t\t\t\tsuggestions.push(i);\n\t\t\t\t\t\t// Stop after first visible inline completion\n\t\t\t\t\t\tif (!i.isInlineEdit && !i.showInlineEditMenu && context.triggerKind === InlineCompletionTriggerKind.Automatic) {\n\t\t\t\t\t\t\tif (i.isVisible(this._textModel, this._cursorPosition.get())) {\n\t\t\t\t\t\t\t\tshouldStopEarly = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldStopEarly) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tproviderResult.cancelAndDispose({ kind: 'lostRace' });\n\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tconst didAllProvidersReturn = providerResult.didAllProvidersReturn;\n\t\t\t\t\tlet error: string | undefined = undefined;\n\t\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\t\terror = 'canceled';\n\t\t\t\t\t}\n\t\t\t\t\tconst result = suggestions.map(c => ({\n\t\t\t\t\t\trange: c.editRange.toString(),\n\t\t\t\t\t\ttext: c.insertText,\n\t\t\t\t\t\thint: c.hint,\n\t\t\t\t\t\tisInlineEdit: c.isInlineEdit,\n\t\t\t\t\t\tshowInlineEditMenu: c.showInlineEditMenu,\n\t\t\t\t\t\tproviderId: c.source.provider.providerId?.toString(),\n\t\t\t\t\t}));\n\t\t\t\t\tthis._log({ sourceId: 'InlineCompletions.fetch', kind: 'end', requestId, durationMs: (Date.now() - startTime.getTime()), error, result, time: Date.now(), didAllProvidersReturn });\n\t\t\t\t}\n\n\t\t\t\trequestResponseInfo.setRequestUuid(providerResult.contextWithUuid.requestUuid);\n\t\t\t\tif (producedSuggestion) {\n\t\t\t\t\trequestResponseInfo.setHasProducedSuggestion();\n\t\t\t\t\tif (suggestions.length > 0 && source.token.isCancellationRequested) {\n\t\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet('canceled:whileAwaitingOtherProviders'));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (source.token.isCancellationRequested) {\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:whileFetching');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst completionsQuotaExceeded = this._contextKeyService.getContextKeyValue<boolean>('completionsQuotaExceeded');\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet(completionsQuotaExceeded ? 'completionsQuotaExceeded' : 'noSuggestion');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst remainingTimeToWait = context.earliestShownDateTime - Date.now();\n\t\t\t\tif (remainingTimeToWait > 0) {\n\t\t\t\t\tawait wait(remainingTimeToWait, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId\n\t\t\t\t\t|| userJumpedToActiveCompletion.get() /* In the meantime the user showed interest for the active completion so dont hide it */) {\n\t\t\t\t\tconst notShownReason =\n\t\t\t\t\t\tsource.token.isCancellationRequested ? 'canceled:afterMinShowDelay' :\n\t\t\t\t\t\t\tthis._store.isDisposed ? 'canceled:disposed' :\n\t\t\t\t\t\t\t\tthis._textModel.getVersionId() !== request.versionId ? 'canceled:documentChanged' :\n\t\t\t\t\t\t\t\t\tuserJumpedToActiveCompletion.get() ? 'canceled:userJumped' :\n\t\t\t\t\t\t\t\t\t\t'unknown';\n\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet(notShownReason));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst endTime = new Date();\n\t\t\t\tthis._debounceValue.update(this._textModel, endTime.getTime() - startTime.getTime());\n\n\t\t\t\tconst cursorPosition = this._cursorPosition.get();\n\t\t\t\tthis._updateOperation.clear();\n\t\t\t\ttransaction(tx => {\n\t\t\t\t\t/** @description Update completions with provider result */\n\t\t\t\t\tconst v = this._state.get();\n\n\t\t\t\t\tif (context.selectedSuggestionInfo) {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: v.suggestWidgetInlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: v.inlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t}\n\n\t\t\t\t\tv.inlineCompletions.dispose();\n\t\t\t\t\tv.suggestWidgetInlineCompletions.dispose();\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tstore.dispose();\n\t\t\t\tdecreaseLoadingCount();\n\t\t\t\tthis.sendInlineCompletionsRequestTelemetry(requestResponseInfo);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tconst updateOperation = new UpdateOperation(request, source, promise);\n\t\tthis._updateOperation.value = updateOperation;\n\n\t\treturn promise;\n\t}\n\n\tpublic clear(tx: ITransaction): void {\n\t\tthis._updateOperation.clear();\n\t\tconst v = this._state.get();\n\t\tthis._state.set({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty()\n\t\t}, tx);\n\t\tv.inlineCompletions.dispose();\n\t\tv.suggestWidgetInlineCompletions.dispose();\n\t}\n\n\tpublic seedInlineCompletionsWithSuggestWidget(): void {\n\t\tconst inlineCompletions = this.inlineCompletions.get();\n\t\tconst suggestWidgetInlineCompletions = this.suggestWidgetInlineCompletions.get();\n\t\tif (!suggestWidgetInlineCompletions) {\n\t\t\treturn;\n\t\t}\n\t\ttransaction(tx => {\n\t\t\t/** @description Seed inline completions with (newer) suggest widget inline completions */\n\t\t\tif (!inlineCompletions || (suggestWidgetInlineCompletions.request?.versionId ?? -1) > (inlineCompletions.request?.versionId ?? -1)) {\n\t\t\t\tinlineCompletions?.dispose();\n\t\t\t\tconst s = this._state.get();\n\t\t\t\tthis._state.set({\n\t\t\t\t\tinlineCompletions: suggestWidgetInlineCompletions.clone(),\n\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t}, tx);\n\t\t\t\ts.inlineCompletions.dispose();\n\t\t\t\ts.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t\tthis.clearSuggestWidgetInlineCompletions(tx);\n\t\t});\n\t}\n\n\tprivate sendInlineCompletionsRequestTelemetry(\n\t\trequestResponseInfo: RequestResponseData\n\t): void {\n\t\tif (!this._sendRequestData.get() && !this._contextKeyService.getContextKeyValue<boolean>('isRunningUnificationExperiment')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (requestResponseInfo.requestUuid === undefined || requestResponseInfo.hasProducedSuggestion) {\n\t\t\treturn;\n\t\t}\n\n\n\t\tif (!isCompletionsEnabled(this._completionsEnabled, this._textModel.getLanguageId())) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst emptyEndOfLifeEvent: InlineCompletionEndOfLifeEvent = {\n\t\t\topportunityId: requestResponseInfo.requestUuid,\n\t\t\tnoSuggestionReason: requestResponseInfo.noSuggestionReason ?? 'unknown',\n\t\t\textensionId: 'vscode-core',\n\t\t\textensionVersion: '0.0.0',\n\t\t\tgroupId: 'empty',\n\t\t\tshown: false,\n\t\t\teditorType: requestResponseInfo.requestInfo.editorType,\n\t\t\trequestReason: requestResponseInfo.requestInfo.reason,\n\t\t\ttypingInterval: requestResponseInfo.requestInfo.typingInterval,\n\t\t\ttypingIntervalCharacterCount: requestResponseInfo.requestInfo.typingIntervalCharacterCount,\n\t\t\tlanguageId: requestResponseInfo.requestInfo.languageId,\n\t\t\tselectedSuggestionInfo: !!requestResponseInfo.context.selectedSuggestionInfo,\n\t\t\tavailableProviders: requestResponseInfo.providers.map(p => p.providerId?.toString()).filter(isDefined).join(','),\n\t\t\t...forwardToChannelIf(requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))),\n\t\t\ttimeUntilProviderRequest: undefined,\n\t\t\ttimeUntilProviderResponse: undefined,\n\t\t\tviewKind: undefined,\n\t\t\tpreceeded: undefined,\n\t\t\tsuperseded: undefined,\n\t\t\treason: undefined,\n\t\t\tcorrelationId: undefined,\n\t\t\tshownDuration: undefined,\n\t\t\tshownDurationUncollapsed: undefined,\n\t\t\ttimeUntilShown: undefined,\n\t\t\tpartiallyAccepted: undefined,\n\t\t\tpartiallyAcceptedCountSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedRatioSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedCharactersSinceOriginal: undefined,\n\t\t\tcursorColumnDistance: undefined,\n\t\t\tcursorLineDistance: undefined,\n\t\t\tlineCountOriginal: undefined,\n\t\t\tlineCountModified: undefined,\n\t\t\tcharacterCountOriginal: undefined,\n\t\t\tcharacterCountModified: undefined,\n\t\t\tdisjointReplacements: undefined,\n\t\t\tsameShapeReplacements: undefined,\n\t\t\tnotShownReason: undefined,\n\t\t};\n\n\t\tconst dataChannel = this._instantiationService.createInstance(DataChannelForwardingTelemetryService);\n\t\tsendInlineCompletionsEndOfLifeTelemetry(dataChannel, emptyEndOfLifeEvent);\n\t}\n\n\tpublic clearSuggestWidgetInlineCompletions(tx: ITransaction): void {\n\t\tif (this._updateOperation.value?.request.context.selectedSuggestionInfo) {\n\t\t\tthis._updateOperation.clear();\n\t\t}\n\t}\n\n\tpublic cancelUpdate(): void {\n\t\tthis._updateOperation.clear();\n\t}\n}\n\nclass UpdateRequest {\n\tconstructor(\n\t\tpublic readonly position: Position,\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly providers: Set<InlineCompletionsProvider>,\n\t) {\n\t}\n\n\tpublic satisfies(other: UpdateRequest): boolean {\n\t\treturn this.position.equals(other.position)\n\t\t\t&& equalsIfDefined(this.context.selectedSuggestionInfo, other.context.selectedSuggestionInfo, itemEquals())\n\t\t\t&& (other.context.triggerKind === InlineCompletionTriggerKind.Automatic\n\t\t\t\t|| this.context.triggerKind === InlineCompletionTriggerKind.Explicit)\n\t\t\t&& this.versionId === other.versionId\n\t\t\t&& isSubset(other.providers, this.providers);\n\t}\n}\n\nclass RequestResponseData {\n\tpublic requestUuid: string | undefined;\n\tpublic noSuggestionReason: string | undefined;\n\tpublic hasProducedSuggestion = false;\n\n\tconstructor(\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly requestInfo: InlineSuggestRequestInfo,\n\t\tpublic readonly providers: InlineCompletionsProvider[],\n\t) { }\n\n\tsetRequestUuid(uuid: string) {\n\t\tthis.requestUuid = uuid;\n\t}\n\n\tsetNoSuggestionReasonIfNotSet(type: string) {\n\t\tthis.noSuggestionReason ??= type;\n\t}\n\n\tsetHasProducedSuggestion() {\n\t\tthis.hasProducedSuggestion = true;\n\t}\n}\n\nfunction isSubset<T>(set1: Set<T>, set2: Set<T>): boolean {\n\treturn [...set1].every(item => set2.has(item));\n}\n\nfunction isCompletionsEnabled(completionsEnablementObject: Record<string, boolean> | undefined, modeId: string = '*'): boolean {\n\tif (completionsEnablementObject === undefined) {\n\t\treturn false; // default to disabled if setting is not available\n\t}\n\n\tif (typeof completionsEnablementObject[modeId] !== 'undefined') {\n\t\treturn Boolean(completionsEnablementObject[modeId]); // go with setting if explicitly defined\n\t}\n\n\treturn Boolean(completionsEnablementObject['*']); // fallback to global setting otherwise\n}\n\nclass UpdateOperation implements IDisposable {\n\tconstructor(\n\t\tpublic readonly request: UpdateRequest,\n\t\tpublic readonly cancellationTokenSource: CancellationTokenSource,\n\t\tpublic readonly promise: Promise<boolean>,\n\t) {\n\t}\n\n\tdispose() {\n\t\tthis.cancellationTokenSource.cancel();\n\t}\n}\n\nclass InlineCompletionsState extends Disposable {\n\tpublic static createEmpty(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState([], undefined);\n\t}\n\n\tconstructor(\n\t\tpublic readonly inlineCompletions: readonly InlineSuggestionItem[],\n\t\tpublic readonly request: UpdateRequest | undefined,\n\t) {\n\t\tfor (const inlineCompletion of inlineCompletions) {\n\t\t\tinlineCompletion.addRef();\n\t\t}\n\n\t\tsuper();\n\n\t\tthis._register({\n\t\t\tdispose: () => {\n\t\t\t\tfor (const inlineCompletion of this.inlineCompletions) {\n\t\t\t\t\tinlineCompletion.removeRef();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate _findById(id: InlineSuggestionIdentity): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.identity === id);\n\t}\n\n\tprivate _findByHash(hash: string): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.hash === hash);\n\t}\n\n\t/**\n\t * Applies the edit on the state.\n\t*/\n\tpublic createStateWithAppliedEdit(edit: StringEdit, textModel: ITextModel): InlineCompletionsState {\n\t\tconst newInlineCompletions = this.inlineCompletions.map(i => i.withEdit(edit, textModel)).filter(isDefined);\n\t\treturn new InlineCompletionsState(newInlineCompletions, this.request);\n\t}\n\n\tpublic createStateWithAppliedResults(updatedSuggestions: InlineSuggestionItem[], request: UpdateRequest, textModel: ITextModel, cursorPosition: Position, itemIdToPreserveAtTop: InlineSuggestionIdentity | undefined): InlineCompletionsState {\n\t\tlet itemToPreserve: InlineSuggestionItem | undefined = undefined;\n\t\tif (itemIdToPreserveAtTop) {\n\t\t\tconst itemToPreserveCandidate = this._findById(itemIdToPreserveAtTop);\n\t\t\tif (itemToPreserveCandidate && itemToPreserveCandidate.canBeReused(textModel, request.position)) {\n\t\t\t\titemToPreserve = itemToPreserveCandidate;\n\n\t\t\t\tconst updatedItemToPreserve = updatedSuggestions.find(i => i.hash === itemToPreserveCandidate.hash);\n\t\t\t\tif (updatedItemToPreserve) {\n\t\t\t\t\tupdatedSuggestions = moveToFront(updatedItemToPreserve, updatedSuggestions);\n\t\t\t\t} else {\n\t\t\t\t\tupdatedSuggestions = [itemToPreserveCandidate, ...updatedSuggestions];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst preferInlineCompletions = itemToPreserve\n\t\t\t// itemToPreserve has precedence\n\t\t\t? !itemToPreserve.isInlineEdit\n\t\t\t// Otherwise: prefer inline completion if there is a visible one\n\t\t\t: updatedSuggestions.some(i => !i.isInlineEdit && i.isVisible(textModel, cursorPosition));\n\n\t\tlet updatedItems: InlineSuggestionItem[] = [];\n\t\tfor (const i of updatedSuggestions) {\n\t\t\tconst oldItem = this._findByHash(i.hash);\n\t\t\tlet item;\n\t\t\tif (oldItem && oldItem !== i) {\n\t\t\t\titem = i.withIdentity(oldItem.identity);\n\t\t\t\ti.setIsPreceeded(oldItem);\n\t\t\t\toldItem.setEndOfLifeReason({ kind: InlineCompletionEndOfLifeReasonKind.Ignored, userTypingDisagreed: false, supersededBy: i.getSourceCompletion() });\n\t\t\t} else {\n\t\t\t\titem = i;\n\t\t\t}\n\t\t\tif (preferInlineCompletions !== item.isInlineEdit) {\n\t\t\t\tupdatedItems.push(item);\n\t\t\t}\n\t\t}\n\n\t\tupdatedItems.sort(compareBy(i => i.showInlineEditMenu, booleanComparator));\n\t\tupdatedItems = distinctByKey(updatedItems, i => i.semanticId);\n\n\t\treturn new InlineCompletionsState(updatedItems, request);\n\t}\n\n\tpublic clone(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState(this.inlineCompletions, this.request);\n\t}\n}\n\n/** Keeps the first item in case of duplicates. */\nfunction distinctByKey<T>(items: T[], key: (item: T) => unknown): T[] {\n\tconst seen = new Set();\n\treturn items.filter(item => {\n\t\tconst k = key(item);\n\t\tif (seen.has(k)) {\n\t\t\treturn false;\n\t\t}\n\t\tseen.add(k);\n\t\treturn true;\n\t});\n}\n\nfunction moveToFront<T>(item: T, items: T[]): T[] {\n\tconst index = items.indexOf(item);\n\tif (index > -1) {\n\t\treturn [item, ...items.slice(0, index), ...items.slice(index + 1)];\n\t}\n\treturn items;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { booleanComparator, compareBy, compareUndefinedSmallest, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findLastMax } from '../../../../../base/common/arraysFind.js';\nimport { RunOnceScheduler } from '../../../../../base/common/async.js';\nimport { CancellationTokenSource } from '../../../../../base/common/cancellation.js';\nimport { equalsIfDefined, itemEquals } from '../../../../../base/common/equals.js';\nimport { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../../base/common/lifecycle.js';\nimport { derived, IObservable, IObservableWithChange, ITransaction, observableValue, recordChangesLazy, transaction } from '../../../../../base/common/observable.js';\n// eslint-disable-next-line local/code-no-deep-import-of-internal\nimport { observableReducerSettable } from '../../../../../base/common/observableInternal/experimental/reducer.js';\nimport { isDefined, isObject } from '../../../../../base/common/types.js';\nimport { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';\nimport { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';\nimport { DataChannelForwardingTelemetryService, forwardToChannelIf, isCopilotLikeExtension } from '../../../../../platform/dataChannel/browser/forwardingTelemetryService.js';\nimport { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';\nimport { ILogService } from '../../../../../platform/log/common/log.js';\nimport { observableConfigValue } from '../../../../../platform/observable/common/platformObservableUtils.js';\nimport product from '../../../../../platform/product/common/product.js';\nimport { StringEdit } from '../../../../common/core/edits/stringEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { InlineCompletionEndOfLifeReasonKind, InlineCompletionTriggerKind, InlineCompletionsProvider } from '../../../../common/languages.js';\nimport { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { offsetEditFromContentChanges } from '../../../../common/model/textModelStringEdit.js';\nimport { IFeatureDebounceInformation } from '../../../../common/services/languageFeatureDebounce.js';\nimport { IModelContentChangedEvent } from '../../../../common/textModelEvents.js';\nimport { formatRecordableLogEntry, IRecordableEditorLogEntry, IRecordableLogEntry, StructuredLogger } from '../structuredLogger.js';\nimport { InlineCompletionEndOfLifeEvent, sendInlineCompletionsEndOfLifeTelemetry } from '../telemetry.js';\nimport { wait } from '../utils.js';\nimport { InlineSuggestionIdentity, InlineSuggestionItem } from './inlineSuggestionItem.js';\nimport { InlineCompletionContextWithoutUuid, InlineSuggestRequestInfo, provideInlineCompletions, runWhenCancelled } from './provideInlineCompletions.js';\n\nexport class InlineCompletionsSource extends Disposable {\n\tprivate static _requestId = 0;\n\n\tprivate readonly _updateOperation = this._register(new MutableDisposable<UpdateOperation>());\n\n\tprivate readonly _loggingEnabled;\n\tprivate readonly _sendRequestData;\n\n\tprivate readonly _structuredFetchLogger;\n\n\tprivate readonly _state = observableReducerSettable(this, {\n\t\tinitial: () => ({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t}),\n\t\tdisposeFinal: (values) => {\n\t\t\tvalues.inlineCompletions.dispose();\n\t\t\tvalues.suggestWidgetInlineCompletions.dispose();\n\t\t},\n\t\tchangeTracker: recordChangesLazy(() => ({ versionId: this._versionId })),\n\t\tupdate: (reader, previousValue, changes) => {\n\t\t\tconst edit = StringEdit.compose(changes.changes.map(c => c.change ? offsetEditFromContentChanges(c.change.changes) : StringEdit.empty).filter(isDefined));\n\n\t\t\tif (edit.isEmpty()) {\n\t\t\t\treturn previousValue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tinlineCompletions: previousValue.inlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t\tsuggestWidgetInlineCompletions: previousValue.suggestWidgetInlineCompletions.createStateWithAppliedEdit(edit, this._textModel),\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tpreviousValue.inlineCompletions.dispose();\n\t\t\t\tpreviousValue.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t}\n\t});\n\n\tpublic readonly inlineCompletions = this._state.map(this, v => v.inlineCompletions);\n\tpublic readonly suggestWidgetInlineCompletions = this._state.map(this, v => v.suggestWidgetInlineCompletions);\n\n\tprivate _completionsEnabled: Record<string, boolean> | undefined = undefined;\n\n\tconstructor(\n\t\tprivate readonly _textModel: ITextModel,\n\t\tprivate readonly _versionId: IObservableWithChange<number | null, IModelContentChangedEvent | undefined>,\n\t\tprivate readonly _debounceValue: IFeatureDebounceInformation,\n\t\tprivate readonly _cursorPosition: IObservable<Position>,\n\t\t@ILanguageConfigurationService private readonly _languageConfigurationService: ILanguageConfigurationService,\n\t\t@ILogService private readonly _logService: ILogService,\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService,\n\t\t@IContextKeyService private readonly _contextKeyService: IContextKeyService,\n\t) {\n\t\tsuper();\n\t\tthis._loggingEnabled = observableConfigValue('editor.inlineSuggest.logFetch', false, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._sendRequestData = observableConfigValue('editor.inlineSuggest.emptyResponseInformation', true, this._configurationService).recomputeInitiallyAndOnChange(this._store);\n\t\tthis._structuredFetchLogger = this._register(this._instantiationService.createInstance(StructuredLogger.cast<\n\t\t\t{ kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry\n\t\t\t| { kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry\n\t\t>(),\n\t\t\t'editor.inlineSuggest.logFetch.commandId'\n\t\t));\n\n\t\tthis.clearOperationOnTextModelChange.recomputeInitiallyAndOnChange(this._store);\n\n\t\tconst enablementSetting = product.defaultChatAgent?.completionsEnablementSetting ?? undefined;\n\t\tif (enablementSetting) {\n\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => {\n\t\t\t\tif (e.affectsConfiguration(enablementSetting)) {\n\t\t\t\t\tthis._updateCompletionsEnablement(enablementSetting);\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\n\t\tthis._state.recomputeInitiallyAndOnChange(this._store);\n\t}\n\n\tprivate _updateCompletionsEnablement(enalementSetting: string) {\n\t\tconst result = this._configurationService.getValue<Record<string, boolean>>(enalementSetting);\n\t\tif (!isObject(result)) {\n\t\t\tthis._completionsEnabled = undefined;\n\t\t} else {\n\t\t\tthis._completionsEnabled = result;\n\t\t}\n\t}\n\n\tpublic readonly clearOperationOnTextModelChange = derived(this, reader => {\n\t\tthis._versionId.read(reader);\n\t\tthis._updateOperation.clear();\n\t\treturn undefined; // always constant\n\t});\n\n\tprivate _log(entry:\n\t\t{ sourceId: string; kind: 'start'; requestId: number; context: unknown; provider: string | undefined } & IRecordableEditorLogEntry\n\t\t| { sourceId: string; kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number; didAllProvidersReturn: boolean } & IRecordableLogEntry\n\t) {\n\t\tif (this._loggingEnabled.get()) {\n\t\t\tthis._logService.info(formatRecordableLogEntry(entry));\n\t\t}\n\t\tthis._structuredFetchLogger.log(entry);\n\t}\n\n\tprivate readonly _loadingCount = observableValue(this, 0);\n\n\tpublic fetch(\n\t\tproviders: InlineCompletionsProvider[],\n\t\tprovidersLabel: string | undefined,\n\t\tcontext: InlineCompletionContextWithoutUuid,\n\t\tactiveInlineCompletion: InlineSuggestionIdentity | undefined,\n\t\twithDebounce: boolean,\n\t\tuserJumpedToActiveCompletion: IObservable<boolean>,\n\t\trequestInfo: InlineSuggestRequestInfo\n\t): Promise<boolean> {\n\t\tconst position = this._cursorPosition.get();\n\t\tconst request = new UpdateRequest(position, context, this._textModel.getVersionId(), new Set(providers));\n\n\t\tconst target = context.selectedSuggestionInfo ? this.suggestWidgetInlineCompletions.get() : this.inlineCompletions.get();\n\n\t\tif (this._updateOperation.value?.request.satisfies(request)) {\n\t\t\treturn this._updateOperation.value.promise;\n\t\t} else if (target?.request?.satisfies(request)) {\n\t\t\treturn Promise.resolve(true);\n\t\t}\n\n\t\tconst updateOngoing = !!this._updateOperation.value;\n\t\tthis._updateOperation.clear();\n\n\t\tconst source = new CancellationTokenSource();\n\n\t\tconst promise = (async () => {\n\t\t\tconst store = new DisposableStore();\n\n\t\t\tthis._loadingCount.set(this._loadingCount.get() + 1, undefined);\n\t\t\tlet didDecrease = false;\n\t\t\tconst decreaseLoadingCount = () => {\n\t\t\t\tif (!didDecrease) {\n\t\t\t\t\tdidDecrease = true;\n\t\t\t\t\tthis._loadingCount.set(this._loadingCount.get() - 1, undefined);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst loadingReset = store.add(new RunOnceScheduler(() => decreaseLoadingCount(), 10 * 1000));\n\t\t\tloadingReset.schedule();\n\n\t\t\tconst inlineSuggestionsProviders = providers.filter(p => p.providerId);\n\t\t\tconst requestResponseInfo = new RequestResponseData(context, requestInfo, inlineSuggestionsProviders);\n\n\n\t\t\ttry {\n\t\t\t\tconst recommendedDebounceValue = this._debounceValue.get(this._textModel);\n\t\t\t\tconst debounceValue = findLastMax(\n\t\t\t\t\tproviders.map(p => p.debounceDelayMs),\n\t\t\t\t\tcompareUndefinedSmallest(numberComparator)\n\t\t\t\t) ?? recommendedDebounceValue;\n\n\t\t\t\t// Debounce in any case if update is ongoing\n\t\t\t\tconst shouldDebounce = updateOngoing || (withDebounce && context.triggerKind === InlineCompletionTriggerKind.Automatic);\n\t\t\t\tif (shouldDebounce) {\n\t\t\t\t\t// This debounces the operation\n\t\t\t\t\tawait wait(debounceValue, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:beforeFetch');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst requestId = InlineCompletionsSource._requestId++;\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tthis._log({\n\t\t\t\t\t\tsourceId: 'InlineCompletions.fetch',\n\t\t\t\t\t\tkind: 'start',\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\tmodelUri: this._textModel.uri,\n\t\t\t\t\t\tmodelVersion: this._textModel.getVersionId(),\n\t\t\t\t\t\tcontext: { triggerKind: context.triggerKind, suggestInfo: context.selectedSuggestionInfo ? true : undefined },\n\t\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\t\tprovider: providersLabel,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst startTime = new Date();\n\t\t\t\tconst providerResult = provideInlineCompletions(providers, this._cursorPosition.get(), this._textModel, context, requestInfo, this._languageConfigurationService);\n\n\t\t\t\trunWhenCancelled(source.token, () => providerResult.cancelAndDispose({ kind: 'tokenCancellation' }));\n\n\t\t\t\tlet shouldStopEarly = false;\n\t\t\t\tlet producedSuggestion = false;\n\n\t\t\t\tconst suggestions: InlineSuggestionItem[] = [];\n\t\t\t\tfor await (const list of providerResult.lists) {\n\t\t\t\t\tif (!list) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tlist.addRef();\n\t\t\t\t\tstore.add(toDisposable(() => list.removeRef(list.inlineSuggestionsData.length === 0 ? { kind: 'empty' } : { kind: 'notTaken' })));\n\n\t\t\t\t\tfor (const item of list.inlineSuggestionsData) {\n\t\t\t\t\t\tproducedSuggestion = true;\n\t\t\t\t\t\tif (!context.includeInlineEdits && (item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineEditRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!context.includeInlineCompletions && !(item.isInlineEdit || item.showInlineEditMenu)) {\n\t\t\t\t\t\t\titem.setNotShownReason('notInlineCompletionRequested');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst i = InlineSuggestionItem.create(item, this._textModel);\n\t\t\t\t\t\tsuggestions.push(i);\n\t\t\t\t\t\t// Stop after first visible inline completion\n\t\t\t\t\t\tif (!i.isInlineEdit && !i.showInlineEditMenu && context.triggerKind === InlineCompletionTriggerKind.Automatic) {\n\t\t\t\t\t\t\tif (i.isVisible(this._textModel, this._cursorPosition.get())) {\n\t\t\t\t\t\t\t\tshouldStopEarly = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldStopEarly) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tproviderResult.cancelAndDispose({ kind: 'lostRace' });\n\n\t\t\t\tif (this._loggingEnabled.get() || this._structuredFetchLogger.isEnabled.get()) {\n\t\t\t\t\tconst didAllProvidersReturn = providerResult.didAllProvidersReturn;\n\t\t\t\t\tlet error: string | undefined = undefined;\n\t\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId) {\n\t\t\t\t\t\terror = 'canceled';\n\t\t\t\t\t}\n\t\t\t\t\tconst result = suggestions.map(c => ({\n\t\t\t\t\t\trange: c.editRange.toString(),\n\t\t\t\t\t\ttext: c.insertText,\n\t\t\t\t\t\thint: c.hint,\n\t\t\t\t\t\tisInlineEdit: c.isInlineEdit,\n\t\t\t\t\t\tshowInlineEditMenu: c.showInlineEditMenu,\n\t\t\t\t\t\tproviderId: c.source.provider.providerId?.toString(),\n\t\t\t\t\t}));\n\t\t\t\t\tthis._log({ sourceId: 'InlineCompletions.fetch', kind: 'end', requestId, durationMs: (Date.now() - startTime.getTime()), error, result, time: Date.now(), didAllProvidersReturn });\n\t\t\t\t}\n\n\t\t\t\trequestResponseInfo.setRequestUuid(providerResult.contextWithUuid.requestUuid);\n\t\t\t\tif (producedSuggestion) {\n\t\t\t\t\trequestResponseInfo.setHasProducedSuggestion();\n\t\t\t\t\tif (suggestions.length > 0 && source.token.isCancellationRequested) {\n\t\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet('canceled:whileAwaitingOtherProviders'));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (source.token.isCancellationRequested) {\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet('canceled:whileFetching');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst completionsQuotaExceeded = this._contextKeyService.getContextKeyValue<boolean>('completionsQuotaExceeded');\n\t\t\t\t\t\trequestResponseInfo.setNoSuggestionReasonIfNotSet(completionsQuotaExceeded ? 'completionsQuotaExceeded' : 'noSuggestion');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst remainingTimeToWait = context.earliestShownDateTime - Date.now();\n\t\t\t\tif (remainingTimeToWait > 0) {\n\t\t\t\t\tawait wait(remainingTimeToWait, source.token);\n\t\t\t\t}\n\n\t\t\t\tif (source.token.isCancellationRequested || this._store.isDisposed || this._textModel.getVersionId() !== request.versionId\n\t\t\t\t\t|| userJumpedToActiveCompletion.get() /* In the meantime the user showed interest for the active completion so dont hide it */) {\n\t\t\t\t\tconst notShownReason =\n\t\t\t\t\t\tsource.token.isCancellationRequested ? 'canceled:afterMinShowDelay' :\n\t\t\t\t\t\t\tthis._store.isDisposed ? 'canceled:disposed' :\n\t\t\t\t\t\t\t\tthis._textModel.getVersionId() !== request.versionId ? 'canceled:documentChanged' :\n\t\t\t\t\t\t\t\t\tuserJumpedToActiveCompletion.get() ? 'canceled:userJumped' :\n\t\t\t\t\t\t\t\t\t\t'unknown';\n\t\t\t\t\tsuggestions.forEach(s => s.setNotShownReasonIfNotSet(notShownReason));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst endTime = new Date();\n\t\t\t\tthis._debounceValue.update(this._textModel, endTime.getTime() - startTime.getTime());\n\n\t\t\t\tconst cursorPosition = this._cursorPosition.get();\n\t\t\t\tthis._updateOperation.clear();\n\t\t\t\ttransaction(tx => {\n\t\t\t\t\t/** @description Update completions with provider result */\n\t\t\t\t\tconst v = this._state.get();\n\n\t\t\t\t\tif (context.selectedSuggestionInfo) {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: v.suggestWidgetInlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._state.set({\n\t\t\t\t\t\t\tinlineCompletions: v.inlineCompletions.createStateWithAppliedResults(suggestions, request, this._textModel, cursorPosition, activeInlineCompletion),\n\t\t\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t\t\t}, tx);\n\t\t\t\t\t}\n\n\t\t\t\t\tv.inlineCompletions.dispose();\n\t\t\t\t\tv.suggestWidgetInlineCompletions.dispose();\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tstore.dispose();\n\t\t\t\tdecreaseLoadingCount();\n\t\t\t\tthis.sendInlineCompletionsRequestTelemetry(requestResponseInfo);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tconst updateOperation = new UpdateOperation(request, source, promise);\n\t\tthis._updateOperation.value = updateOperation;\n\n\t\treturn promise;\n\t}\n\n\tpublic clear(tx: ITransaction): void {\n\t\tthis._updateOperation.clear();\n\t\tconst v = this._state.get();\n\t\tthis._state.set({\n\t\t\tinlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty()\n\t\t}, tx);\n\t\tv.inlineCompletions.dispose();\n\t\tv.suggestWidgetInlineCompletions.dispose();\n\t}\n\n\tpublic seedInlineCompletionsWithSuggestWidget(): void {\n\t\tconst inlineCompletions = this.inlineCompletions.get();\n\t\tconst suggestWidgetInlineCompletions = this.suggestWidgetInlineCompletions.get();\n\t\tif (!suggestWidgetInlineCompletions) {\n\t\t\treturn;\n\t\t}\n\t\ttransaction(tx => {\n\t\t\t/** @description Seed inline completions with (newer) suggest widget inline completions */\n\t\t\tif (!inlineCompletions || (suggestWidgetInlineCompletions.request?.versionId ?? -1) > (inlineCompletions.request?.versionId ?? -1)) {\n\t\t\t\tinlineCompletions?.dispose();\n\t\t\t\tconst s = this._state.get();\n\t\t\t\tthis._state.set({\n\t\t\t\t\tinlineCompletions: suggestWidgetInlineCompletions.clone(),\n\t\t\t\t\tsuggestWidgetInlineCompletions: InlineCompletionsState.createEmpty(),\n\t\t\t\t}, tx);\n\t\t\t\ts.inlineCompletions.dispose();\n\t\t\t\ts.suggestWidgetInlineCompletions.dispose();\n\t\t\t}\n\t\t\tthis.clearSuggestWidgetInlineCompletions(tx);\n\t\t});\n\t}\n\n\tprivate sendInlineCompletionsRequestTelemetry(\n\t\trequestResponseInfo: RequestResponseData\n\t): void {\n\t\tif (!this._sendRequestData.get() && !this._contextKeyService.getContextKeyValue<boolean>('isRunningUnificationExperiment')) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (requestResponseInfo.requestUuid === undefined || requestResponseInfo.hasProducedSuggestion) {\n\t\t\treturn;\n\t\t}\n\n\n\t\tif (!isCompletionsEnabled(this._completionsEnabled, this._textModel.getLanguageId())) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst emptyEndOfLifeEvent: InlineCompletionEndOfLifeEvent = {\n\t\t\topportunityId: requestResponseInfo.requestUuid,\n\t\t\tnoSuggestionReason: requestResponseInfo.noSuggestionReason ?? 'unknown',\n\t\t\textensionId: 'vscode-core',\n\t\t\textensionVersion: '0.0.0',\n\t\t\tgroupId: 'empty',\n\t\t\tshown: false,\n\t\t\teditorType: requestResponseInfo.requestInfo.editorType,\n\t\t\trequestReason: requestResponseInfo.requestInfo.reason,\n\t\t\ttypingInterval: requestResponseInfo.requestInfo.typingInterval,\n\t\t\ttypingIntervalCharacterCount: requestResponseInfo.requestInfo.typingIntervalCharacterCount,\n\t\t\tlanguageId: requestResponseInfo.requestInfo.languageId,\n\t\t\tselectedSuggestionInfo: !!requestResponseInfo.context.selectedSuggestionInfo,\n\t\t\tavailableProviders: requestResponseInfo.providers.map(p => p.providerId?.toString()).filter(isDefined).join(','),\n\t\t\t...forwardToChannelIf(requestResponseInfo.providers.some(p => isCopilotLikeExtension(p.providerId?.extensionId))),\n\t\t\ttimeUntilProviderRequest: undefined,\n\t\t\ttimeUntilProviderResponse: undefined,\n\t\t\tviewKind: undefined,\n\t\t\tpreceeded: undefined,\n\t\t\tsuperseded: undefined,\n\t\t\treason: undefined,\n\t\t\tcorrelationId: undefined,\n\t\t\tshownDuration: undefined,\n\t\t\tshownDurationUncollapsed: undefined,\n\t\t\ttimeUntilShown: undefined,\n\t\t\tpartiallyAccepted: undefined,\n\t\t\tpartiallyAcceptedCountSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedRatioSinceOriginal: undefined,\n\t\t\tpartiallyAcceptedCharactersSinceOriginal: undefined,\n\t\t\tcursorColumnDistance: undefined,\n\t\t\tcursorLineDistance: undefined,\n\t\t\tlineCountOriginal: undefined,\n\t\t\tlineCountModified: undefined,\n\t\t\tcharacterCountOriginal: undefined,\n\t\t\tcharacterCountModified: undefined,\n\t\t\tdisjointReplacements: undefined,\n\t\t\tsameShapeReplacements: undefined,\n\t\t\tnotShownReason: undefined,\n\t\t};\n\n\t\tconst dataChannel = this._instantiationService.createInstance(DataChannelForwardingTelemetryService);\n\t\tsendInlineCompletionsEndOfLifeTelemetry(dataChannel, emptyEndOfLifeEvent);\n\t}\n\n\tpublic clearSuggestWidgetInlineCompletions(tx: ITransaction): void {\n\t\tif (this._updateOperation.value?.request.context.selectedSuggestionInfo) {\n\t\t\tthis._updateOperation.clear();\n\t\t}\n\t}\n\n\tpublic cancelUpdate(): void {\n\t\tthis._updateOperation.clear();\n\t}\n}\n\nclass UpdateRequest {\n\tconstructor(\n\t\tpublic readonly position: Position,\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly providers: Set<InlineCompletionsProvider>,\n\t) {\n\t}\n\n\tpublic satisfies(other: UpdateRequest): boolean {\n\t\treturn this.position.equals(other.position)\n\t\t\t&& equalsIfDefined(this.context.selectedSuggestionInfo, other.context.selectedSuggestionInfo, itemEquals())\n\t\t\t&& (other.context.triggerKind === InlineCompletionTriggerKind.Automatic\n\t\t\t\t|| this.context.triggerKind === InlineCompletionTriggerKind.Explicit)\n\t\t\t&& this.versionId === other.versionId\n\t\t\t&& isSubset(other.providers, this.providers);\n\t}\n}\n\nclass RequestResponseData {\n\tpublic requestUuid: string | undefined;\n\tpublic noSuggestionReason: string | undefined;\n\tpublic hasProducedSuggestion = false;\n\n\tconstructor(\n\t\tpublic readonly context: InlineCompletionContextWithoutUuid,\n\t\tpublic readonly requestInfo: InlineSuggestRequestInfo,\n\t\tpublic readonly providers: InlineCompletionsProvider[],\n\t) { }\n\n\tsetRequestUuid(uuid: string) {\n\t\tthis.requestUuid = uuid;\n\t}\n\n\tsetNoSuggestionReasonIfNotSet(type: string) {\n\t\tthis.noSuggestionReason ??= type;\n\t}\n\n\tsetHasProducedSuggestion() {\n\t\tthis.hasProducedSuggestion = true;\n\t}\n}\n\nfunction isSubset<T>(set1: Set<T>, set2: Set<T>): boolean {\n\treturn [...set1].every(item => set2.has(item));\n}\n\nfunction isCompletionsEnabled(completionsEnablementObject: Record<string, boolean> | undefined, modeId: string = '*'): boolean {\n\tif (completionsEnablementObject === undefined) {\n\t\treturn false; // default to disabled if setting is not available\n\t}\n\n\tif (typeof completionsEnablementObject[modeId] !== 'undefined') {\n\t\treturn Boolean(completionsEnablementObject[modeId]); // go with setting if explicitly defined\n\t}\n\n\treturn Boolean(completionsEnablementObject['*']); // fallback to global setting otherwise\n}\n\nclass UpdateOperation implements IDisposable {\n\tconstructor(\n\t\tpublic readonly request: UpdateRequest,\n\t\tpublic readonly cancellationTokenSource: CancellationTokenSource,\n\t\tpublic readonly promise: Promise<boolean>,\n\t) {\n\t}\n\n\tdispose() {\n\t\tthis.cancellationTokenSource.cancel();\n\t}\n}\n\nclass InlineCompletionsState extends Disposable {\n\tpublic static createEmpty(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState([], undefined);\n\t}\n\n\tconstructor(\n\t\tpublic readonly inlineCompletions: readonly InlineSuggestionItem[],\n\t\tpublic readonly request: UpdateRequest | undefined,\n\t) {\n\t\tfor (const inlineCompletion of inlineCompletions) {\n\t\t\tinlineCompletion.addRef();\n\t\t}\n\n\t\tsuper();\n\n\t\tthis._register({\n\t\t\tdispose: () => {\n\t\t\t\tfor (const inlineCompletion of this.inlineCompletions) {\n\t\t\t\t\tinlineCompletion.removeRef();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate _findById(id: InlineSuggestionIdentity): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.identity === id);\n\t}\n\n\tprivate _findByHash(hash: string): InlineSuggestionItem | undefined {\n\t\treturn this.inlineCompletions.find(i => i.hash === hash);\n\t}\n\n\t/**\n\t * Applies the edit on the state.\n\t*/\n\tpublic createStateWithAppliedEdit(edit: StringEdit, textModel: ITextModel): InlineCompletionsState {\n\t\tconst newInlineCompletions = this.inlineCompletions.map(i => i.withEdit(edit, textModel)).filter(isDefined);\n\t\treturn new InlineCompletionsState(newInlineCompletions, this.request);\n\t}\n\n\tpublic createStateWithAppliedResults(updatedSuggestions: InlineSuggestionItem[], request: UpdateRequest, textModel: ITextModel, cursorPosition: Position, itemIdToPreserveAtTop: InlineSuggestionIdentity | undefined): InlineCompletionsState {\n\t\tlet itemToPreserve: InlineSuggestionItem | undefined = undefined;\n\t\tif (itemIdToPreserveAtTop) {\n\t\t\tconst itemToPreserveCandidate = this._findById(itemIdToPreserveAtTop);\n\t\t\tif (itemToPreserveCandidate && itemToPreserveCandidate.canBeReused(textModel, request.position)) {\n\t\t\t\titemToPreserve = itemToPreserveCandidate;\n\n\t\t\t\tconst updatedItemToPreserve = updatedSuggestions.find(i => i.hash === itemToPreserveCandidate.hash);\n\t\t\t\tif (updatedItemToPreserve) {\n\t\t\t\t\tupdatedSuggestions = moveToFront(updatedItemToPreserve, updatedSuggestions);\n\t\t\t\t} else {\n\t\t\t\t\tupdatedSuggestions = [itemToPreserveCandidate, ...updatedSuggestions];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst preferInlineCompletions = itemToPreserve\n\t\t\t// itemToPreserve has precedence\n\t\t\t? !itemToPreserve.isInlineEdit\n\t\t\t// Otherwise: prefer inline completion if there is a visible one\n\t\t\t: updatedSuggestions.some(i => !i.isInlineEdit && i.isVisible(textModel, cursorPosition));\n\n\t\tlet updatedItems: InlineSuggestionItem[] = [];\n\t\tfor (const i of updatedSuggestions) {\n\t\t\tconst oldItem = this._findByHash(i.hash);\n\t\t\tlet item;\n\t\t\tif (oldItem && oldItem !== i) {\n\t\t\t\titem = i.withIdentity(oldItem.identity);\n\t\t\t\ti.setIsPreceeded(oldItem);\n\t\t\t\toldItem.setEndOfLifeReason({ kind: InlineCompletionEndOfLifeReasonKind.Ignored, userTypingDisagreed: false, supersededBy: i.getSourceCompletion() });\n\t\t\t} else {\n\t\t\t\titem = i;\n\t\t\t}\n\t\t\tif (preferInlineCompletions !== item.isInlineEdit) {\n\t\t\t\tupdatedItems.push(item);\n\t\t\t}\n\t\t}\n\n\t\tupdatedItems.sort(compareBy(i => i.showInlineEditMenu, booleanComparator));\n\t\tupdatedItems = distinctByKey(updatedItems, i => i.semanticId);\n\n\t\treturn new InlineCompletionsState(updatedItems, request);\n\t}\n\n\tpublic clone(): InlineCompletionsState {\n\t\treturn new InlineCompletionsState(this.inlineCompletions, this.request);\n\t}\n}\n\n/** Keeps the first item in case of duplicates. */\nfunction distinctByKey<T>(items: T[], key: (item: T) => unknown): T[] {\n\tconst seen = new Set();\n\treturn items.filter(item => {\n\t\tconst k = key(item);\n\t\tif (seen.has(k)) {\n\t\t\treturn false;\n\t\t}\n\t\tseen.add(k);\n\t\treturn true;\n\t});\n}\n\nfunction moveToFront<T>(item: T, items: T[]): T[] {\n\tconst index = items.indexOf(item);\n\tif (index > -1) {\n\t\treturn [item, ...items.slice(0, index), ...items.slice(index + 1)];\n\t}\n\treturn items;\n}\n"]}
@@ -20,7 +20,7 @@ import { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';
20
20
  export var InlineSuggestionItem;
21
21
  (function (InlineSuggestionItem) {
22
22
  function create(data, textModel) {
23
- if (!data.isInlineEdit) {
23
+ if (!data.isInlineEdit && !data.uri) {
24
24
  return InlineCompletionItem.create(data, textModel);
25
25
  }
26
26
  else {
@@ -30,10 +30,10 @@ export var InlineSuggestionItem;
30
30
  InlineSuggestionItem.create = create;
31
31
  })(InlineSuggestionItem || (InlineSuggestionItem = {}));
32
32
  class InlineSuggestionItemBase {
33
- constructor(_data, identity, displayLocation) {
33
+ constructor(_data, identity, hint) {
34
34
  this._data = _data;
35
35
  this.identity = identity;
36
- this.displayLocation = displayLocation;
36
+ this.hint = hint;
37
37
  }
38
38
  /**
39
39
  * A reference to the original inline completion list this inline completion has been constructed from.
@@ -43,10 +43,10 @@ class InlineSuggestionItemBase {
43
43
  get isFromExplicitRequest() { return this._data.context.triggerKind === InlineCompletionTriggerKind.Explicit; }
44
44
  get forwardStable() { return this.source.inlineSuggestions.enableForwardStability ?? false; }
45
45
  get editRange() { return this.getSingleTextEdit().range; }
46
- get targetRange() { return this.displayLocation?.range && !this.displayLocation.jumpToEdit ? this.displayLocation?.range : this.editRange; }
46
+ get targetRange() { return this.hint?.range && !this.hint.jumpToEdit ? this.hint?.range : this.editRange; }
47
47
  get insertText() { return this.getSingleTextEdit().text; }
48
48
  get semanticId() { return this.hash; }
49
- get action() { return this._sourceInlineCompletion.action; }
49
+ get action() { return this._sourceInlineCompletion.gutterMenuLinkAction; }
50
50
  get command() { return this._sourceInlineCompletion.command; }
51
51
  get warning() { return this._sourceInlineCompletion.warning; }
52
52
  get showInlineEditMenu() { return !!this._sourceInlineCompletion.showInlineEditMenu; }
@@ -83,9 +83,6 @@ class InlineSuggestionItemBase {
83
83
  setEndOfLifeReason(reason) {
84
84
  this._data.setEndOfLifeReason(reason);
85
85
  }
86
- reportInlineEditError(reason) {
87
- this._data.reportInlineEditError(reason);
88
- }
89
86
  setIsPreceeded(item) {
90
87
  this._data.setIsPreceeded(item.partialAccepts);
91
88
  }
@@ -123,14 +120,14 @@ export class InlineSuggestionIdentity {
123
120
  this._jumpedTo.set(true, tx);
124
121
  }
125
122
  }
126
- class InlineSuggestDisplayLocation {
123
+ export class InlineSuggestHint {
127
124
  static create(displayLocation) {
128
- return new InlineSuggestDisplayLocation(displayLocation.range, displayLocation.label, displayLocation.kind, displayLocation.jumpToEdit);
125
+ return new InlineSuggestHint(Range.lift(displayLocation.range), displayLocation.content, displayLocation.style, displayLocation.jumpToEdit);
129
126
  }
130
- constructor(range, label, kind, jumpToEdit) {
127
+ constructor(range, content, style, jumpToEdit) {
131
128
  this.range = range;
132
- this.label = label;
133
- this.kind = kind;
129
+ this.content = content;
130
+ this.style = style;
134
131
  this.jumpToEdit = jumpToEdit;
135
132
  }
136
133
  withEdit(edit, positionOffsetTransformer) {
@@ -140,7 +137,7 @@ class InlineSuggestDisplayLocation {
140
137
  return undefined;
141
138
  }
142
139
  const newRange = positionOffsetTransformer.getRange(newOffsetRange);
143
- return new InlineSuggestDisplayLocation(newRange, this.label, this.kind, this.jumpToEdit);
140
+ return new InlineSuggestHint(newRange, this.content, this.style, this.jumpToEdit);
144
141
  }
145
142
  }
146
143
  export class InlineCompletionItem extends InlineSuggestionItemBase {
@@ -151,7 +148,7 @@ export class InlineCompletionItem extends InlineSuggestionItemBase {
151
148
  const edit = reshapeInlineCompletion(new StringReplacement(transformer.getOffsetRange(data.range), insertText), textModel);
152
149
  const trimmedEdit = edit.removeCommonSuffixAndPrefix(textModel.getValue());
153
150
  const textEdit = transformer.getTextReplacement(edit);
154
- const displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;
151
+ const displayLocation = data.hint ? InlineSuggestHint.create(data.hint) : undefined;
155
152
  return new InlineCompletionItem(edit, trimmedEdit, textEdit, textEdit.range, data.snippetInfo, data.additionalTextEdits, data, identity, displayLocation);
156
153
  }
157
154
  constructor(_edit, _trimmedEdit, _textEdit, _originalRange, snippetInfo, additionalTextEdits, data, identity, displayLocation) {
@@ -169,7 +166,7 @@ export class InlineCompletionItem extends InlineSuggestionItemBase {
169
166
  }
170
167
  getSingleTextEdit() { return this._textEdit; }
171
168
  withIdentity(identity) {
172
- return new InlineCompletionItem(this._edit, this._trimmedEdit, this._textEdit, this._originalRange, this.snippetInfo, this.additionalTextEdits, this._data, identity, this.displayLocation);
169
+ return new InlineCompletionItem(this._edit, this._trimmedEdit, this._textEdit, this._originalRange, this.snippetInfo, this.additionalTextEdits, this._data, identity, this.hint);
173
170
  }
174
171
  withEdit(textModelEdit, textModel) {
175
172
  const newEditRange = applyEditsToRanges([this._edit.replaceRange], textModelEdit);
@@ -179,7 +176,7 @@ export class InlineCompletionItem extends InlineSuggestionItemBase {
179
176
  const newEdit = new StringReplacement(newEditRange[0], this._textEdit.text);
180
177
  const positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);
181
178
  const newTextEdit = positionOffsetTransformer.getTextReplacement(newEdit);
182
- let newDisplayLocation = this.displayLocation;
179
+ let newDisplayLocation = this.hint;
183
180
  if (newDisplayLocation) {
184
181
  newDisplayLocation = newDisplayLocation.withEdit(textModelEdit, positionOffsetTransformer);
185
182
  if (!newDisplayLocation) {
@@ -248,13 +245,14 @@ export class InlineEditItem extends InlineSuggestionItemBase {
248
245
  const replacedText = textModel.getValueInRange(replacedRange);
249
246
  return SingleUpdatedNextEdit.create(edit, replacedText);
250
247
  });
251
- const displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;
252
- return new InlineEditItem(offsetEdit, singleTextEdit, data, identity, edits, displayLocation, false, textModel.getVersionId());
248
+ const hint = data.hint ? InlineSuggestHint.create(data.hint) : undefined;
249
+ return new InlineEditItem(offsetEdit, singleTextEdit, data.uri, data, identity, edits, hint, false, textModel.getVersionId());
253
250
  }
254
- constructor(_edit, _textEdit, data, identity, _edits, displayLocation, _lastChangePartOfInlineEdit = false, _inlineEditModelVersion) {
255
- super(data, identity, displayLocation);
251
+ constructor(_edit, _textEdit, uri, data, identity, _edits, hint, _lastChangePartOfInlineEdit = false, _inlineEditModelVersion) {
252
+ super(data, identity, hint);
256
253
  this._edit = _edit;
257
254
  this._textEdit = _textEdit;
255
+ this.uri = uri;
258
256
  this._edits = _edits;
259
257
  this._lastChangePartOfInlineEdit = _lastChangePartOfInlineEdit;
260
258
  this._inlineEditModelVersion = _inlineEditModelVersion;
@@ -268,7 +266,7 @@ export class InlineEditItem extends InlineSuggestionItemBase {
268
266
  return this._textEdit;
269
267
  }
270
268
  withIdentity(identity) {
271
- return new InlineEditItem(this._edit, this._textEdit, this._data, identity, this._edits, this.displayLocation, this._lastChangePartOfInlineEdit, this._inlineEditModelVersion);
269
+ return new InlineEditItem(this._edit, this._textEdit, this.uri, this._data, identity, this._edits, this.hint, this._lastChangePartOfInlineEdit, this._inlineEditModelVersion);
272
270
  }
273
271
  canBeReused(model, position) {
274
272
  // TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.
@@ -299,14 +297,14 @@ export class InlineEditItem extends InlineSuggestionItemBase {
299
297
  const newEdit = new StringEdit(edits.map(edit => edit.edit));
300
298
  const positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);
301
299
  const newTextEdit = positionOffsetTransformer.getTextEdit(newEdit).toReplacement(new TextModelText(textModel));
302
- let newDisplayLocation = this.displayLocation;
300
+ let newDisplayLocation = this.hint;
303
301
  if (newDisplayLocation) {
304
302
  newDisplayLocation = newDisplayLocation.withEdit(textModelChanges, positionOffsetTransformer);
305
303
  if (!newDisplayLocation) {
306
304
  return undefined;
307
305
  }
308
306
  }
309
- return new InlineEditItem(newEdit, newTextEdit, this._data, this.identity, edits, newDisplayLocation, lastChangePartOfInlineEdit, inlineEditModelVersion);
307
+ return new InlineEditItem(newEdit, newTextEdit, this.uri, this._data, this.identity, edits, newDisplayLocation, lastChangePartOfInlineEdit, inlineEditModelVersion);
310
308
  }
311
309
  }
312
310
  function getStringEdit(textModel, editRange, replaceText) {