@vscode/chat-lib 0.3.1-2 → 0.3.1-21
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.
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts +1 -6
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js +9 -20
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/common/constants.d.ts +0 -1
- package/dist/src/_internal/extension/common/constants.d.ts.map +1 -1
- package/dist/src/_internal/extension/common/constants.js +2 -1
- package/dist/src/_internal/extension/common/constants.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/experiments/defaultExpFilters.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/experiments/defaultExpFilters.js +5 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/experiments/defaultExpFilters.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.d.ts +4 -2
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js +38 -5
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.d.ts +4 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.js +58 -48
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/inlineCompletion.d.ts +3 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/inlineCompletion.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/inlineCompletion.js +5 -5
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/inlineCompletion.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.d.ts +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.js +215 -125
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.d.ts +4 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.js +31 -18
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.js +4 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.d.ts +3 -3
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js +9 -9
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/rejectionCollector.d.ts +3 -2
- package/dist/src/_internal/extension/inlineEdits/common/rejectionCollector.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/rejectionCollector.js +10 -11
- package/dist/src/_internal/extension/inlineEdits/common/rejectionCollector.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts +52 -8
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js +208 -41
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts +14 -4
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js +53 -39
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +25 -4
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +474 -172
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts +16 -8
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +53 -27
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/power/common/powerService.d.ts +22 -0
- package/dist/src/_internal/extension/power/common/powerService.d.ts.map +1 -0
- package/dist/src/_internal/extension/power/common/powerService.js +20 -0
- package/dist/src/_internal/extension/power/common/powerService.js.map +1 -0
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts +4 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +46 -10
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/inlineSuggestion.d.ts +15 -0
- package/dist/src/_internal/extension/xtab/common/inlineSuggestion.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/inlineSuggestion.js +43 -0
- package/dist/src/_internal/extension/xtab/common/inlineSuggestion.js.map +1 -0
- package/dist/src/_internal/extension/xtab/common/lintErrors.d.ts +4 -4
- package/dist/src/_internal/extension/xtab/common/lintErrors.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/lintErrors.js +70 -26
- package/dist/src/_internal/extension/xtab/common/lintErrors.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts +4 -4
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +84 -19
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/terminalOutput.d.ts +20 -0
- package/dist/src/_internal/extension/xtab/common/terminalOutput.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/terminalOutput.js +105 -0
- package/dist/src/_internal/extension/xtab/common/terminalOutput.js.map +1 -0
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.d.ts +2 -3
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js +2 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.d.ts +2 -2
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js +50 -4
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +53 -9
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +384 -170
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabUtils.d.ts +1 -4
- package/dist/src/_internal/extension/xtab/node/xtabUtils.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabUtils.js +21 -39
- package/dist/src/_internal/extension/xtab/node/xtabUtils.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts +7 -2
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.js +11 -4
- package/dist/src/_internal/platform/authentication/common/copilotToken.js.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js +1 -0
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts +2 -2
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +8 -8
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +51 -10
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +53 -15
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +3 -2
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +22 -26
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +9 -5
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointTypes.d.ts +1 -0
- package/dist/src/_internal/platform/endpoint/common/endpointTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointTypes.js +1 -0
- package/dist/src/_internal/platform/endpoint/common/endpointTypes.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/phaseDataContainer.d.ts +16 -0
- package/dist/src/_internal/platform/endpoint/common/phaseDataContainer.d.ts.map +1 -0
- package/dist/src/_internal/platform/endpoint/common/phaseDataContainer.js +37 -0
- package/dist/src/_internal/platform/endpoint/common/phaseDataContainer.js.map +1 -0
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js +1 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +6 -13
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +18 -53
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +22 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +193 -59
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +25 -3
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +6 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +4 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.d.ts +4 -3
- package/dist/src/_internal/platform/git/common/gitService.d.ts.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.js +4 -2
- package/dist/src/_internal/platform/github/common/githubAPI.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +43 -4
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js +18 -6
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts +100 -3
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js +230 -2
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts +11 -5
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +33 -18
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/responseProcessor.d.ts +30 -5
- package/dist/src/_internal/platform/inlineEdits/common/responseProcessor.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/responseProcessor.js +69 -2
- package/dist/src/_internal/platform/inlineEdits/common/responseProcessor.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +39 -7
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +43 -6
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.d.ts +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js +23 -24
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js.map +1 -1
- package/dist/src/_internal/platform/log/common/logService.d.ts +68 -0
- package/dist/src/_internal/platform/log/common/logService.d.ts.map +1 -1
- package/dist/src/_internal/platform/log/common/logService.js +227 -29
- package/dist/src/_internal/platform/log/common/logService.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.d.ts +5 -1
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js +121 -6
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.d.ts +1 -4
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.d.ts.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.js +1 -21
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts +18 -5
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.js +55 -27
- package/dist/src/_internal/platform/networking/common/anthropic.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts +8 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +2 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts +17 -13
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js +4 -4
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/common/capturingToken.d.ts +35 -1
- package/dist/src/_internal/platform/requestLogger/common/capturingToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/common/capturingToken.js +21 -1
- package/dist/src/_internal/platform/requestLogger/common/capturingToken.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts +2 -2
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts +37 -2
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.js +54 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts +2 -0
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.js +1 -0
- package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetryData.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetryData.js +3 -0
- package/dist/src/_internal/platform/telemetry/common/telemetryData.js.map +1 -1
- package/dist/src/_internal/platform/terminal/common/terminalService.d.ts +111 -0
- package/dist/src/_internal/platform/terminal/common/terminalService.d.ts.map +1 -0
- package/dist/src/_internal/platform/terminal/common/terminalService.js +83 -0
- package/dist/src/_internal/platform/terminal/common/terminalService.js.map +1 -0
- package/dist/src/_internal/platform/workspace/common/workspaceService.d.ts +9 -3
- package/dist/src/_internal/platform/workspace/common/workspaceService.d.ts.map +1 -1
- package/dist/src/_internal/platform/workspace/common/workspaceService.js +8 -2
- package/dist/src/_internal/platform/workspace/common/workspaceService.js.map +1 -1
- package/dist/src/_internal/util/common/asyncIterableUtils.d.ts +17 -0
- package/dist/src/_internal/util/common/asyncIterableUtils.d.ts.map +1 -0
- package/dist/src/_internal/util/common/asyncIterableUtils.js +94 -0
- package/dist/src/_internal/util/common/asyncIterableUtils.js.map +1 -0
- package/dist/src/_internal/util/common/backwardCompatSetting.d.ts +12 -0
- package/dist/src/_internal/util/common/backwardCompatSetting.d.ts.map +1 -0
- package/dist/src/_internal/util/common/backwardCompatSetting.js +21 -0
- package/dist/src/_internal/util/common/backwardCompatSetting.js.map +1 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +52 -3
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +63 -5
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/themes.d.ts +13 -0
- package/dist/src/_internal/util/common/test/shims/themes.d.ts.map +1 -0
- package/dist/src/_internal/util/common/test/shims/themes.js +27 -0
- package/dist/src/_internal/util/common/test/shims/themes.js.map +1 -0
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/arrays.d.ts +13 -1
- package/dist/src/_internal/util/vs/base/common/arrays.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/arrays.js +26 -0
- package/dist/src/_internal/util/vs/base/common/arrays.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/arraysFind.d.ts +6 -3
- package/dist/src/_internal/util/vs/base/common/arraysFind.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/arraysFind.js +19 -1
- package/dist/src/_internal/util/vs/base/common/arraysFind.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/assert.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/assert.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/assert.js +4 -0
- package/dist/src/_internal/util/vs/base/common/assert.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/async.d.ts +7 -0
- package/dist/src/_internal/util/vs/base/common/async.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/async.js +39 -2
- package/dist/src/_internal/util/vs/base/common/async.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/buffer.js +2 -2
- package/dist/src/_internal/util/vs/base/common/buffer.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.d.ts +1 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/cancellation.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codicons.d.ts +31 -5
- package/dist/src/_internal/util/vs/base/common/codicons.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.d.ts +31 -5
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.js +31 -5
- package/dist/src/_internal/util/vs/base/common/codiconsLibrary.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/collections.d.ts +2 -2
- package/dist/src/_internal/util/vs/base/common/collections.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/collections.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/equals.d.ts +46 -14
- package/dist/src/_internal/util/vs/base/common/equals.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/equals.js +84 -36
- package/dist/src/_internal/util/vs/base/common/equals.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/event.d.ts +30 -2
- package/dist/src/_internal/util/vs/base/common/event.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/event.js +105 -19
- package/dist/src/_internal/util/vs/base/common/event.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/filters.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/filters.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/filters.js +23 -3
- package/dist/src/_internal/util/vs/base/common/filters.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/glob.d.ts +7 -3
- package/dist/src/_internal/util/vs/base/common/glob.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/glob.js +42 -30
- package/dist/src/_internal/util/vs/base/common/glob.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/htmlContent.d.ts +6 -1
- package/dist/src/_internal/util/vs/base/common/htmlContent.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/htmlContent.js +12 -4
- package/dist/src/_internal/util/vs/base/common/htmlContent.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/iterator.d.ts +2 -2
- package/dist/src/_internal/util/vs/base/common/iterator.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/iterator.js +1 -1
- package/dist/src/_internal/util/vs/base/common/iterator.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/lifecycle.d.ts +6 -2
- package/dist/src/_internal/util/vs/base/common/lifecycle.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/lifecycle.js +10 -5
- package/dist/src/_internal/util/vs/base/common/lifecycle.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/linkedList.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/linkedList.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/linkedList.js +9 -0
- package/dist/src/_internal/util/vs/base/common/linkedList.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/map.d.ts +4 -4
- package/dist/src/_internal/util/vs/base/common/map.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/map.js +8 -5
- package/dist/src/_internal/util/vs/base/common/map.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/marshallingIds.d.ts +1 -1
- package/dist/src/_internal/util/vs/base/common/marshallingIds.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/mime.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/mime.js +7 -5
- package/dist/src/_internal/util/vs/base/common/mime.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/network.d.ts +10 -2
- package/dist/src/_internal/util/vs/base/common/network.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/network.js +10 -3
- package/dist/src/_internal/util/vs/base/common/network.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/normalization.d.ts +11 -0
- package/dist/src/_internal/util/vs/base/common/normalization.d.ts.map +1 -0
- package/dist/src/_internal/util/vs/base/common/normalization.js +61 -0
- package/dist/src/_internal/util/vs/base/common/normalization.js.map +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.d.ts +4 -4
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/base.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.js +1 -2
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugLocation.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.js +0 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/debugName.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.d.ts +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.js +5 -4
- package/dist/src/_internal/util/vs/base/common/observableInternal/index.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.d.ts +5 -2
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js +39 -11
- package/dist/src/_internal/util/vs/base/common/observableInternal/logging/debugGetDependencyGraph.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/map.d.ts +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/map.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/map.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.d.ts +10 -4
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.js +17 -6
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derived.d.ts +2 -2
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derived.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.js +11 -8
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.d.ts +1 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.js +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.d.ts +2 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.js +16 -0
- package/dist/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utils.d.ts +5 -3
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utils.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utils.js +51 -27
- package/dist/src/_internal/util/vs/base/common/observableInternal/utils/utils.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/platform.d.ts +0 -1
- package/dist/src/_internal/util/vs/base/common/platform.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/platform.js +0 -4
- package/dist/src/_internal/util/vs/base/common/platform.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/strings.d.ts +10 -2
- package/dist/src/_internal/util/vs/base/common/strings.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/strings.js +80 -26
- package/dist/src/_internal/util/vs/base/common/strings.js.map +1 -1
- package/dist/src/_internal/util/vs/base/common/types.d.ts +14 -0
- package/dist/src/_internal/util/vs/base/common/types.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/base/common/types.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/edit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.d.ts +5 -0
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.js +45 -7
- package/dist/src/_internal/util/vs/editor/common/core/edits/stringEdit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/textEdit.d.ts +12 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/textEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/edits/textEdit.js +355 -0
- package/dist/src/_internal/util/vs/editor/common/core/edits/textEdit.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.d.ts +3 -0
- package/dist/src/_internal/util/vs/editor/common/core/range.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/range.js +3 -0
- package/dist/src/_internal/util/vs/editor/common/core/range.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/ranges/offsetRange.d.ts +7 -0
- package/dist/src/_internal/util/vs/editor/common/core/ranges/offsetRange.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/ranges/offsetRange.js +13 -0
- package/dist/src/_internal/util/vs/editor/common/core/ranges/offsetRange.js.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.d.ts +5 -2
- package/dist/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.js +24 -10
- package/dist/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.js.map +1 -1
- package/dist/src/_internal/util/vs/nls.d.ts +2 -1
- package/dist/src/_internal/util/vs/nls.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/nls.js +10 -9
- package/dist/src/_internal/util/vs/nls.js.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.d.ts +0 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiation.js.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.js +1 -8
- package/dist/src/_internal/util/vs/platform/instantiation/common/instantiationService.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.d.ts +8 -2
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/location.d.ts +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/location.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/location.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.d.ts +3 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.js +10 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.d.ts +13 -13
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/position.d.ts +5 -2
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/position.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/position.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/range.d.ts +2 -2
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/range.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/range.js +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/range.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.d.ts +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.js +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.d.ts +3 -3
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.js +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.d.ts +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.js.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.d.ts +6 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.d.ts +6 -2
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.d.ts.map +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.js +1 -1
- package/dist/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +7 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +9 -2
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts +4 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +15 -3
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +726 -264
- package/package.json +3 -3
- package/dist/src/_internal/util/common/tracing.d.ts +0 -51
- package/dist/src/_internal/util/common/tracing.d.ts.map +0 -1
- package/dist/src/_internal/util/common/tracing.js +0 -96
- package/dist/src/_internal/util/common/tracing.js.map +0 -1
- package/dist/src/_internal/util/vs/nls.messages.d.ts +0 -3
- package/dist/src/_internal/util/vs/nls.messages.d.ts.map +0 -1
- package/dist/src/_internal/util/vs/nls.messages.js +0 -22
- package/dist/src/_internal/util/vs/nls.messages.js.map +0 -1
|
@@ -47,17 +47,20 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
47
47
|
};
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.NextEditFetchRequest = exports.NextEditProvider = void 0;
|
|
50
|
+
const path_1 = require("path");
|
|
50
51
|
const configurationService_1 = require("../../../platform/configuration/common/configurationService");
|
|
51
52
|
const edit_1 = require("../../../platform/inlineEdits/common/dataTypes/edit");
|
|
52
53
|
const rootedLineEdit_1 = require("../../../platform/inlineEdits/common/dataTypes/rootedLineEdit");
|
|
54
|
+
const inlineEditLogContext_1 = require("../../../platform/inlineEdits/common/inlineEditLogContext");
|
|
53
55
|
const statelessNextEditProvider_1 = require("../../../platform/inlineEdits/common/statelessNextEditProvider");
|
|
54
56
|
const observable_1 = require("../../../platform/inlineEdits/common/utils/observable");
|
|
55
57
|
const logService_1 = require("../../../platform/log/common/logService");
|
|
58
|
+
const capturingToken_1 = require("../../../platform/requestLogger/common/capturingToken");
|
|
59
|
+
const requestLogger_1 = require("../../../platform/requestLogger/node/requestLogger");
|
|
56
60
|
const snippyService_1 = require("../../../platform/snippy/common/snippyService");
|
|
57
61
|
const nullExperimentationService_1 = require("../../../platform/telemetry/common/nullExperimentationService");
|
|
58
62
|
const errors = __importStar(require("../../../util/common/errors"));
|
|
59
63
|
const result_1 = require("../../../util/common/result");
|
|
60
|
-
const tracing_1 = require("../../../util/common/tracing");
|
|
61
64
|
const assert_1 = require("../../../util/vs/base/common/assert");
|
|
62
65
|
const async_1 = require("../../../util/vs/base/common/async");
|
|
63
66
|
const cache_1 = require("../../../util/vs/base/common/cache");
|
|
@@ -69,11 +72,40 @@ const types_1 = require("../../../util/vs/base/common/types");
|
|
|
69
72
|
const uuid_1 = require("../../../util/vs/base/common/uuid");
|
|
70
73
|
const lineEdit_1 = require("../../../util/vs/editor/common/core/edits/lineEdit");
|
|
71
74
|
const stringEdit_1 = require("../../../util/vs/editor/common/core/edits/stringEdit");
|
|
75
|
+
const position_1 = require("../../../util/vs/editor/common/core/position");
|
|
72
76
|
const offsetRange_1 = require("../../../util/vs/editor/common/core/ranges/offsetRange");
|
|
77
|
+
const abstractText_1 = require("../../../util/vs/editor/common/core/text/abstractText");
|
|
73
78
|
const editRebase_1 = require("../common/editRebase");
|
|
74
79
|
const rejectionCollector_1 = require("../common/rejectionCollector");
|
|
75
80
|
const nextEditCache_1 = require("./nextEditCache");
|
|
76
81
|
const nextEditResult_1 = require("./nextEditResult");
|
|
82
|
+
/**
|
|
83
|
+
* Computes a reduced window range that encompasses both the original window (shrunk by one line
|
|
84
|
+
* on each end) and the full line where the cursor is located.
|
|
85
|
+
*
|
|
86
|
+
* This ensures the cache invalidation window always includes the cursor's line while trimming
|
|
87
|
+
* the edges of the original window.
|
|
88
|
+
*/
|
|
89
|
+
function computeReducedWindow(window, activeDocSelection, documentBeforeEdits) {
|
|
90
|
+
if (!activeDocSelection) {
|
|
91
|
+
return window;
|
|
92
|
+
}
|
|
93
|
+
const cursorOffset = activeDocSelection.endExclusive;
|
|
94
|
+
const t = documentBeforeEdits.getTransformer();
|
|
95
|
+
const cursorPosition = t.getPosition(cursorOffset);
|
|
96
|
+
const lineOffset = t.getOffset(cursorPosition.with(undefined, 1));
|
|
97
|
+
const lineEndOffset = t.getOffset(cursorPosition.with(undefined, t.getLineLength(cursorPosition.lineNumber) + 1));
|
|
98
|
+
const reducedOffset = t.getOffset(t.getPosition(window.start).delta(1));
|
|
99
|
+
const reducedEndPosition = t.getPosition(window.endExclusive).delta(-2);
|
|
100
|
+
const reducedEndOffset = t.getOffset(reducedEndPosition.column > 1 ? reducedEndPosition.with(undefined, t.getLineLength(reducedEndPosition.lineNumber) + 1) : reducedEndPosition);
|
|
101
|
+
return new offsetRange_1.OffsetRange(Math.min(reducedOffset, lineOffset), Math.max(reducedEndOffset, lineEndOffset));
|
|
102
|
+
}
|
|
103
|
+
function convertLineEditToEdit(nextLineEdit, projectedDocuments, docId) {
|
|
104
|
+
const doc = projectedDocuments.find(d => d.nextEditDoc.id === docId);
|
|
105
|
+
const rootedLineEdit = new rootedLineEdit_1.RootedLineEdit(doc.documentAfterEdits, nextLineEdit);
|
|
106
|
+
const suggestedEdit = rootedLineEdit.toEdit();
|
|
107
|
+
return suggestedEdit;
|
|
108
|
+
}
|
|
77
109
|
let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
78
110
|
get lastRejectionTime() {
|
|
79
111
|
return this._lastRejectionTime;
|
|
@@ -81,7 +113,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
81
113
|
get lastTriggerTime() {
|
|
82
114
|
return this._lastTriggerTime;
|
|
83
115
|
}
|
|
84
|
-
constructor(_workspace, _statelessNextEditProvider, _historyContextProvider, _xtabHistoryTracker, _debugRecorder, _configService, _snippyService, _logService, _expService) {
|
|
116
|
+
constructor(_workspace, _statelessNextEditProvider, _historyContextProvider, _xtabHistoryTracker, _debugRecorder, _configService, _snippyService, _logService, _expService, _requestLogger) {
|
|
85
117
|
super();
|
|
86
118
|
this._workspace = _workspace;
|
|
87
119
|
this._statelessNextEditProvider = _statelessNextEditProvider;
|
|
@@ -92,14 +124,23 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
92
124
|
this._snippyService = _snippyService;
|
|
93
125
|
this._logService = _logService;
|
|
94
126
|
this._expService = _expService;
|
|
127
|
+
this._requestLogger = _requestLogger;
|
|
95
128
|
this.ID = this._statelessNextEditProvider.ID;
|
|
96
|
-
this._rejectionCollector = this._register(new rejectionCollector_1.RejectionCollector(this._workspace,
|
|
129
|
+
this._rejectionCollector = this._register(new rejectionCollector_1.RejectionCollector(this._workspace, this._logService));
|
|
97
130
|
this._pendingStatelessNextEditRequest = null;
|
|
131
|
+
/**
|
|
132
|
+
* Tracks a speculative request for the post-edit document state.
|
|
133
|
+
* When a suggestion is shown, we speculatively fetch the next edit as if the user had already accepted.
|
|
134
|
+
* This allows reusing the in-flight request when the user actually accepts the suggestion.
|
|
135
|
+
*/
|
|
136
|
+
this._speculativePendingRequest = null;
|
|
98
137
|
this._lastShownTime = 0;
|
|
138
|
+
/** The requestId of the last shown suggestion. We store only the requestId (not the object) to avoid preventing garbage collection. */
|
|
139
|
+
this._lastShownSuggestionId = undefined;
|
|
99
140
|
this._lastRejectionTime = 0;
|
|
100
141
|
this._lastTriggerTime = 0;
|
|
101
142
|
this._shouldExpandEditWindow = false;
|
|
102
|
-
this.
|
|
143
|
+
this._logger = this._logService.createSubLogger(['NES', 'NextEditProvider']);
|
|
103
144
|
this._nextEditCache = new nextEditCache_1.NextEditCache(this._workspace, this._logService, this._configService, this._expService);
|
|
104
145
|
(0, observable_2.mapObservableArrayCached)(this, this._workspace.openDocuments, (doc, store) => {
|
|
105
146
|
store.add((0, observable_2.runOnChange)(doc.value, (value) => {
|
|
@@ -121,16 +162,15 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
121
162
|
const now = Date.now();
|
|
122
163
|
this._lastTriggerTime = now;
|
|
123
164
|
const sw = new stopwatch_1.StopWatch();
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
165
|
+
const logger = this._logger.createSubLogger(context.requestUuid.substring(4, 8))
|
|
166
|
+
.withExtraTarget(logService_1.LogTarget.fromCallback((_level, msg) => {
|
|
167
|
+
logContext.trace(`[${Math.floor(sw.elapsed()).toString().padStart(4, ' ')}ms] ${msg}`);
|
|
168
|
+
}));
|
|
129
169
|
const shouldExpandEditWindow = this._shouldExpandEditWindow;
|
|
130
170
|
logContext.setStatelessNextEditProviderId(this._statelessNextEditProvider.ID);
|
|
131
171
|
let result;
|
|
132
172
|
try {
|
|
133
|
-
result = await this._getNextEditCanThrow(docId, context, now, shouldExpandEditWindow,
|
|
173
|
+
result = await this._getNextEditCanThrow(docId, context, now, shouldExpandEditWindow, logger, logContext, cancellationToken, telemetryBuilder);
|
|
134
174
|
}
|
|
135
175
|
catch (error) {
|
|
136
176
|
logContext.setError(error);
|
|
@@ -143,20 +183,20 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
143
183
|
this._lastNextEditResult = result;
|
|
144
184
|
return result;
|
|
145
185
|
}
|
|
146
|
-
async _getNextEditCanThrow(docId, context, triggerTime, shouldExpandEditWindow,
|
|
147
|
-
const
|
|
148
|
-
|
|
186
|
+
async _getNextEditCanThrow(docId, context, triggerTime, shouldExpandEditWindow, parentLogger, logContext, cancellationToken, telemetryBuilder) {
|
|
187
|
+
const logger = parentLogger.createSubLogger('_getNextEdit');
|
|
188
|
+
logger.trace(`invoked with trigger id = ${context.changeHint === undefined ? 'undefined' : `uuid = ${context.changeHint.data.uuid}, reason = ${context.changeHint.data.reason}`}`);
|
|
149
189
|
const doc = this._workspace.getDocument(docId);
|
|
150
190
|
if (!doc) {
|
|
151
|
-
|
|
191
|
+
logger.trace(`Document "${docId.baseName}" not found`);
|
|
152
192
|
throw new errors_1.BugIndicatingError(`Document "${docId.baseName}" not found`);
|
|
153
193
|
}
|
|
154
194
|
const documentAtInvocationTime = doc.value.get();
|
|
155
195
|
const selections = doc.selection.get();
|
|
156
196
|
const nesConfigs = this.determineNesConfigs(telemetryBuilder, logContext);
|
|
157
|
-
const cachedEdit = this._nextEditCache.lookupNextEdit(docId, documentAtInvocationTime, selections
|
|
197
|
+
const cachedEdit = this._nextEditCache.lookupNextEdit(docId, documentAtInvocationTime, selections);
|
|
158
198
|
if (cachedEdit?.rejected) {
|
|
159
|
-
|
|
199
|
+
logger.trace('cached edit was previously rejected');
|
|
160
200
|
telemetryBuilder.setStatus('previouslyRejectedCache');
|
|
161
201
|
telemetryBuilder.setWasPreviouslyRejected();
|
|
162
202
|
const nextEditResult = new nextEditResult_1.NextEditResult(logContext.requestId, cachedEdit.source, undefined);
|
|
@@ -170,7 +210,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
170
210
|
let isRebasedCachedEdit = false;
|
|
171
211
|
let isSubsequentCachedEdit = false;
|
|
172
212
|
if (cachedEdit) {
|
|
173
|
-
|
|
213
|
+
logger.trace('using cached edit');
|
|
174
214
|
const actualEdit = cachedEdit.rebasedEdit || cachedEdit.edit;
|
|
175
215
|
if (actualEdit) {
|
|
176
216
|
edit = { actualEdit, isFromCursorJump: cachedEdit.isFromCursorJump };
|
|
@@ -187,21 +227,21 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
187
227
|
logContext.recordingBookmark = req.log.recordingBookmark;
|
|
188
228
|
}
|
|
189
229
|
else {
|
|
190
|
-
|
|
230
|
+
logger.trace(`fetching next edit with shouldExpandEditWindow=${shouldExpandEditWindow}`);
|
|
191
231
|
const providerRequestStartDateTime = (this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsDebounceUseCoreRequestTime, this._expService)
|
|
192
232
|
? (context.requestIssuedDateTime ?? undefined)
|
|
193
233
|
: undefined);
|
|
194
234
|
req = new NextEditFetchRequest(context.requestUuid, logContext, providerRequestStartDateTime);
|
|
195
235
|
telemetryBuilder.setHeaderRequestId(req.headerRequestId);
|
|
196
236
|
const startVersion = doc.value.get();
|
|
197
|
-
|
|
198
|
-
const result = await this.fetchNextEdit(req, doc, nesConfigs, shouldExpandEditWindow,
|
|
199
|
-
|
|
237
|
+
logger.trace('awaiting firstEdit promise');
|
|
238
|
+
const result = await this.fetchNextEdit(req, doc, nesConfigs, shouldExpandEditWindow, logger, telemetryBuilder, cancellationToken);
|
|
239
|
+
logger.trace('resolved firstEdit promise');
|
|
200
240
|
const latency = `First edit latency: ${Date.now() - this._lastTriggerTime} ms`;
|
|
201
241
|
logContext.addLog(latency);
|
|
202
|
-
|
|
242
|
+
logger.trace(latency);
|
|
203
243
|
if (result.isError()) {
|
|
204
|
-
|
|
244
|
+
logger.trace(`failed to fetch next edit ${result.err.toString()}`);
|
|
205
245
|
telemetryBuilder.setStatus(`noEdit:${result.err.kind}`);
|
|
206
246
|
error = result.err;
|
|
207
247
|
}
|
|
@@ -211,18 +251,18 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
211
251
|
currentDocument = targetDoc.value.get();
|
|
212
252
|
const docDidChange = targetDocumentId === doc.id && startVersion.value !== currentDocument.value;
|
|
213
253
|
if (docDidChange) {
|
|
214
|
-
|
|
254
|
+
logger.trace('document changed while fetching next edit');
|
|
215
255
|
telemetryBuilder.setStatus('docChanged');
|
|
216
256
|
logContext.setIsSkipped();
|
|
217
257
|
}
|
|
218
258
|
else {
|
|
219
259
|
const suggestedNextEdit = result.val.rebasedEdit || result.val.edit;
|
|
220
260
|
if (!suggestedNextEdit) {
|
|
221
|
-
|
|
261
|
+
logger.trace('empty edits');
|
|
222
262
|
telemetryBuilder.setStatus('emptyEdits');
|
|
223
263
|
}
|
|
224
264
|
else {
|
|
225
|
-
|
|
265
|
+
logger.trace('fetch succeeded');
|
|
226
266
|
logContext.setResponseResults([suggestedNextEdit]); // TODO: other streamed edits?
|
|
227
267
|
edit = { actualEdit: suggestedNextEdit, isFromCursorJump: result.val.isFromCursorJump };
|
|
228
268
|
}
|
|
@@ -230,7 +270,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
230
270
|
}
|
|
231
271
|
}
|
|
232
272
|
if (error instanceof statelessNextEditProvider_1.NoNextEditReason.FetchFailure || error instanceof statelessNextEditProvider_1.NoNextEditReason.Unexpected) {
|
|
233
|
-
|
|
273
|
+
logger.trace(`has throwing error: ${error.error}`);
|
|
234
274
|
throw error.error;
|
|
235
275
|
}
|
|
236
276
|
else if (error instanceof statelessNextEditProvider_1.NoNextEditReason.NoSuggestions) {
|
|
@@ -244,17 +284,17 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
244
284
|
}
|
|
245
285
|
const emptyResult = new nextEditResult_1.NextEditResult(logContext.requestId, req, undefined);
|
|
246
286
|
if (!edit) {
|
|
247
|
-
|
|
287
|
+
logger.trace('had no edit');
|
|
248
288
|
// telemetry builder status must've been set earlier
|
|
249
289
|
return emptyResult;
|
|
250
290
|
}
|
|
251
291
|
if (cancellationToken.isCancellationRequested) {
|
|
252
|
-
|
|
292
|
+
logger.trace('cancelled');
|
|
253
293
|
telemetryBuilder.setStatus(`noEdit:gotCancelled`);
|
|
254
294
|
return emptyResult;
|
|
255
295
|
}
|
|
256
|
-
if (this._rejectionCollector.isRejected(targetDocumentId, edit.actualEdit) || currentDocument && this._nextEditCache.isRejectedNextEdit(targetDocumentId, currentDocument, edit.actualEdit
|
|
257
|
-
|
|
296
|
+
if (this._rejectionCollector.isRejected(targetDocumentId, edit.actualEdit) || currentDocument && this._nextEditCache.isRejectedNextEdit(targetDocumentId, currentDocument, edit.actualEdit)) {
|
|
297
|
+
logger.trace('edit was previously rejected');
|
|
258
298
|
telemetryBuilder.setStatus('previouslyRejected');
|
|
259
299
|
telemetryBuilder.setWasPreviouslyRejected();
|
|
260
300
|
return emptyResult;
|
|
@@ -265,16 +305,16 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
265
305
|
const showRangePreference = this._statelessNextEditProvider.showNextEditPreference ?? "aroundEdit" /* ShowNextEditPreference.AroundEdit */;
|
|
266
306
|
const nextEditResult = new nextEditResult_1.NextEditResult(logContext.requestId, req, { edit: edit.actualEdit, isFromCursorJump: edit.isFromCursorJump, showRangePreference, documentBeforeEdits: currentDocument, targetDocumentId });
|
|
267
307
|
telemetryBuilder.setHasNextEdit(true);
|
|
268
|
-
const delay = this.computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay: context.enforceCacheDelay },
|
|
308
|
+
const delay = this.computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay: context.enforceCacheDelay }, logger);
|
|
269
309
|
if (delay > 0) {
|
|
270
310
|
await (0, async_1.timeout)(delay);
|
|
271
311
|
if (cancellationToken.isCancellationRequested) {
|
|
272
|
-
|
|
312
|
+
logger.trace('cancelled');
|
|
273
313
|
telemetryBuilder.setStatus(`noEdit:gotCancelled`);
|
|
274
314
|
return emptyResult;
|
|
275
315
|
}
|
|
276
316
|
}
|
|
277
|
-
|
|
317
|
+
logger.trace('returning next edit result');
|
|
278
318
|
return nextEditResult;
|
|
279
319
|
}
|
|
280
320
|
determineNesConfigs(telemetryBuilder, logContext) {
|
|
@@ -299,9 +339,9 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
299
339
|
documentAfterEdits: nextEditDoc.documentAfterEdits,
|
|
300
340
|
};
|
|
301
341
|
}
|
|
302
|
-
async fetchNextEdit(req, doc, nesConfigs, shouldExpandEditWindow,
|
|
342
|
+
async fetchNextEdit(req, doc, nesConfigs, shouldExpandEditWindow, parentLogger, telemetryBuilder, cancellationToken) {
|
|
303
343
|
const curDocId = doc.id;
|
|
304
|
-
const
|
|
344
|
+
const logger = parentLogger.createSubLogger('fetchNextEdit');
|
|
305
345
|
const historyContext = this._historyContextProvider.getHistoryContext(curDocId);
|
|
306
346
|
if (!historyContext) {
|
|
307
347
|
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Unexpected(new Error('DocumentMissingInHistoryContext')));
|
|
@@ -310,45 +350,60 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
310
350
|
const selectionAtInvocationTime = doc.selection.get();
|
|
311
351
|
const logContext = req.log;
|
|
312
352
|
logContext.setRecentEdit(historyContext);
|
|
353
|
+
// Check if we can reuse the regular pending request
|
|
313
354
|
const pendingRequestStillCurrent = documentAtInvocationTime.value === this._pendingStatelessNextEditRequest?.documentBeforeEdits.value;
|
|
314
355
|
const existingNextEditRequest = (pendingRequestStillCurrent || nesConfigs.isAsyncCompletions) && !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
315
356
|
&& this._pendingStatelessNextEditRequest || undefined;
|
|
316
|
-
if (
|
|
357
|
+
// Check if we can reuse the speculative pending request (from when a suggestion was shown)
|
|
358
|
+
const speculativeRequestMatches = this._speculativePendingRequest?.postEditContent === documentAtInvocationTime.value
|
|
359
|
+
&& !this._speculativePendingRequest.request.cancellationTokenSource.token.isCancellationRequested;
|
|
360
|
+
const speculativeRequest = speculativeRequestMatches ? this._speculativePendingRequest?.request : undefined;
|
|
361
|
+
// Prefer speculative request if it matches (it was specifically created for this post-edit state)
|
|
362
|
+
const requestToReuse = speculativeRequest ?? existingNextEditRequest;
|
|
363
|
+
if (requestToReuse) {
|
|
317
364
|
// Nice! No need to make another request, we can reuse the result from a pending request.
|
|
318
|
-
|
|
319
|
-
|
|
365
|
+
if (speculativeRequest) {
|
|
366
|
+
logger.trace(`reusing speculative pending request (opportunityId=${speculativeRequest.opportunityId}, headerRequestId=${speculativeRequest.headerRequestId})`);
|
|
367
|
+
// Clear the speculative request since we're using it
|
|
368
|
+
this._speculativePendingRequest = null;
|
|
369
|
+
}
|
|
370
|
+
const nextEditResult = await this._joinNextEditRequest(requestToReuse, telemetryBuilder, logContext, cancellationToken);
|
|
371
|
+
const requestStillCurrent = speculativeRequest
|
|
372
|
+
? speculativeRequestMatches // For speculative, we already checked it matches
|
|
373
|
+
: pendingRequestStillCurrent;
|
|
374
|
+
if (requestStillCurrent) {
|
|
320
375
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
321
|
-
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit :
|
|
376
|
+
return nextEditResult.nextEdit.isError() ? nextEditResult.nextEdit : requestToReuse.firstEdit.p;
|
|
322
377
|
}
|
|
323
378
|
else {
|
|
324
379
|
// Needs rebasing.
|
|
325
|
-
const cacheResult = await
|
|
380
|
+
const cacheResult = await requestToReuse.firstEdit.p;
|
|
326
381
|
if (cacheResult.isOk() && cacheResult.val.edit) {
|
|
327
|
-
const rebasedCachedEdit = this._nextEditCache.tryRebaseCacheEntry(cacheResult.val, documentAtInvocationTime, selectionAtInvocationTime
|
|
382
|
+
const rebasedCachedEdit = this._nextEditCache.tryRebaseCacheEntry(cacheResult.val, documentAtInvocationTime, selectionAtInvocationTime);
|
|
328
383
|
if (rebasedCachedEdit) {
|
|
329
384
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
330
385
|
return result_1.Result.ok(rebasedCachedEdit);
|
|
331
386
|
}
|
|
332
387
|
}
|
|
333
388
|
if (cancellationToken.isCancellationRequested) {
|
|
334
|
-
|
|
389
|
+
logger.trace('document changed after rebase failed');
|
|
335
390
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
336
391
|
return result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.GotCancelled('afterFailedRebase'));
|
|
337
392
|
}
|
|
338
393
|
// Rebase failed (or result had error). Check if there is a new pending request. Otherwise continue with a new request below.
|
|
339
|
-
const
|
|
340
|
-
const existingNextEditRequest2 =
|
|
394
|
+
const pendingRequestStillCurrent2 = documentAtInvocationTime.value === this._pendingStatelessNextEditRequest?.documentBeforeEdits.value;
|
|
395
|
+
const existingNextEditRequest2 = pendingRequestStillCurrent2 && !this._pendingStatelessNextEditRequest?.cancellationTokenSource.token.isCancellationRequested
|
|
341
396
|
&& this._pendingStatelessNextEditRequest || undefined;
|
|
342
397
|
if (existingNextEditRequest2) {
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
telemetryBuilder.setStatelessNextEditTelemetry(
|
|
346
|
-
return
|
|
398
|
+
logger.trace('reusing 2nd existing next edit request after rebase failed');
|
|
399
|
+
const nextEditResult2 = await this._joinNextEditRequest(existingNextEditRequest2, telemetryBuilder, logContext, cancellationToken);
|
|
400
|
+
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult2.telemetry);
|
|
401
|
+
return nextEditResult2.nextEdit.isError() ? nextEditResult2.nextEdit : existingNextEditRequest2.firstEdit.p;
|
|
347
402
|
}
|
|
348
|
-
|
|
403
|
+
logger.trace('creating new next edit request after rebase failed');
|
|
349
404
|
}
|
|
350
405
|
}
|
|
351
|
-
const res = await this._executeNewNextEditRequest(req, doc, historyContext, nesConfigs, shouldExpandEditWindow,
|
|
406
|
+
const res = await this._executeNewNextEditRequest(req, doc, historyContext, nesConfigs, shouldExpandEditWindow, logger, telemetryBuilder, cancellationToken);
|
|
352
407
|
const nextEditRequest = res.nextEditRequest;
|
|
353
408
|
const nextEditResult = res.nextEditResult;
|
|
354
409
|
telemetryBuilder.setStatelessNextEditTelemetry(nextEditResult.telemetry);
|
|
@@ -356,7 +411,7 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
356
411
|
}
|
|
357
412
|
async _joinNextEditRequest(nextEditRequest, telemetryBuilder, logContext, cancellationToken) {
|
|
358
413
|
// TODO: Will the telemetry look alright in this case?
|
|
359
|
-
telemetryBuilder.setHeaderRequestId(nextEditRequest.
|
|
414
|
+
telemetryBuilder.setHeaderRequestId(nextEditRequest.headerRequestId);
|
|
360
415
|
telemetryBuilder.setIsFromCache();
|
|
361
416
|
telemetryBuilder.setRequest(nextEditRequest);
|
|
362
417
|
logContext.setRequestInput(nextEditRequest);
|
|
@@ -369,21 +424,15 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
369
424
|
disp.dispose();
|
|
370
425
|
}
|
|
371
426
|
}
|
|
372
|
-
async _executeNewNextEditRequest(req, doc, historyContext, nesConfigs, shouldExpandEditWindow,
|
|
427
|
+
async _executeNewNextEditRequest(req, doc, historyContext, nesConfigs, shouldExpandEditWindow, parentLogger, telemetryBuilder, cancellationToken) {
|
|
373
428
|
const curDocId = doc.id;
|
|
374
|
-
const
|
|
429
|
+
const logger = parentLogger.createSubLogger('_executeNewNextEditRequest');
|
|
375
430
|
const recording = this._debugRecorder?.getRecentLog();
|
|
376
431
|
const logContext = req.log;
|
|
377
432
|
const activeDocAndIdx = assertDefined(historyContext.getDocumentAndIdx(curDocId));
|
|
378
433
|
const activeDocSelection = doc.selection.get()[0];
|
|
379
434
|
const projectedDocuments = historyContext.documents.map(doc => this._processDoc(doc));
|
|
380
435
|
const xtabEditHistory = this._xtabHistoryTracker.getHistory();
|
|
381
|
-
function convertLineEditToEdit(nextLineEdit, docId) {
|
|
382
|
-
const doc = projectedDocuments.find(d => d.nextEditDoc.id === docId);
|
|
383
|
-
const rootedLineEdit = new rootedLineEdit_1.RootedLineEdit(doc.documentAfterEdits, nextLineEdit);
|
|
384
|
-
const suggestedEdit = rootedLineEdit.toEdit();
|
|
385
|
-
return suggestedEdit;
|
|
386
|
-
}
|
|
387
436
|
const firstEdit = new async_1.DeferredPromise();
|
|
388
437
|
const nLinesEditWindow = (shouldExpandEditWindow
|
|
389
438
|
? this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAutoExpandEditWindowLines, this._expService)
|
|
@@ -416,123 +465,138 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
416
465
|
data.value.changes.forEach(edit => {
|
|
417
466
|
if (nextEditRequest.intermediateUserEdit && !edit.isEmpty()) {
|
|
418
467
|
nextEditRequest.intermediateUserEdit = nextEditRequest.intermediateUserEdit.compose(edit);
|
|
419
|
-
if (!(0, editRebase_1.checkEditConsistency)(nextEditRequest.documentBeforeEdits.value, nextEditRequest.intermediateUserEdit, data.value.value.value,
|
|
468
|
+
if (!(0, editRebase_1.checkEditConsistency)(nextEditRequest.documentBeforeEdits.value, nextEditRequest.intermediateUserEdit, data.value.value.value, logger)) {
|
|
420
469
|
nextEditRequest.intermediateUserEdit = undefined;
|
|
421
470
|
}
|
|
422
471
|
}
|
|
423
472
|
});
|
|
424
473
|
}) : undefined);
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
const { documentBeforeEdits, window } = result.err;
|
|
456
|
-
let reducedWindow = window;
|
|
457
|
-
if (activeDocSelection && window) {
|
|
458
|
-
const cursorOffset = activeDocSelection.endExclusive;
|
|
459
|
-
const t = documentBeforeEdits.getTransformer();
|
|
460
|
-
const cursorPosition = t.getPosition(cursorOffset);
|
|
461
|
-
const lineOffset = t.getOffset(cursorPosition.with(undefined, 1));
|
|
462
|
-
const lineEndOffset = t.getOffset(cursorPosition.with(undefined, t.getLineLength(cursorPosition.lineNumber) + 1));
|
|
463
|
-
const reducedOffset = t.getOffset(t.getPosition(window.start).delta(1));
|
|
464
|
-
const reducedEndPosition = t.getPosition(window.endExclusive).delta(-2);
|
|
465
|
-
const reducedEndOffset = t.getOffset(reducedEndPosition.column > 1 ? reducedEndPosition.with(undefined, t.getLineLength(reducedEndPosition.lineNumber) + 1) : reducedEndPosition);
|
|
466
|
-
reducedWindow = new offsetRange_1.OffsetRange(Math.min(reducedOffset, lineOffset), Math.max(reducedEndOffset, lineEndOffset));
|
|
467
|
-
}
|
|
468
|
-
this._nextEditCache.setNoNextEdit(curDocId, documentBeforeEdits, reducedWindow, req);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
{
|
|
472
|
-
disp.dispose();
|
|
473
|
-
removeFromPending();
|
|
474
|
-
}
|
|
475
|
-
if (!firstEdit.isSettled) {
|
|
476
|
-
firstEdit.complete(result);
|
|
477
|
-
}
|
|
478
|
-
return;
|
|
474
|
+
const statePerDoc = new cache_1.CachedFunction((id) => {
|
|
475
|
+
const doc = projectedDocuments.find(d => d.nextEditDoc.id === id);
|
|
476
|
+
if (!doc) {
|
|
477
|
+
throw new errors_1.BugIndicatingError();
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
docContents: doc.documentAfterEdits,
|
|
481
|
+
editsSoFar: stringEdit_1.StringEdit.empty,
|
|
482
|
+
nextEdits: [],
|
|
483
|
+
docId: id,
|
|
484
|
+
};
|
|
485
|
+
});
|
|
486
|
+
const editStream = this._statelessNextEditProvider.provideNextEdit(nextEditRequest, logger, logContext, nextEditRequest.cancellationTokenSource.token);
|
|
487
|
+
let ithEdit = -1;
|
|
488
|
+
const processEdit = (streamedEdit, telemetry) => {
|
|
489
|
+
++ithEdit;
|
|
490
|
+
const myLogger = logger.createSubLogger('processEdit');
|
|
491
|
+
myLogger.trace(`processing edit #${ithEdit} (starts at 0)`);
|
|
492
|
+
// reset shouldExpandEditWindow to false when we get any edit
|
|
493
|
+
myLogger.trace('resetting shouldExpandEditWindow to false due to receiving an edit');
|
|
494
|
+
this._shouldExpandEditWindow = false;
|
|
495
|
+
const targetDocState = statePerDoc.get(streamedEdit.targetDocument ?? curDocId);
|
|
496
|
+
const singleLineEdit = streamedEdit.edit;
|
|
497
|
+
const lineEdit = new lineEdit_1.LineEdit([singleLineEdit]);
|
|
498
|
+
const edit = convertLineEditToEdit(lineEdit, projectedDocuments, targetDocState.docId);
|
|
499
|
+
const rebasedEdit = edit.tryRebase(targetDocState.editsSoFar);
|
|
500
|
+
if (rebasedEdit === undefined) {
|
|
501
|
+
myLogger.trace(`edit ${ithEdit} is undefined after rebasing`);
|
|
502
|
+
if (!firstEdit.isSettled) {
|
|
503
|
+
firstEdit.complete(result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Uncategorized(new Error('Rebased edit is undefined'))));
|
|
479
504
|
}
|
|
480
|
-
|
|
481
|
-
|
|
505
|
+
return undefined;
|
|
506
|
+
}
|
|
507
|
+
targetDocState.editsSoFar = targetDocState.editsSoFar.compose(rebasedEdit);
|
|
508
|
+
let cachedEdit;
|
|
509
|
+
if (rebasedEdit.replacements.length === 0) {
|
|
510
|
+
myLogger.trace(`WARNING: ${ithEdit} has no edits`);
|
|
511
|
+
}
|
|
512
|
+
else if (rebasedEdit.replacements.length > 1) {
|
|
513
|
+
myLogger.trace(`WARNING: ${ithEdit} has ${rebasedEdit.replacements.length} edits, but expected only 1`);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
// populate the cache
|
|
517
|
+
const nextEditReplacement = rebasedEdit.replacements[0];
|
|
518
|
+
targetDocState.nextEdits.push(nextEditReplacement);
|
|
519
|
+
cachedEdit = this._nextEditCache.setKthNextEdit(targetDocState.docId, targetDocState.docContents, ithEdit === 0 ? streamedEdit.window : undefined, nextEditReplacement, ithEdit, ithEdit === 0 ? targetDocState.nextEdits : undefined, ithEdit === 0 ? nextEditRequest.intermediateUserEdit : undefined, req, { isFromCursorJump: streamedEdit.isFromCursorJump, originalEditWindow: streamedEdit.originalWindow });
|
|
520
|
+
myLogger.trace(`populated cache for ${ithEdit}`);
|
|
521
|
+
}
|
|
522
|
+
if (!firstEdit.isSettled) {
|
|
523
|
+
myLogger.trace('resolving firstEdit promise');
|
|
524
|
+
logContext.setResult(new rootedLineEdit_1.RootedLineEdit(targetDocState.docContents, lineEdit)); // this's correct without rebasing because this's the first edit
|
|
525
|
+
firstEdit.complete(cachedEdit ? result_1.Result.ok(cachedEdit) : result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Unexpected(new Error('No cached edit'))));
|
|
526
|
+
}
|
|
527
|
+
targetDocState.docContents = rebasedEdit.applyOnText(targetDocState.docContents);
|
|
528
|
+
return cachedEdit;
|
|
529
|
+
};
|
|
530
|
+
const handleStreamEnd = (completionReason, lastTelemetry) => {
|
|
531
|
+
const myLogger = logger.createSubLogger('streamEnd');
|
|
532
|
+
// if there was a request made, and it ended without any edits, reset shouldExpandEditWindow
|
|
533
|
+
const hadNoEdits = ithEdit === -1;
|
|
534
|
+
if (hadNoEdits && completionReason instanceof statelessNextEditProvider_1.NoNextEditReason.NoSuggestions) {
|
|
535
|
+
myLogger.trace('resetting shouldExpandEditWindow to false due to NoSuggestions');
|
|
482
536
|
this._shouldExpandEditWindow = false;
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
targetDocState.editsSoFar = targetDocState.editsSoFar.compose(rebasedEdit);
|
|
496
|
-
let cachedEdit;
|
|
497
|
-
if (rebasedEdit.replacements.length === 0) {
|
|
498
|
-
myTracer.trace(`WARNING: ${ithEdit} has no edits`);
|
|
499
|
-
}
|
|
500
|
-
else if (rebasedEdit.replacements.length > 1) {
|
|
501
|
-
myTracer.trace(`WARNING: ${ithEdit} has ${rebasedEdit.replacements.length} edits, but expected only 1`);
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
// populate the cache
|
|
505
|
-
const nextEdit = rebasedEdit.replacements[0];
|
|
506
|
-
targetDocState.nextEdits.push(nextEdit);
|
|
507
|
-
cachedEdit = this._nextEditCache.setKthNextEdit(targetDocState.docId, targetDocState.docContents, ithEdit === 0 ? result.val.window : undefined, nextEdit, ithEdit, ithEdit === 0 ? targetDocState.nextEdits : undefined, ithEdit === 0 ? nextEditRequest.intermediateUserEdit : undefined, req, { isFromCursorJump: result.val.isFromCursorJump });
|
|
508
|
-
myTracer.trace(`populated cache for ${ithEdit}`);
|
|
509
|
-
}
|
|
510
|
-
if (!firstEdit.isSettled) {
|
|
511
|
-
myTracer.trace('resolving firstEdit promise');
|
|
512
|
-
logContext.setResult(new rootedLineEdit_1.RootedLineEdit(targetDocState.docContents, lineEdit)); // this's correct without rebasing because this's the first edit
|
|
513
|
-
firstEdit.complete(cachedEdit ? result_1.Result.ok(cachedEdit) : result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Unexpected(new Error('No cached edit'))));
|
|
537
|
+
}
|
|
538
|
+
if (statePerDoc.get(curDocId).nextEdits.length) {
|
|
539
|
+
myLogger.trace(`${statePerDoc.get(curDocId).nextEdits.length} edits returned`);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
myLogger.trace(`no edit, reason: ${completionReason.kind}`);
|
|
543
|
+
if (completionReason instanceof statelessNextEditProvider_1.NoNextEditReason.NoSuggestions) {
|
|
544
|
+
const { documentBeforeEdits, window } = completionReason;
|
|
545
|
+
const reducedWindow = window ? computeReducedWindow(window, activeDocSelection, documentBeforeEdits) : undefined;
|
|
546
|
+
this._nextEditCache.setNoNextEdit(curDocId, documentBeforeEdits, reducedWindow, req);
|
|
514
547
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
548
|
+
}
|
|
549
|
+
if (!firstEdit.isSettled) {
|
|
550
|
+
firstEdit.complete(result_1.Result.error(completionReason));
|
|
551
|
+
}
|
|
552
|
+
const resultForTelemetry = statePerDoc.get(curDocId).nextEdits.length > 0
|
|
553
|
+
? result_1.Result.ok(undefined)
|
|
554
|
+
: result_1.Result.error(completionReason);
|
|
555
|
+
const result = new statelessNextEditProvider_1.StatelessNextEditResult(resultForTelemetry, lastTelemetry);
|
|
556
|
+
nextEditRequest.setResult(result);
|
|
557
|
+
disp.dispose();
|
|
558
|
+
removeFromPending();
|
|
559
|
+
return result;
|
|
518
560
|
};
|
|
519
|
-
const pushEdit = createPushEdit();
|
|
520
561
|
try {
|
|
521
|
-
|
|
522
|
-
|
|
562
|
+
let res = await editStream.next();
|
|
563
|
+
if (res.done) {
|
|
564
|
+
// Stream ended immediately without any edits
|
|
565
|
+
const completionReason = res.value.v;
|
|
566
|
+
nextEditResult = handleStreamEnd(completionReason, res.value.telemetryBuilder);
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
// Process first edit synchronously
|
|
570
|
+
const firstStreamedEdit = res.value.v;
|
|
571
|
+
const firstTelemetry = res.value.telemetryBuilder;
|
|
572
|
+
processEdit(firstStreamedEdit, firstTelemetry);
|
|
573
|
+
// Continue streaming remaining edits in the background (unawaited)
|
|
574
|
+
(async () => {
|
|
575
|
+
try {
|
|
576
|
+
res = await editStream.next();
|
|
577
|
+
while (!res.done) {
|
|
578
|
+
const streamedEdit = res.value.v;
|
|
579
|
+
processEdit(streamedEdit, res.value.telemetryBuilder);
|
|
580
|
+
res = await editStream.next();
|
|
581
|
+
}
|
|
582
|
+
// Stream completed
|
|
583
|
+
const completionReason = res.value.v;
|
|
584
|
+
handleStreamEnd(completionReason, res.value.telemetryBuilder);
|
|
585
|
+
}
|
|
586
|
+
catch (err) {
|
|
587
|
+
logger.trace(`Error while streaming further edits: ${errors.toString(err)}`);
|
|
588
|
+
const errorReason = new statelessNextEditProvider_1.NoNextEditReason.Unexpected(errors.fromUnknown(err));
|
|
589
|
+
handleStreamEnd(errorReason, firstTelemetry);
|
|
590
|
+
}
|
|
591
|
+
})();
|
|
592
|
+
// Return early with streaming result
|
|
593
|
+
nextEditResult = statelessNextEditProvider_1.StatelessNextEditResult.streaming(new statelessNextEditProvider_1.StatelessNextEditTelemetryBuilder(nextEditRequest.headerRequestId));
|
|
594
|
+
}
|
|
523
595
|
}
|
|
524
596
|
catch (err) {
|
|
525
597
|
nextEditRequest.setResultError(err);
|
|
526
598
|
throw err;
|
|
527
599
|
}
|
|
528
|
-
finally {
|
|
529
|
-
if (!nextEditResult || nextEditResult.nextEdit.isError()) {
|
|
530
|
-
// when streaming, we need to keep the response going unless UI cancels it
|
|
531
|
-
// if we remove it from pending here, when UI cancels, we cannot cancel it because we think that the request has finished
|
|
532
|
-
disp.dispose();
|
|
533
|
-
removeFromPending();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
600
|
return { nextEditRequest, nextEditResult };
|
|
537
601
|
}
|
|
538
602
|
_hookupCancellation(nextEditRequest, cancellationToken, attachedDisposable) {
|
|
@@ -575,9 +639,9 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
575
639
|
nextEditRequest.liveDependentants++;
|
|
576
640
|
return disposables;
|
|
577
641
|
}
|
|
578
|
-
computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay },
|
|
642
|
+
computeMinimumResponseDelay({ triggerTime, isRebasedCachedEdit, isSubsequentCachedEdit, enforceCacheDelay }, logger) {
|
|
579
643
|
if (!enforceCacheDelay) {
|
|
580
|
-
|
|
644
|
+
logger.trace('[minimumDelay] no minimum delay enforced due to enforceCacheDelay being false');
|
|
581
645
|
return 0;
|
|
582
646
|
}
|
|
583
647
|
const cacheDelay = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsCacheDelay, this._expService);
|
|
@@ -593,22 +657,251 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
593
657
|
const nextEditProviderCallLatency = Date.now() - triggerTime;
|
|
594
658
|
// if the provider call took longer than the minimum delay, we don't need to delay further
|
|
595
659
|
const delay = Math.max(0, minimumResponseDelay - nextEditProviderCallLatency);
|
|
596
|
-
|
|
660
|
+
logger.trace(`[minimumDelay] expected delay: ${minimumResponseDelay}ms, effective delay: ${delay}. isRebasedCachedEdit: ${isRebasedCachedEdit} (rebasedCacheDelay: ${rebasedCacheDelay}), isSubsequentCachedEdit: ${isSubsequentCachedEdit} (subsequentCacheDelay: ${subsequentCacheDelay})`);
|
|
597
661
|
return delay;
|
|
598
662
|
}
|
|
599
663
|
handleShown(suggestion) {
|
|
600
664
|
this._lastShownTime = Date.now();
|
|
665
|
+
this._lastShownSuggestionId = suggestion.requestId;
|
|
666
|
+
// Trigger speculative request for the post-edit document state
|
|
667
|
+
const speculativeRequestsEnabled = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsSpeculativeRequests, this._expService);
|
|
668
|
+
if (speculativeRequestsEnabled) {
|
|
669
|
+
void this._triggerSpeculativeRequest(suggestion);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
async _triggerSpeculativeRequest(suggestion) {
|
|
673
|
+
const logger = this._logger.createSubLogger('_triggerSpeculativeRequest');
|
|
674
|
+
const result = suggestion.result;
|
|
675
|
+
if (!result?.edit) {
|
|
676
|
+
logger.trace('no edit in suggestion result');
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const docId = result.targetDocumentId;
|
|
680
|
+
if (!docId) {
|
|
681
|
+
logger.trace('no target document ID in suggestion result');
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
// Compute the post-edit document content
|
|
685
|
+
const postEditContent = result.edit.replace(result.documentBeforeEdits.value);
|
|
686
|
+
const postEditCursorOffset = result.edit.replaceRange.endExclusive + result.edit.getLengthDelta();
|
|
687
|
+
const selections = [new offsetRange_1.OffsetRange(postEditCursorOffset, postEditCursorOffset)];
|
|
688
|
+
const rootedEdit = new edit_1.RootedEdit(result.documentBeforeEdits, new stringEdit_1.StringEdit([result.edit]));
|
|
689
|
+
const postEditContentST = new abstractText_1.StringText(postEditContent);
|
|
690
|
+
let cachedEdit = this._nextEditCache.lookupNextEdit(docId, postEditContentST, selections);
|
|
691
|
+
let shiftedSelection;
|
|
692
|
+
if (cachedEdit) {
|
|
693
|
+
// first cachedEdit should be without edits because of noSuggestions caching
|
|
694
|
+
if (cachedEdit.edit) {
|
|
695
|
+
logger.trace('already have cached edit for post-edit state');
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
else if (cachedEdit.editWindow) {
|
|
699
|
+
const trans = postEditContentST.getTransformer();
|
|
700
|
+
const endOfEditWindow = trans.getPosition(cachedEdit.editWindow.endExclusive - 1);
|
|
701
|
+
const shiftedCursorLineNumber = (endOfEditWindow.lineNumber + 1 < postEditContentST.lineRange.endLineNumberExclusive
|
|
702
|
+
? endOfEditWindow.lineNumber + 1
|
|
703
|
+
: endOfEditWindow.lineNumber);
|
|
704
|
+
const shiftedSelectionCursorOffset = trans.getOffset(new position_1.Position(shiftedCursorLineNumber, 1));
|
|
705
|
+
shiftedSelection = new offsetRange_1.OffsetRange(shiftedSelectionCursorOffset, shiftedSelectionCursorOffset);
|
|
706
|
+
cachedEdit = this._nextEditCache.lookupNextEdit(docId, postEditContentST, [shiftedSelection]);
|
|
707
|
+
if (cachedEdit?.edit) {
|
|
708
|
+
logger.trace('already have cached edit for post-edit state (after shifting selection)');
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
logger.trace('already have cached no-suggestions entry for post-edit state');
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
// Check if we already have a pending request for the post-edit state
|
|
718
|
+
if (this._pendingStatelessNextEditRequest?.documentBeforeEdits.value === postEditContent) {
|
|
719
|
+
logger.trace('already have pending request for post-edit state');
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
// Check if we already have a speculative request for this post-edit state
|
|
723
|
+
if (this._speculativePendingRequest?.postEditContent === postEditContent) {
|
|
724
|
+
logger.trace('already have speculative request for post-edit state');
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
// Get the document to trigger speculative fetch
|
|
728
|
+
// Note: targetDocumentId is defined when the suggestion targets a different document
|
|
729
|
+
// Otherwise, use the file path from the log context
|
|
730
|
+
const doc = this._workspace.getDocument(docId);
|
|
731
|
+
if (!doc) {
|
|
732
|
+
logger.trace('document not found for speculative request');
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
// Cancel any previous speculative request
|
|
736
|
+
this._speculativePendingRequest?.request.cancellationTokenSource.cancel();
|
|
737
|
+
this._speculativePendingRequest = null;
|
|
738
|
+
const historyContext = this._historyContextProvider.getHistoryContext(docId);
|
|
739
|
+
if (!historyContext) {
|
|
740
|
+
logger.trace('no history context for speculative request');
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
// Create a speculative request
|
|
744
|
+
// Use a dummy version since this is speculative and we don't have the actual post-edit version
|
|
745
|
+
const logContext = new inlineEditLogContext_1.InlineEditRequestLogContext(docId.uri, 0, undefined);
|
|
746
|
+
const req = new NextEditFetchRequest(`sp-${suggestion.source.opportunityId}`, logContext, undefined, `sp-${(0, uuid_1.generateUuid)()}`);
|
|
747
|
+
logger.trace(`triggering speculative request for post-edit state (opportunityId=${req.opportunityId}, headerRequestId=${req.headerRequestId})`);
|
|
748
|
+
logger.trace(`triggering speculative request for post-edit state (opportunityId=${req.opportunityId}, headerRequestId=${req.headerRequestId})`);
|
|
749
|
+
try {
|
|
750
|
+
const speculativeRequest = await this._createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, result.edit, logger);
|
|
751
|
+
if (speculativeRequest) {
|
|
752
|
+
this._speculativePendingRequest = {
|
|
753
|
+
request: speculativeRequest,
|
|
754
|
+
postEditContent,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
catch (e) {
|
|
759
|
+
logger.trace(`speculative request failed: ${errors.toString(e)}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Creates and starts a speculative request for the post-edit document state.
|
|
764
|
+
* The request will populate the cache so that when the user accepts the suggestion,
|
|
765
|
+
* the next NES request can reuse or find the result in cache.
|
|
766
|
+
*/
|
|
767
|
+
async _createSpeculativeRequest(req, doc, shiftedSelection, historyContext, postEditContent, rootedEdit, appliedEdit, parentLogger) {
|
|
768
|
+
const logger = parentLogger.createSubLogger('_createSpeculativeRequest');
|
|
769
|
+
const curDocId = doc.id;
|
|
770
|
+
const recording = this._debugRecorder?.getRecentLog();
|
|
771
|
+
const logContext = req.log;
|
|
772
|
+
const activeDocAndIdx = historyContext.getDocumentAndIdx(curDocId);
|
|
773
|
+
if (!activeDocAndIdx) {
|
|
774
|
+
logger.trace('active doc not found in history context');
|
|
775
|
+
return undefined;
|
|
776
|
+
}
|
|
777
|
+
// Create the post-edit document content
|
|
778
|
+
const postEditText = new abstractText_1.StringText(postEditContent);
|
|
779
|
+
// Process documents, but for the active document, use the post-edit state
|
|
780
|
+
const projectedDocuments = historyContext.documents.map(docHist => {
|
|
781
|
+
if (docHist.docId !== curDocId) {
|
|
782
|
+
return this._processDoc(docHist);
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
// For the active document, create a version representing post-edit state
|
|
786
|
+
// The "recent edit" from the model's perspective is the NES edit we just applied
|
|
787
|
+
const workspaceRoot = this._workspace.getWorkspaceRoot(curDocId);
|
|
788
|
+
const postEditEdit = new stringEdit_1.StringEdit([appliedEdit]);
|
|
789
|
+
const postEditLineEdit = rootedLineEdit_1.RootedLineEdit.fromEdit(new edit_1.RootedEdit(doc.value.get(), postEditEdit)).removeCommonSuffixPrefixLines().edit;
|
|
790
|
+
let selection = shiftedSelection;
|
|
791
|
+
if (selection === undefined) {
|
|
792
|
+
const appliedEditEndPos = postEditText.getTransformer().getPosition(appliedEdit.replaceRange.endExclusive + appliedEdit.getLengthDelta());
|
|
793
|
+
const pos = new position_1.Position(appliedEditEndPos.lineNumber, 1);
|
|
794
|
+
const offset = postEditText.getTransformer().getOffset(pos);
|
|
795
|
+
selection = new offsetRange_1.OffsetRange(offset, offset);
|
|
796
|
+
}
|
|
797
|
+
const nextEditDoc = new statelessNextEditProvider_1.StatelessNextEditDocument(curDocId, workspaceRoot, docHist.languageId, doc.value.get().getLines(), // lines before the NES edit
|
|
798
|
+
postEditLineEdit, // the NES edit as LineEdit
|
|
799
|
+
doc.value.get(), // document before NES edit
|
|
800
|
+
edit_1.Edits.single(postEditEdit), // the NES edit as Edits
|
|
801
|
+
selection);
|
|
802
|
+
return {
|
|
803
|
+
recentEdit: new edit_1.RootedEdit(doc.value.get(), postEditEdit),
|
|
804
|
+
nextEditDoc,
|
|
805
|
+
documentAfterEdits: postEditText,
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
const xtabEditHistory = this._xtabHistoryTracker.getHistory();
|
|
810
|
+
const suggestedEdit = { kind: 'edit', docId: curDocId, edit: rootedEdit };
|
|
811
|
+
xtabEditHistory.push(suggestedEdit);
|
|
812
|
+
const firstEdit = new async_1.DeferredPromise();
|
|
813
|
+
const nLinesEditWindow = this._configService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.InlineEditsAutoExpandEditWindowLines, this._expService);
|
|
814
|
+
const nextEditRequest = new statelessNextEditProvider_1.StatelessNextEditRequest(req.headerRequestId, req.opportunityId, postEditText, // documentBeforeEdits is the post-edit state
|
|
815
|
+
projectedDocuments.map(d => d.nextEditDoc), activeDocAndIdx.idx, xtabEditHistory, firstEdit, nLinesEditWindow, logContext, undefined, // recordingBookmark
|
|
816
|
+
recording, undefined);
|
|
817
|
+
logger.trace('starting speculative provider call');
|
|
818
|
+
// Start the provider call - this runs in the background and populates the cache
|
|
819
|
+
const label = `NES | spec | ${(0, path_1.basename)(doc.id.toUri().fsPath)} (v${doc.version})`;
|
|
820
|
+
const capturingToken = new capturingToken_1.CapturingToken(label, undefined, true, true);
|
|
821
|
+
void this._requestLogger.captureInvocation(capturingToken, () => this._runSpeculativeProviderCall(nextEditRequest, projectedDocuments, curDocId, req, logger));
|
|
822
|
+
return nextEditRequest;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Runs the provider call for a speculative request and caches results.
|
|
826
|
+
*/
|
|
827
|
+
async _runSpeculativeProviderCall(nextEditRequest, projectedDocuments, curDocId, req, parentLogger) {
|
|
828
|
+
const logger = parentLogger.createSubLogger('_runSpeculativeProviderCall');
|
|
829
|
+
const statePerDoc = new cache_1.CachedFunction((id) => {
|
|
830
|
+
const doc = projectedDocuments.find(d => d.nextEditDoc.id === id);
|
|
831
|
+
if (!doc) {
|
|
832
|
+
throw new errors_1.BugIndicatingError();
|
|
833
|
+
}
|
|
834
|
+
return {
|
|
835
|
+
docContents: doc.documentAfterEdits,
|
|
836
|
+
editsSoFar: stringEdit_1.StringEdit.empty,
|
|
837
|
+
nextEdits: [],
|
|
838
|
+
docId: id,
|
|
839
|
+
};
|
|
840
|
+
});
|
|
841
|
+
const logContext = req.log;
|
|
842
|
+
const editStream = this._statelessNextEditProvider.provideNextEdit(nextEditRequest, logger, logContext, nextEditRequest.cancellationTokenSource.token);
|
|
843
|
+
let ithEdit = -1;
|
|
844
|
+
try {
|
|
845
|
+
let res = await editStream.next();
|
|
846
|
+
if (res.done) {
|
|
847
|
+
nextEditRequest.firstEdit.complete(result_1.Result.error(res.value.v));
|
|
848
|
+
nextEditRequest.setResult(new statelessNextEditProvider_1.StatelessNextEditResult(result_1.Result.error(res.value.v), res.value.telemetryBuilder));
|
|
849
|
+
logger.trace('speculative request completed with no edits');
|
|
850
|
+
}
|
|
851
|
+
else {
|
|
852
|
+
(async () => {
|
|
853
|
+
while (!res.done) {
|
|
854
|
+
++ithEdit;
|
|
855
|
+
const streamedEdit = res.value.v;
|
|
856
|
+
const targetDocState = statePerDoc.get(streamedEdit.targetDocument ?? curDocId);
|
|
857
|
+
const singleLineEdit = streamedEdit.edit;
|
|
858
|
+
const lineEdit = new lineEdit_1.LineEdit([singleLineEdit]);
|
|
859
|
+
const edit = convertLineEditToEdit(lineEdit, projectedDocuments, targetDocState.docId);
|
|
860
|
+
const rebasedEdit = edit.tryRebase(targetDocState.editsSoFar);
|
|
861
|
+
if (rebasedEdit === undefined) {
|
|
862
|
+
logger.trace(`speculative edit ${ithEdit} rebasing failed`);
|
|
863
|
+
res = await editStream.next();
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
targetDocState.editsSoFar = targetDocState.editsSoFar.compose(rebasedEdit);
|
|
867
|
+
if (rebasedEdit.replacements.length === 1) {
|
|
868
|
+
const nextEditReplacement = rebasedEdit.replacements[0];
|
|
869
|
+
targetDocState.nextEdits.push(nextEditReplacement);
|
|
870
|
+
// Populate the cache with the speculative result
|
|
871
|
+
const cachedEdit = this._nextEditCache.setKthNextEdit(targetDocState.docId, targetDocState.docContents, ithEdit === 0 ? streamedEdit.window : undefined, nextEditReplacement, ithEdit, ithEdit === 0 ? targetDocState.nextEdits : undefined, undefined, // no userEditSince for speculative
|
|
872
|
+
req, { isFromCursorJump: streamedEdit.isFromCursorJump, originalEditWindow: streamedEdit.originalWindow });
|
|
873
|
+
if (!nextEditRequest.firstEdit.isSettled && cachedEdit) {
|
|
874
|
+
nextEditRequest.firstEdit.complete(result_1.Result.ok(cachedEdit));
|
|
875
|
+
nextEditRequest.setResult(new statelessNextEditProvider_1.StatelessNextEditResult(result_1.Result.ok(undefined), res.value.telemetryBuilder));
|
|
876
|
+
}
|
|
877
|
+
logger.trace(`cached speculative edit ${ithEdit}`);
|
|
878
|
+
}
|
|
879
|
+
targetDocState.docContents = rebasedEdit.applyOnText(targetDocState.docContents);
|
|
880
|
+
res = await editStream.next();
|
|
881
|
+
}
|
|
882
|
+
})().finally(() => {
|
|
883
|
+
if (!nextEditRequest.firstEdit.isSettled) {
|
|
884
|
+
nextEditRequest.firstEdit.complete(result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Uncategorized(new Error('Speculative request ended without edits'))));
|
|
885
|
+
nextEditRequest.setResult(new statelessNextEditProvider_1.StatelessNextEditResult(result_1.Result.error(new statelessNextEditProvider_1.NoNextEditReason.Uncategorized(new Error('Speculative request ended without edits'))), res.value.telemetryBuilder));
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
logger.trace(`speculative request completed with ${ithEdit + 1} edits`);
|
|
890
|
+
}
|
|
891
|
+
catch (e) {
|
|
892
|
+
logger.trace(`speculative provider call error: ${errors.toString(e)}`);
|
|
893
|
+
}
|
|
601
894
|
}
|
|
602
895
|
handleAcceptance(docId, suggestion) {
|
|
603
896
|
this.runSnippy(docId, suggestion);
|
|
604
897
|
this._statelessNextEditProvider.handleAcceptance?.();
|
|
605
|
-
const
|
|
898
|
+
const logger = this._logger.createSubLogger(suggestion.source.opportunityId.substring(4, 8)).createSubLogger('handleAcceptance');
|
|
606
899
|
if (suggestion === this._lastNextEditResult) {
|
|
607
|
-
|
|
900
|
+
logger.trace('setting shouldExpandEditWindow to true due to acceptance of last suggestion');
|
|
608
901
|
this._shouldExpandEditWindow = true;
|
|
609
902
|
}
|
|
610
903
|
else {
|
|
611
|
-
|
|
904
|
+
logger.trace('NOT setting shouldExpandEditWindow to true because suggestion is not the last suggestion');
|
|
612
905
|
}
|
|
613
906
|
}
|
|
614
907
|
handleRejection(docId, suggestion) {
|
|
@@ -623,7 +916,15 @@ let NextEditProvider = class NextEditProvider extends lifecycle_1.Disposable {
|
|
|
623
916
|
this._lastRejectionTime = Date.now();
|
|
624
917
|
this._statelessNextEditProvider.handleRejection?.();
|
|
625
918
|
}
|
|
626
|
-
handleIgnored(docId, suggestion, supersededBy) {
|
|
919
|
+
handleIgnored(docId, suggestion, supersededBy) {
|
|
920
|
+
// Check if this was the last shown suggestion
|
|
921
|
+
const wasShown = this._lastShownSuggestionId === suggestion.requestId;
|
|
922
|
+
const wasSuperseded = supersededBy !== undefined;
|
|
923
|
+
if (wasShown && !wasSuperseded) {
|
|
924
|
+
// Was shown to the user
|
|
925
|
+
this._statelessNextEditProvider.handleIgnored?.();
|
|
926
|
+
}
|
|
927
|
+
}
|
|
627
928
|
async runSnippy(docId, suggestion) {
|
|
628
929
|
if (suggestion.result === undefined || suggestion.result.edit === undefined) {
|
|
629
930
|
return;
|
|
@@ -640,7 +941,8 @@ exports.NextEditProvider = NextEditProvider = __decorate([
|
|
|
640
941
|
__param(5, configurationService_1.IConfigurationService),
|
|
641
942
|
__param(6, snippyService_1.ISnippyService),
|
|
642
943
|
__param(7, logService_1.ILogService),
|
|
643
|
-
__param(8, nullExperimentationService_1.IExperimentationService)
|
|
944
|
+
__param(8, nullExperimentationService_1.IExperimentationService),
|
|
945
|
+
__param(9, requestLogger_1.IRequestLogger)
|
|
644
946
|
], NextEditProvider);
|
|
645
947
|
function assertDefined(value) {
|
|
646
948
|
if (!value) {
|
|
@@ -649,11 +951,11 @@ function assertDefined(value) {
|
|
|
649
951
|
return value;
|
|
650
952
|
}
|
|
651
953
|
class NextEditFetchRequest {
|
|
652
|
-
constructor(opportunityId, log, providerRequestStartDateTime) {
|
|
954
|
+
constructor(opportunityId, log, providerRequestStartDateTime, headerRequestId = (0, uuid_1.generateUuid)()) {
|
|
653
955
|
this.opportunityId = opportunityId;
|
|
654
956
|
this.log = log;
|
|
655
957
|
this.providerRequestStartDateTime = providerRequestStartDateTime;
|
|
656
|
-
this.headerRequestId =
|
|
958
|
+
this.headerRequestId = headerRequestId;
|
|
657
959
|
}
|
|
658
960
|
}
|
|
659
961
|
exports.NextEditFetchRequest = NextEditFetchRequest;
|