@vscode/chat-lib 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
  2. package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
  3. package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
  4. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -0
  5. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
  6. package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -0
  7. package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
  8. package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
  9. package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
  10. package/dist/src/_internal/platform/env/common/envService.js +2 -1
  11. package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
  12. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
  13. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
  14. package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
  15. package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
  16. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
  17. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
  18. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
  19. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
  20. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
  21. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
  22. package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
  23. package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
  24. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
  25. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
  26. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
  27. package/dist/src/_internal/vscodeTypes.d.ts +4 -0
  28. package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
  29. package/dist/src/_internal/vscodeTypes.js +5 -1
  30. package/dist/src/_internal/vscodeTypes.js.map +1 -1
  31. package/dist/src/main.d.ts +5 -0
  32. package/dist/src/main.d.ts.map +1 -1
  33. package/dist/src/main.js +12 -0
  34. package/dist/src/main.js.map +1 -1
  35. package/dist/src/package.json +46 -19
  36. package/package.json +3 -6
  37. package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
  38. package/src/_internal/extension/common/constants.ts +0 -90
  39. package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
  40. package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
  41. package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
  42. package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
  43. package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
  44. package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
  45. package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
  46. package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
  47. package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
  48. package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
  49. package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
  50. package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
  51. package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
  52. package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
  53. package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
  54. package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
  55. package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
  56. package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
  57. package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
  58. package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
  59. package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
  60. package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
  61. package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
  62. package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
  63. package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
  64. package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
  65. package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
  66. package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
  67. package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
  68. package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
  69. package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
  70. package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
  71. package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
  72. package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
  73. package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
  74. package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
  75. package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
  76. package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
  77. package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
  78. package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
  79. package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
  80. package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
  81. package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
  82. package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
  83. package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
  84. package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
  85. package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
  86. package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
  87. package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
  88. package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
  89. package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
  90. package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
  91. package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
  92. package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
  93. package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
  94. package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
  95. package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
  96. package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
  97. package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
  98. package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
  99. package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
  100. package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
  101. package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
  102. package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
  103. package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
  104. package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
  105. package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
  106. package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
  107. package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
  108. package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
  109. package/src/_internal/platform/authentication/common/authentication.ts +0 -309
  110. package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
  111. package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
  112. package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
  113. package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
  114. package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
  115. package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
  116. package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
  117. package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
  118. package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
  119. package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
  120. package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
  121. package/src/_internal/platform/chat/common/interactionService.ts +0 -35
  122. package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
  123. package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
  124. package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
  125. package/src/_internal/platform/configuration/common/validator.ts +0 -242
  126. package/src/_internal/platform/diff/common/diffService.ts +0 -41
  127. package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
  128. package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
  129. package/src/_internal/platform/editing/common/abstractText.ts +0 -177
  130. package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
  131. package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
  132. package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
  133. package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
  134. package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
  135. package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
  136. package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
  137. package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
  138. package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
  139. package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
  140. package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
  141. package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
  142. package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
  143. package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
  144. package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
  145. package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
  146. package/src/_internal/platform/env/common/envService.ts +0 -134
  147. package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
  148. package/src/_internal/platform/env/common/packagejson.ts +0 -49
  149. package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
  150. package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
  151. package/src/_internal/platform/git/vscode/git.d.ts +0 -414
  152. package/src/_internal/platform/github/common/githubAPI.ts +0 -44
  153. package/src/_internal/platform/github/common/githubService.ts +0 -87
  154. package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
  155. package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
  156. package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
  157. package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
  158. package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
  159. package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
  160. package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
  161. package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
  162. package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
  163. package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
  164. package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
  165. package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
  166. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
  167. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
  168. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
  169. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
  170. package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
  171. package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
  172. package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
  173. package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
  174. package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
  175. package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
  176. package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
  177. package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
  178. package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
  179. package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
  180. package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
  181. package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
  182. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
  183. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
  184. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
  185. package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
  186. package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
  187. package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
  188. package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
  189. package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
  190. package/src/_internal/platform/log/common/logService.ts +0 -232
  191. package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
  192. package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
  193. package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
  194. package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
  195. package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
  196. package/src/_internal/platform/networking/common/fetch.ts +0 -349
  197. package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
  198. package/src/_internal/platform/networking/common/networking.ts +0 -442
  199. package/src/_internal/platform/networking/common/openai.ts +0 -273
  200. package/src/_internal/platform/networking/node/chatStream.ts +0 -137
  201. package/src/_internal/platform/networking/node/stream.ts +0 -749
  202. package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
  203. package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
  204. package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
  205. package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
  206. package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
  207. package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
  208. package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
  209. package/src/_internal/platform/notebook/common/helpers.ts +0 -212
  210. package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
  211. package/src/_internal/platform/openai/node/fetch.ts +0 -596
  212. package/src/_internal/platform/parser/node/nodes.ts +0 -190
  213. package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
  214. package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
  215. package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
  216. package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
  217. package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
  218. package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
  219. package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
  220. package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
  221. package/src/_internal/platform/thinking/common/thinking.ts +0 -61
  222. package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
  223. package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
  224. package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
  225. package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
  226. package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
  227. package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
  228. package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
  229. package/src/_internal/util/common/anomalyDetection.ts +0 -112
  230. package/src/_internal/util/common/arrays.ts +0 -81
  231. package/src/_internal/util/common/async.ts +0 -155
  232. package/src/_internal/util/common/cache.ts +0 -183
  233. package/src/_internal/util/common/crypto.ts +0 -41
  234. package/src/_internal/util/common/errors.ts +0 -22
  235. package/src/_internal/util/common/globals.d.ts +0 -12
  236. package/src/_internal/util/common/imageUtils.ts +0 -154
  237. package/src/_internal/util/common/languages.ts +0 -940
  238. package/src/_internal/util/common/notebooks.ts +0 -286
  239. package/src/_internal/util/common/result.ts +0 -71
  240. package/src/_internal/util/common/services.ts +0 -43
  241. package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
  242. package/src/_internal/util/common/test/shims/editing.ts +0 -233
  243. package/src/_internal/util/common/test/shims/enums.ts +0 -61
  244. package/src/_internal/util/common/test/shims/l10n.ts +0 -37
  245. package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
  246. package/src/_internal/util/common/test/shims/terminal.ts +0 -33
  247. package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
  248. package/src/_internal/util/common/time.ts +0 -31
  249. package/src/_internal/util/common/tokenizer.ts +0 -30
  250. package/src/_internal/util/common/tracing.ts +0 -52
  251. package/src/_internal/util/common/types.ts +0 -33
  252. package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
  253. package/src/_internal/util/node/worker.ts +0 -130
  254. package/src/_internal/util/vs/base/common/arrays.ts +0 -926
  255. package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
  256. package/src/_internal/util/vs/base/common/assert.ts +0 -89
  257. package/src/_internal/util/vs/base/common/async.ts +0 -2582
  258. package/src/_internal/util/vs/base/common/buffer.ts +0 -501
  259. package/src/_internal/util/vs/base/common/cache.ts +0 -122
  260. package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
  261. package/src/_internal/util/vs/base/common/charCode.ts +0 -452
  262. package/src/_internal/util/vs/base/common/codicons.ts +0 -66
  263. package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
  264. package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
  265. package/src/_internal/util/vs/base/common/collections.ts +0 -156
  266. package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
  267. package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
  268. package/src/_internal/util/vs/base/common/equals.ts +0 -148
  269. package/src/_internal/util/vs/base/common/errors.ts +0 -342
  270. package/src/_internal/util/vs/base/common/event.ts +0 -1782
  271. package/src/_internal/util/vs/base/common/extpath.ts +0 -425
  272. package/src/_internal/util/vs/base/common/filters.ts +0 -928
  273. package/src/_internal/util/vs/base/common/functional.ts +0 -34
  274. package/src/_internal/util/vs/base/common/glob.ts +0 -839
  275. package/src/_internal/util/vs/base/common/hash.ts +0 -326
  276. package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
  277. package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
  278. package/src/_internal/util/vs/base/common/iterator.ts +0 -196
  279. package/src/_internal/util/vs/base/common/lazy.ts +0 -59
  280. package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
  281. package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
  282. package/src/_internal/util/vs/base/common/map.ts +0 -954
  283. package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
  284. package/src/_internal/util/vs/base/common/mime.ts +0 -136
  285. package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
  286. package/src/_internal/util/vs/base/common/network.ts +0 -429
  287. package/src/_internal/util/vs/base/common/numbers.ts +0 -166
  288. package/src/_internal/util/vs/base/common/objects.ts +0 -242
  289. package/src/_internal/util/vs/base/common/observable.ts +0 -10
  290. package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
  291. package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
  292. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
  293. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
  294. package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
  295. package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
  296. package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
  297. package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
  298. package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
  299. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
  300. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
  301. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
  302. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
  303. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
  304. package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
  305. package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
  306. package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
  307. package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
  308. package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
  309. package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
  310. package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
  311. package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
  312. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
  313. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
  314. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
  315. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
  316. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
  317. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
  318. package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
  319. package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
  320. package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
  321. package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
  322. package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
  323. package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
  324. package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
  325. package/src/_internal/util/vs/base/common/path.ts +0 -1591
  326. package/src/_internal/util/vs/base/common/platform.ts +0 -282
  327. package/src/_internal/util/vs/base/common/process.ts +0 -78
  328. package/src/_internal/util/vs/base/common/resources.ts +0 -446
  329. package/src/_internal/util/vs/base/common/sequence.ts +0 -36
  330. package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
  331. package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
  332. package/src/_internal/util/vs/base/common/stream.ts +0 -792
  333. package/src/_internal/util/vs/base/common/strings.ts +0 -1364
  334. package/src/_internal/util/vs/base/common/symbols.ts +0 -11
  335. package/src/_internal/util/vs/base/common/themables.ts +0 -106
  336. package/src/_internal/util/vs/base/common/types.ts +0 -345
  337. package/src/_internal/util/vs/base/common/uint.ts +0 -61
  338. package/src/_internal/util/vs/base/common/uri.ts +0 -752
  339. package/src/_internal/util/vs/base/common/uuid.ts +0 -72
  340. package/src/_internal/util/vs/base-common.d.ts +0 -42
  341. package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
  342. package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
  343. package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
  344. package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
  345. package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
  346. package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
  347. package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
  348. package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
  349. package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
  350. package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
  351. package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
  352. package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
  353. package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
  354. package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
  355. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
  356. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
  357. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
  358. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
  359. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
  360. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
  361. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
  362. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
  363. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
  364. package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
  365. package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
  366. package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
  367. package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
  368. package/src/_internal/util/vs/nls.messages.ts +0 -21
  369. package/src/_internal/util/vs/nls.ts +0 -243
  370. package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
  371. package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
  372. package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
  373. package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
  374. package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
  375. package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
  376. package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
  377. package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
  378. package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
  379. package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
  380. package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
  381. package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
  382. package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
  383. package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
  384. package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
  385. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
  386. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
  387. package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
  388. package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
  389. package/src/_internal/vscodeTypes.ts +0 -100
  390. package/src/main.ts +0 -207
  391. package/src/package.json +0 -4063
@@ -1,928 +0,0 @@
1
- //!!! DO NOT modify, this file was COPIED from 'microsoft/vscode'
2
-
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License. See License.txt in the project root for license information.
6
- *--------------------------------------------------------------------------------------------*/
7
-
8
- import { CharCode } from './charCode';
9
- import { LRUCache } from './map';
10
- import { getKoreanAltChars } from './naturalLanguage/korean';
11
- import * as strings from './strings';
12
-
13
- export interface IFilter {
14
- // Returns null if word doesn't match.
15
- (word: string, wordToMatchAgainst: string): IMatch[] | null;
16
- }
17
-
18
- export interface IMatch {
19
- start: number;
20
- end: number;
21
- }
22
-
23
- // Combined filters
24
-
25
- /**
26
- * @returns A filter which combines the provided set
27
- * of filters with an or. The *first* filters that
28
- * matches defined the return value of the returned
29
- * filter.
30
- */
31
- export function or(...filter: IFilter[]): IFilter {
32
- return function (word: string, wordToMatchAgainst: string): IMatch[] | null {
33
- for (let i = 0, len = filter.length; i < len; i++) {
34
- const match = filter[i](word, wordToMatchAgainst);
35
- if (match) {
36
- return match;
37
- }
38
- }
39
- return null;
40
- };
41
- }
42
-
43
- // Prefix
44
-
45
- export const matchesStrictPrefix: IFilter = _matchesPrefix.bind(undefined, false);
46
- export const matchesPrefix: IFilter = _matchesPrefix.bind(undefined, true);
47
-
48
- function _matchesPrefix(ignoreCase: boolean, word: string, wordToMatchAgainst: string): IMatch[] | null {
49
- if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
50
- return null;
51
- }
52
-
53
- let matches: boolean;
54
- if (ignoreCase) {
55
- matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
56
- } else {
57
- matches = wordToMatchAgainst.indexOf(word) === 0;
58
- }
59
-
60
- if (!matches) {
61
- return null;
62
- }
63
-
64
- return word.length > 0 ? [{ start: 0, end: word.length }] : [];
65
- }
66
-
67
- // Contiguous Substring
68
-
69
- export function matchesContiguousSubString(word: string, wordToMatchAgainst: string): IMatch[] | null {
70
- const index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
71
- if (index === -1) {
72
- return null;
73
- }
74
-
75
- return [{ start: index, end: index + word.length }];
76
- }
77
-
78
- // Substring
79
-
80
- export function matchesSubString(word: string, wordToMatchAgainst: string): IMatch[] | null {
81
- return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
82
- }
83
-
84
- function _matchesSubString(word: string, wordToMatchAgainst: string, i: number, j: number): IMatch[] | null {
85
- if (i === word.length) {
86
- return [];
87
- } else if (j === wordToMatchAgainst.length) {
88
- return null;
89
- } else {
90
- if (word[i] === wordToMatchAgainst[j]) {
91
- let result: IMatch[] | null = null;
92
- if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
93
- return join({ start: j, end: j + 1 }, result);
94
- }
95
- return null;
96
- }
97
-
98
- return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
99
- }
100
- }
101
-
102
- // CamelCase
103
-
104
- function isLower(code: number): boolean {
105
- return CharCode.a <= code && code <= CharCode.z;
106
- }
107
-
108
- export function isUpper(code: number): boolean {
109
- return CharCode.A <= code && code <= CharCode.Z;
110
- }
111
-
112
- function isNumber(code: number): boolean {
113
- return CharCode.Digit0 <= code && code <= CharCode.Digit9;
114
- }
115
-
116
- function isWhitespace(code: number): boolean {
117
- return (
118
- code === CharCode.Space
119
- || code === CharCode.Tab
120
- || code === CharCode.LineFeed
121
- || code === CharCode.CarriageReturn
122
- );
123
- }
124
-
125
- const wordSeparators = new Set<number>();
126
- // These are chosen as natural word separators based on writen text.
127
- // It is a subset of the word separators used by the monaco editor.
128
- '()[]{}<>`\'"-/;:,.?!'
129
- .split('')
130
- .forEach(s => wordSeparators.add(s.charCodeAt(0)));
131
-
132
- function isWordSeparator(code: number): boolean {
133
- return isWhitespace(code) || wordSeparators.has(code);
134
- }
135
-
136
- function charactersMatch(codeA: number, codeB: number): boolean {
137
- return (codeA === codeB) || (isWordSeparator(codeA) && isWordSeparator(codeB));
138
- }
139
-
140
- const alternateCharsCache: Map<number, ArrayLike<number> | undefined> = new Map();
141
- /**
142
- * Gets alternative codes to the character code passed in. This comes in the
143
- * form of an array of character codes, all of which must match _in order_ to
144
- * successfully match.
145
- *
146
- * @param code The character code to check.
147
- */
148
- function getAlternateCodes(code: number): ArrayLike<number> | undefined {
149
- if (alternateCharsCache.has(code)) {
150
- return alternateCharsCache.get(code);
151
- }
152
-
153
- // NOTE: This function is written in such a way that it can be extended in
154
- // the future, but right now the return type takes into account it's only
155
- // supported by a single "alt codes provider".
156
- // `ArrayLike<ArrayLike<number>>` is a more appropriate type if changed.
157
- let result: ArrayLike<number> | undefined;
158
- const codes = getKoreanAltChars(code);
159
- if (codes) {
160
- result = codes;
161
- }
162
-
163
- alternateCharsCache.set(code, result);
164
- return result;
165
- }
166
-
167
- function isAlphanumeric(code: number): boolean {
168
- return isLower(code) || isUpper(code) || isNumber(code);
169
- }
170
-
171
- function join(head: IMatch, tail: IMatch[]): IMatch[] {
172
- if (tail.length === 0) {
173
- tail = [head];
174
- } else if (head.end === tail[0].start) {
175
- tail[0].start = head.start;
176
- } else {
177
- tail.unshift(head);
178
- }
179
- return tail;
180
- }
181
-
182
- function nextAnchor(camelCaseWord: string, start: number): number {
183
- for (let i = start; i < camelCaseWord.length; i++) {
184
- const c = camelCaseWord.charCodeAt(i);
185
- if (isUpper(c) || isNumber(c) || (i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1)))) {
186
- return i;
187
- }
188
- }
189
- return camelCaseWord.length;
190
- }
191
-
192
- function _matchesCamelCase(word: string, camelCaseWord: string, i: number, j: number): IMatch[] | null {
193
- if (i === word.length) {
194
- return [];
195
- } else if (j === camelCaseWord.length) {
196
- return null;
197
- } else if (word[i] !== camelCaseWord[j].toLowerCase()) {
198
- return null;
199
- } else {
200
- let result: IMatch[] | null = null;
201
- let nextUpperIndex = j + 1;
202
- result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
203
- while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
204
- result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
205
- nextUpperIndex++;
206
- }
207
- return result === null ? null : join({ start: j, end: j + 1 }, result);
208
- }
209
- }
210
-
211
- interface ICamelCaseAnalysis {
212
- upperPercent: number;
213
- lowerPercent: number;
214
- alphaPercent: number;
215
- numericPercent: number;
216
- }
217
-
218
- // Heuristic to avoid computing camel case matcher for words that don't
219
- // look like camelCaseWords.
220
- function analyzeCamelCaseWord(word: string): ICamelCaseAnalysis {
221
- let upper = 0, lower = 0, alpha = 0, numeric = 0, code = 0;
222
-
223
- for (let i = 0; i < word.length; i++) {
224
- code = word.charCodeAt(i);
225
-
226
- if (isUpper(code)) { upper++; }
227
- if (isLower(code)) { lower++; }
228
- if (isAlphanumeric(code)) { alpha++; }
229
- if (isNumber(code)) { numeric++; }
230
- }
231
-
232
- const upperPercent = upper / word.length;
233
- const lowerPercent = lower / word.length;
234
- const alphaPercent = alpha / word.length;
235
- const numericPercent = numeric / word.length;
236
-
237
- return { upperPercent, lowerPercent, alphaPercent, numericPercent };
238
- }
239
-
240
- function isUpperCaseWord(analysis: ICamelCaseAnalysis): boolean {
241
- const { upperPercent, lowerPercent } = analysis;
242
- return lowerPercent === 0 && upperPercent > 0.6;
243
- }
244
-
245
- function isCamelCaseWord(analysis: ICamelCaseAnalysis): boolean {
246
- const { upperPercent, lowerPercent, alphaPercent, numericPercent } = analysis;
247
- return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
248
- }
249
-
250
- // Heuristic to avoid computing camel case matcher for words that don't
251
- // look like camel case patterns.
252
- function isCamelCasePattern(word: string): boolean {
253
- let upper = 0, lower = 0, code = 0, whitespace = 0;
254
-
255
- for (let i = 0; i < word.length; i++) {
256
- code = word.charCodeAt(i);
257
-
258
- if (isUpper(code)) { upper++; }
259
- if (isLower(code)) { lower++; }
260
- if (isWhitespace(code)) { whitespace++; }
261
- }
262
-
263
- if ((upper === 0 || lower === 0) && whitespace === 0) {
264
- return word.length <= 30;
265
- } else {
266
- return upper <= 5;
267
- }
268
- }
269
-
270
- export function matchesCamelCase(word: string, camelCaseWord: string): IMatch[] | null {
271
- if (!camelCaseWord) {
272
- return null;
273
- }
274
-
275
- camelCaseWord = camelCaseWord.trim();
276
-
277
- if (camelCaseWord.length === 0) {
278
- return null;
279
- }
280
-
281
- if (!isCamelCasePattern(word)) {
282
- return null;
283
- }
284
-
285
- // TODO: Consider removing this check
286
- if (camelCaseWord.length > 60) {
287
- camelCaseWord = camelCaseWord.substring(0, 60);
288
- }
289
-
290
- const analysis = analyzeCamelCaseWord(camelCaseWord);
291
-
292
- if (!isCamelCaseWord(analysis)) {
293
- if (!isUpperCaseWord(analysis)) {
294
- return null;
295
- }
296
-
297
- camelCaseWord = camelCaseWord.toLowerCase();
298
- }
299
-
300
- let result: IMatch[] | null = null;
301
- let i = 0;
302
-
303
- word = word.toLowerCase();
304
- while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
305
- i = nextAnchor(camelCaseWord, i + 1);
306
- }
307
-
308
- return result;
309
- }
310
-
311
- // Matches beginning of words supporting non-ASCII languages
312
- // If `contiguous` is true then matches word with beginnings of the words in the target. E.g. "pul" will match "Git: Pull"
313
- // Otherwise also matches sub string of the word with beginnings of the words in the target. E.g. "gp" or "g p" will match "Git: Pull"
314
- // Useful in cases where the target is words (e.g. command labels)
315
-
316
- export function matchesWords(word: string, target: string, contiguous: boolean = false): IMatch[] | null {
317
- if (!target || target.length === 0) {
318
- return null;
319
- }
320
-
321
- let result: IMatch[] | null = null;
322
- let targetIndex = 0;
323
-
324
- word = word.toLowerCase();
325
- target = target.toLowerCase();
326
- while (targetIndex < target.length) {
327
- result = _matchesWords(word, target, 0, targetIndex, contiguous);
328
- if (result !== null) {
329
- break;
330
- }
331
- targetIndex = nextWord(target, targetIndex + 1);
332
- }
333
-
334
- return result;
335
- }
336
-
337
- function _matchesWords(word: string, target: string, wordIndex: number, targetIndex: number, contiguous: boolean): IMatch[] | null {
338
- let targetIndexOffset = 0;
339
-
340
- if (wordIndex === word.length) {
341
- return [];
342
- } else if (targetIndex === target.length) {
343
- return null;
344
- } else if (!charactersMatch(word.charCodeAt(wordIndex), target.charCodeAt(targetIndex))) {
345
- // Verify alternate characters before exiting
346
- const altChars = getAlternateCodes(word.charCodeAt(wordIndex));
347
- if (!altChars) {
348
- return null;
349
- }
350
- for (let k = 0; k < altChars.length; k++) {
351
- if (!charactersMatch(altChars[k], target.charCodeAt(targetIndex + k))) {
352
- return null;
353
- }
354
- }
355
- targetIndexOffset += altChars.length - 1;
356
- }
357
-
358
- let result: IMatch[] | null = null;
359
- let nextWordIndex = targetIndex + targetIndexOffset + 1;
360
- result = _matchesWords(word, target, wordIndex + 1, nextWordIndex, contiguous);
361
- if (!contiguous) {
362
- while (!result && (nextWordIndex = nextWord(target, nextWordIndex)) < target.length) {
363
- result = _matchesWords(word, target, wordIndex + 1, nextWordIndex, contiguous);
364
- nextWordIndex++;
365
- }
366
- }
367
-
368
- if (!result) {
369
- return null;
370
- }
371
-
372
- // If the characters don't exactly match, then they must be word separators (see charactersMatch(...)).
373
- // We don't want to include this in the matches but we don't want to throw the target out all together so we return `result`.
374
- if (word.charCodeAt(wordIndex) !== target.charCodeAt(targetIndex)) {
375
- // Verify alternate characters before exiting
376
- const altChars = getAlternateCodes(word.charCodeAt(wordIndex));
377
- if (!altChars) {
378
- return result;
379
- }
380
- for (let k = 0; k < altChars.length; k++) {
381
- if (altChars[k] !== target.charCodeAt(targetIndex + k)) {
382
- return result;
383
- }
384
- }
385
- }
386
-
387
- return join({ start: targetIndex, end: targetIndex + targetIndexOffset + 1 }, result);
388
- }
389
-
390
- function nextWord(word: string, start: number): number {
391
- for (let i = start; i < word.length; i++) {
392
- if (isWordSeparator(word.charCodeAt(i)) ||
393
- (i > 0 && isWordSeparator(word.charCodeAt(i - 1)))) {
394
- return i;
395
- }
396
- }
397
- return word.length;
398
- }
399
-
400
- // Fuzzy
401
-
402
- const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matchesContiguousSubString);
403
- const fuzzySeparateFilter = or(matchesPrefix, matchesCamelCase, matchesSubString);
404
- const fuzzyRegExpCache = new LRUCache<string, RegExp>(10000); // bounded to 10000 elements
405
-
406
- export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching = false): IMatch[] | null {
407
- if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
408
- return null; // return early for invalid input
409
- }
410
-
411
- // Form RegExp for wildcard matches
412
- let regexp = fuzzyRegExpCache.get(word);
413
- if (!regexp) {
414
- regexp = new RegExp(strings.convertSimple2RegExpPattern(word), 'i');
415
- fuzzyRegExpCache.set(word, regexp);
416
- }
417
-
418
- // RegExp Filter
419
- const match = regexp.exec(wordToMatchAgainst);
420
- if (match) {
421
- return [{ start: match.index, end: match.index + match[0].length }];
422
- }
423
-
424
- // Default Filter
425
- return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
426
- }
427
-
428
- /**
429
- * Match pattern against word in a fuzzy way. As in IntelliSense and faster and more
430
- * powerful than `matchesFuzzy`
431
- */
432
- export function matchesFuzzy2(pattern: string, word: string): IMatch[] | null {
433
- const score = fuzzyScore(pattern, pattern.toLowerCase(), 0, word, word.toLowerCase(), 0, { firstMatchCanBeWeak: true, boostFullMatch: true });
434
- return score ? createMatches(score) : null;
435
- }
436
-
437
- export function anyScore(pattern: string, lowPattern: string, patternPos: number, word: string, lowWord: string, wordPos: number): FuzzyScore {
438
- const max = Math.min(13, pattern.length);
439
- for (; patternPos < max; patternPos++) {
440
- const result = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, { firstMatchCanBeWeak: true, boostFullMatch: true });
441
- if (result) {
442
- return result;
443
- }
444
- }
445
- return [0, wordPos];
446
- }
447
-
448
- //#region --- fuzzyScore ---
449
-
450
- export function createMatches(score: undefined | FuzzyScore): IMatch[] {
451
- if (typeof score === 'undefined') {
452
- return [];
453
- }
454
- const res: IMatch[] = [];
455
- const wordPos = score[1];
456
- for (let i = score.length - 1; i > 1; i--) {
457
- const pos = score[i] + wordPos;
458
- const last = res[res.length - 1];
459
- if (last && last.end === pos) {
460
- last.end = pos + 1;
461
- } else {
462
- res.push({ start: pos, end: pos + 1 });
463
- }
464
- }
465
- return res;
466
- }
467
-
468
- const _maxLen = 128;
469
-
470
- function initTable() {
471
- const table: number[][] = [];
472
- const row: number[] = [];
473
- for (let i = 0; i <= _maxLen; i++) {
474
- row[i] = 0;
475
- }
476
- for (let i = 0; i <= _maxLen; i++) {
477
- table.push(row.slice(0));
478
- }
479
- return table;
480
- }
481
-
482
- function initArr(maxLen: number) {
483
- const row: number[] = [];
484
- for (let i = 0; i <= maxLen; i++) {
485
- row[i] = 0;
486
- }
487
- return row;
488
- }
489
-
490
- const _minWordMatchPos = initArr(2 * _maxLen); // min word position for a certain pattern position
491
- const _maxWordMatchPos = initArr(2 * _maxLen); // max word position for a certain pattern position
492
- const _diag = initTable(); // the length of a contiguous diagonal match
493
- const _table = initTable();
494
- const _arrows = <Arrow[][]>initTable();
495
- const _debug = false;
496
-
497
- function printTable(table: number[][], pattern: string, patternLen: number, word: string, wordLen: number): string {
498
- function pad(s: string, n: number, pad = ' ') {
499
- while (s.length < n) {
500
- s = pad + s;
501
- }
502
- return s;
503
- }
504
- let ret = ` | |${word.split('').map(c => pad(c, 3)).join('|')}\n`;
505
-
506
- for (let i = 0; i <= patternLen; i++) {
507
- if (i === 0) {
508
- ret += ' |';
509
- } else {
510
- ret += `${pattern[i - 1]}|`;
511
- }
512
- ret += table[i].slice(0, wordLen + 1).map(n => pad(n.toString(), 3)).join('|') + '\n';
513
- }
514
- return ret;
515
- }
516
-
517
- function printTables(pattern: string, patternStart: number, word: string, wordStart: number): void {
518
- pattern = pattern.substr(patternStart);
519
- word = word.substr(wordStart);
520
- console.log(printTable(_table, pattern, pattern.length, word, word.length));
521
- console.log(printTable(_arrows, pattern, pattern.length, word, word.length));
522
- console.log(printTable(_diag, pattern, pattern.length, word, word.length));
523
- }
524
-
525
- function isSeparatorAtPos(value: string, index: number): boolean {
526
- if (index < 0 || index >= value.length) {
527
- return false;
528
- }
529
- const code = value.codePointAt(index);
530
- switch (code) {
531
- case CharCode.Underline:
532
- case CharCode.Dash:
533
- case CharCode.Period:
534
- case CharCode.Space:
535
- case CharCode.Slash:
536
- case CharCode.Backslash:
537
- case CharCode.SingleQuote:
538
- case CharCode.DoubleQuote:
539
- case CharCode.Colon:
540
- case CharCode.DollarSign:
541
- case CharCode.LessThan:
542
- case CharCode.GreaterThan:
543
- case CharCode.OpenParen:
544
- case CharCode.CloseParen:
545
- case CharCode.OpenSquareBracket:
546
- case CharCode.CloseSquareBracket:
547
- case CharCode.OpenCurlyBrace:
548
- case CharCode.CloseCurlyBrace:
549
- return true;
550
- case undefined:
551
- return false;
552
- default:
553
- if (strings.isEmojiImprecise(code)) {
554
- return true;
555
- }
556
- return false;
557
- }
558
- }
559
-
560
- function isWhitespaceAtPos(value: string, index: number): boolean {
561
- if (index < 0 || index >= value.length) {
562
- return false;
563
- }
564
- const code = value.charCodeAt(index);
565
- switch (code) {
566
- case CharCode.Space:
567
- case CharCode.Tab:
568
- return true;
569
- default:
570
- return false;
571
- }
572
- }
573
-
574
- function isUpperCaseAtPos(pos: number, word: string, wordLow: string): boolean {
575
- return word[pos] !== wordLow[pos];
576
- }
577
-
578
- export function isPatternInWord(patternLow: string, patternPos: number, patternLen: number, wordLow: string, wordPos: number, wordLen: number, fillMinWordPosArr = false): boolean {
579
- while (patternPos < patternLen && wordPos < wordLen) {
580
- if (patternLow[patternPos] === wordLow[wordPos]) {
581
- if (fillMinWordPosArr) {
582
- // Remember the min word position for each pattern position
583
- _minWordMatchPos[patternPos] = wordPos;
584
- }
585
- patternPos += 1;
586
- }
587
- wordPos += 1;
588
- }
589
- return patternPos === patternLen; // pattern must be exhausted
590
- }
591
-
592
- const enum Arrow { Diag = 1, Left = 2, LeftLeft = 3 }
593
-
594
- /**
595
- * An array representing a fuzzy match.
596
- *
597
- * 0. the score
598
- * 1. the offset at which matching started
599
- * 2. `<match_pos_N>`
600
- * 3. `<match_pos_1>`
601
- * 4. `<match_pos_0>` etc
602
- */
603
- export type FuzzyScore = [score: number, wordStart: number, ...matches: number[]];
604
-
605
- export namespace FuzzyScore {
606
- /**
607
- * No matches and value `-100`
608
- */
609
- export const Default: FuzzyScore = ([-100, 0]);
610
-
611
- export function isDefault(score?: FuzzyScore): score is [-100, 0] {
612
- return !score || (score.length === 2 && score[0] === -100 && score[1] === 0);
613
- }
614
- }
615
-
616
- export abstract class FuzzyScoreOptions {
617
-
618
- static default = { boostFullMatch: true, firstMatchCanBeWeak: false };
619
-
620
- constructor(
621
- readonly firstMatchCanBeWeak: boolean,
622
- readonly boostFullMatch: boolean,
623
- ) { }
624
- }
625
-
626
- export interface FuzzyScorer {
627
- (pattern: string, lowPattern: string, patternPos: number, word: string, lowWord: string, wordPos: number, options?: FuzzyScoreOptions): FuzzyScore | undefined;
628
- }
629
-
630
- export function fuzzyScore(pattern: string, patternLow: string, patternStart: number, word: string, wordLow: string, wordStart: number, options: FuzzyScoreOptions = FuzzyScoreOptions.default): FuzzyScore | undefined {
631
-
632
- const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
633
- const wordLen = word.length > _maxLen ? _maxLen : word.length;
634
-
635
- if (patternStart >= patternLen || wordStart >= wordLen || (patternLen - patternStart) > (wordLen - wordStart)) {
636
- return undefined;
637
- }
638
-
639
- // Run a simple check if the characters of pattern occur
640
- // (in order) at all in word. If that isn't the case we
641
- // stop because no match will be possible
642
- if (!isPatternInWord(patternLow, patternStart, patternLen, wordLow, wordStart, wordLen, true)) {
643
- return undefined;
644
- }
645
-
646
- // Find the max matching word position for each pattern position
647
- // NOTE: the min matching word position was filled in above, in the `isPatternInWord` call
648
- _fillInMaxWordMatchPos(patternLen, wordLen, patternStart, wordStart, patternLow, wordLow);
649
-
650
- let row: number = 1;
651
- let column: number = 1;
652
- let patternPos = patternStart;
653
- let wordPos = wordStart;
654
-
655
- const hasStrongFirstMatch = [false];
656
-
657
- // There will be a match, fill in tables
658
- for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
659
-
660
- // Reduce search space to possible matching word positions and to possible access from next row
661
- const minWordMatchPos = _minWordMatchPos[patternPos];
662
- const maxWordMatchPos = _maxWordMatchPos[patternPos];
663
- const nextMaxWordMatchPos = (patternPos + 1 < patternLen ? _maxWordMatchPos[patternPos + 1] : wordLen);
664
-
665
- for (column = minWordMatchPos - wordStart + 1, wordPos = minWordMatchPos; wordPos < nextMaxWordMatchPos; column++, wordPos++) {
666
-
667
- let score = Number.MIN_SAFE_INTEGER;
668
- let canComeDiag = false;
669
-
670
- if (wordPos <= maxWordMatchPos) {
671
- score = _doScore(
672
- pattern, patternLow, patternPos, patternStart,
673
- word, wordLow, wordPos, wordLen, wordStart,
674
- _diag[row - 1][column - 1] === 0,
675
- hasStrongFirstMatch
676
- );
677
- }
678
-
679
- let diagScore = 0;
680
- if (score !== Number.MIN_SAFE_INTEGER) {
681
- canComeDiag = true;
682
- diagScore = score + _table[row - 1][column - 1];
683
- }
684
-
685
- const canComeLeft = wordPos > minWordMatchPos;
686
- const leftScore = canComeLeft ? _table[row][column - 1] + (_diag[row][column - 1] > 0 ? -5 : 0) : 0; // penalty for a gap start
687
-
688
- const canComeLeftLeft = wordPos > minWordMatchPos + 1 && _diag[row][column - 1] > 0;
689
- const leftLeftScore = canComeLeftLeft ? _table[row][column - 2] + (_diag[row][column - 2] > 0 ? -5 : 0) : 0; // penalty for a gap start
690
-
691
- if (canComeLeftLeft && (!canComeLeft || leftLeftScore >= leftScore) && (!canComeDiag || leftLeftScore >= diagScore)) {
692
- // always prefer choosing left left to jump over a diagonal because that means a match is earlier in the word
693
- _table[row][column] = leftLeftScore;
694
- _arrows[row][column] = Arrow.LeftLeft;
695
- _diag[row][column] = 0;
696
- } else if (canComeLeft && (!canComeDiag || leftScore >= diagScore)) {
697
- // always prefer choosing left since that means a match is earlier in the word
698
- _table[row][column] = leftScore;
699
- _arrows[row][column] = Arrow.Left;
700
- _diag[row][column] = 0;
701
- } else if (canComeDiag) {
702
- _table[row][column] = diagScore;
703
- _arrows[row][column] = Arrow.Diag;
704
- _diag[row][column] = _diag[row - 1][column - 1] + 1;
705
- } else {
706
- throw new Error(`not possible`);
707
- }
708
- }
709
- }
710
-
711
- if (_debug) {
712
- printTables(pattern, patternStart, word, wordStart);
713
- }
714
-
715
- if (!hasStrongFirstMatch[0] && !options.firstMatchCanBeWeak) {
716
- return undefined;
717
- }
718
-
719
- row--;
720
- column--;
721
-
722
- const result: FuzzyScore = [_table[row][column], wordStart];
723
-
724
- let backwardsDiagLength = 0;
725
- let maxMatchColumn = 0;
726
-
727
- while (row >= 1) {
728
- // Find the column where we go diagonally up
729
- let diagColumn = column;
730
- do {
731
- const arrow = _arrows[row][diagColumn];
732
- if (arrow === Arrow.LeftLeft) {
733
- diagColumn = diagColumn - 2;
734
- } else if (arrow === Arrow.Left) {
735
- diagColumn = diagColumn - 1;
736
- } else {
737
- // found the diagonal
738
- break;
739
- }
740
- } while (diagColumn >= 1);
741
-
742
- // Overturn the "forwards" decision if keeping the "backwards" diagonal would give a better match
743
- if (
744
- backwardsDiagLength > 1 // only if we would have a contiguous match of 3 characters
745
- && patternLow[patternStart + row - 1] === wordLow[wordStart + column - 1] // only if we can do a contiguous match diagonally
746
- && !isUpperCaseAtPos(diagColumn + wordStart - 1, word, wordLow) // only if the forwards chose diagonal is not an uppercase
747
- && backwardsDiagLength + 1 > _diag[row][diagColumn] // only if our contiguous match would be longer than the "forwards" contiguous match
748
- ) {
749
- diagColumn = column;
750
- }
751
-
752
- if (diagColumn === column) {
753
- // this is a contiguous match
754
- backwardsDiagLength++;
755
- } else {
756
- backwardsDiagLength = 1;
757
- }
758
-
759
- if (!maxMatchColumn) {
760
- // remember the last matched column
761
- maxMatchColumn = diagColumn;
762
- }
763
-
764
- row--;
765
- column = diagColumn - 1;
766
- result.push(column);
767
- }
768
-
769
- if (wordLen - wordStart === patternLen && options.boostFullMatch) {
770
- // the word matches the pattern with all characters!
771
- // giving the score a total match boost (to come up ahead other words)
772
- result[0] += 2;
773
- }
774
-
775
- // Add 1 penalty for each skipped character in the word
776
- const skippedCharsCount = maxMatchColumn - patternLen;
777
- result[0] -= skippedCharsCount;
778
-
779
- return result;
780
- }
781
-
782
- function _fillInMaxWordMatchPos(patternLen: number, wordLen: number, patternStart: number, wordStart: number, patternLow: string, wordLow: string) {
783
- let patternPos = patternLen - 1;
784
- let wordPos = wordLen - 1;
785
- while (patternPos >= patternStart && wordPos >= wordStart) {
786
- if (patternLow[patternPos] === wordLow[wordPos]) {
787
- _maxWordMatchPos[patternPos] = wordPos;
788
- patternPos--;
789
- }
790
- wordPos--;
791
- }
792
- }
793
-
794
- function _doScore(
795
- pattern: string, patternLow: string, patternPos: number, patternStart: number,
796
- word: string, wordLow: string, wordPos: number, wordLen: number, wordStart: number,
797
- newMatchStart: boolean,
798
- outFirstMatchStrong: boolean[],
799
- ): number {
800
- if (patternLow[patternPos] !== wordLow[wordPos]) {
801
- return Number.MIN_SAFE_INTEGER;
802
- }
803
-
804
- let score = 1;
805
- let isGapLocation = false;
806
- if (wordPos === (patternPos - patternStart)) {
807
- // common prefix: `foobar <-> foobaz`
808
- // ^^^^^
809
- score = pattern[patternPos] === word[wordPos] ? 7 : 5;
810
-
811
- } else if (isUpperCaseAtPos(wordPos, word, wordLow) && (wordPos === 0 || !isUpperCaseAtPos(wordPos - 1, word, wordLow))) {
812
- // hitting upper-case: `foo <-> forOthers`
813
- // ^^ ^
814
- score = pattern[patternPos] === word[wordPos] ? 7 : 5;
815
- isGapLocation = true;
816
-
817
- } else if (isSeparatorAtPos(wordLow, wordPos) && (wordPos === 0 || !isSeparatorAtPos(wordLow, wordPos - 1))) {
818
- // hitting a separator: `. <-> foo.bar`
819
- // ^
820
- score = 5;
821
-
822
- } else if (isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1)) {
823
- // post separator: `foo <-> bar_foo`
824
- // ^^^
825
- score = 5;
826
- isGapLocation = true;
827
- }
828
-
829
- if (score > 1 && patternPos === patternStart) {
830
- outFirstMatchStrong[0] = true;
831
- }
832
-
833
- if (!isGapLocation) {
834
- isGapLocation = isUpperCaseAtPos(wordPos, word, wordLow) || isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1);
835
- }
836
-
837
- //
838
- if (patternPos === patternStart) { // first character in pattern
839
- if (wordPos > wordStart) {
840
- // the first pattern character would match a word character that is not at the word start
841
- // so introduce a penalty to account for the gap preceding this match
842
- score -= isGapLocation ? 3 : 5;
843
- }
844
- } else {
845
- if (newMatchStart) {
846
- // this would be the beginning of a new match (i.e. there would be a gap before this location)
847
- score += isGapLocation ? 2 : 0;
848
- } else {
849
- // this is part of a contiguous match, so give it a slight bonus, but do so only if it would not be a preferred gap location
850
- score += isGapLocation ? 0 : 1;
851
- }
852
- }
853
-
854
- if (wordPos + 1 === wordLen) {
855
- // we always penalize gaps, but this gives unfair advantages to a match that would match the last character in the word
856
- // so pretend there is a gap after the last character in the word to normalize things
857
- score -= isGapLocation ? 3 : 5;
858
- }
859
-
860
- return score;
861
- }
862
-
863
- //#endregion
864
-
865
-
866
- //#region --- graceful ---
867
-
868
- export function fuzzyScoreGracefulAggressive(pattern: string, lowPattern: string, patternPos: number, word: string, lowWord: string, wordPos: number, options?: FuzzyScoreOptions): FuzzyScore | undefined {
869
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, options);
870
- }
871
-
872
- export function fuzzyScoreGraceful(pattern: string, lowPattern: string, patternPos: number, word: string, lowWord: string, wordPos: number, options?: FuzzyScoreOptions): FuzzyScore | undefined {
873
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, false, options);
874
- }
875
-
876
- function fuzzyScoreWithPermutations(pattern: string, lowPattern: string, patternPos: number, word: string, lowWord: string, wordPos: number, aggressive: boolean, options?: FuzzyScoreOptions): FuzzyScore | undefined {
877
- let top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, options);
878
-
879
- if (top && !aggressive) {
880
- // when using the original pattern yield a result we`
881
- // return it unless we are aggressive and try to find
882
- // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
883
- return top;
884
- }
885
-
886
- if (pattern.length >= 3) {
887
- // When the pattern is long enough then try a few (max 7)
888
- // permutations of the pattern to find a better match. The
889
- // permutations only swap neighbouring characters, e.g
890
- // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
891
- const tries = Math.min(7, pattern.length - 1);
892
- for (let movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
893
- const newPattern = nextTypoPermutation(pattern, movingPatternPos);
894
- if (newPattern) {
895
- const candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, options);
896
- if (candidate) {
897
- candidate[0] -= 3; // permutation penalty
898
- if (!top || candidate[0] > top[0]) {
899
- top = candidate;
900
- }
901
- }
902
- }
903
- }
904
- }
905
-
906
- return top;
907
- }
908
-
909
- function nextTypoPermutation(pattern: string, patternPos: number): string | undefined {
910
-
911
- if (patternPos + 1 >= pattern.length) {
912
- return undefined;
913
- }
914
-
915
- const swap1 = pattern[patternPos];
916
- const swap2 = pattern[patternPos + 1];
917
-
918
- if (swap1 === swap2) {
919
- return undefined;
920
- }
921
-
922
- return pattern.slice(0, patternPos)
923
- + swap2
924
- + swap1
925
- + pattern.slice(patternPos + 2);
926
- }
927
-
928
- //#endregion