@codingame/monaco-vscode-api 1.83.1 → 1.83.3-next.0

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 (233) hide show
  1. package/extensions.d.ts +3 -3
  2. package/extensions.js +31 -33
  3. package/l10n.d.ts +4 -0
  4. package/l10n.js +10 -0
  5. package/missing-services.js +4 -2
  6. package/monaco-editor-treemending.patch +12268 -1070
  7. package/monaco-treemending.js +8 -2
  8. package/package.json +8 -1
  9. package/service-override/extensions.js +2 -2
  10. package/service-override/layout.js +2 -2
  11. package/tools/l10n.js +177 -0
  12. package/tools.js +22 -1
  13. package/vscode/src/vs/base/browser/ui/menu/menubar.js +1 -1
  14. package/vscode/src/vs/base/browser/ui/splitview/paneview.js +2 -2
  15. package/vscode/src/vs/base/common/date.js +55 -55
  16. package/vscode/src/vs/base/common/jsonErrorMessages.js +10 -10
  17. package/vscode/src/vs/base/common/tfIdf.js +137 -0
  18. package/vscode/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +23 -0
  19. package/vscode/src/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +115 -0
  20. package/vscode/src/vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess.js +112 -0
  21. package/vscode/src/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess.js +334 -0
  22. package/vscode/src/vs/platform/dialogs/common/dialogs.js +10 -14
  23. package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +3 -0
  24. package/vscode/src/vs/platform/extensionManagement/common/extensionNls.js +2 -2
  25. package/vscode/src/vs/platform/files/common/fileService.js +28 -37
  26. package/vscode/src/vs/platform/files/common/files.js +6 -6
  27. package/vscode/src/vs/platform/files/common/io.js +2 -2
  28. package/vscode/src/vs/platform/keyboardLayout/common/keyboardConfig.js +3 -9
  29. package/vscode/src/vs/platform/quickinput/browser/commandsQuickAccess.js +300 -0
  30. package/vscode/src/vs/platform/quickinput/browser/helpQuickAccess.js +59 -0
  31. package/vscode/src/vs/platform/quickinput/browser/pickerQuickAccess.js +212 -0
  32. package/vscode/src/vs/platform/request/common/request.js +2 -2
  33. package/vscode/src/vs/platform/theme/common/tokenClassificationRegistry.js +42 -63
  34. package/vscode/src/vs/platform/workspaces/common/workspaces.js +15 -15
  35. package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +13 -32
  36. package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +2 -2
  37. package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +50 -52
  38. package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +58 -69
  39. package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +4 -5
  40. package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +38 -50
  41. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +23 -23
  42. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +21 -53
  43. package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +4 -4
  44. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +4 -5
  45. package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +6 -2
  46. package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +4 -2
  47. package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +1 -1
  48. package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +2 -12
  49. package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +15 -9
  50. package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +16 -20
  51. package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +6 -28
  52. package/vscode/src/vs/workbench/api/browser/statusBarExtensionPoint.js +60 -0
  53. package/vscode/src/vs/workbench/api/common/extHostChat.js +3 -3
  54. package/vscode/src/vs/workbench/api/common/extHostCommands.js +59 -65
  55. package/vscode/src/vs/workbench/api/common/extHostConsoleForwarder.js +8 -8
  56. package/vscode/src/vs/workbench/api/common/extHostDiagnostics.js +2 -6
  57. package/vscode/src/vs/workbench/api/common/extHostExtensionService.js +2 -2
  58. package/vscode/src/vs/workbench/api/common/extHostLanguageFeatures.js +150 -222
  59. package/vscode/src/vs/workbench/api/common/extHostLogService.js +2 -2
  60. package/vscode/src/vs/workbench/api/common/extHostNotebook.js +3 -3
  61. package/vscode/src/vs/workbench/api/common/extHostProgress.js +2 -6
  62. package/vscode/src/vs/workbench/api/common/extHostSCM.js +54 -58
  63. package/vscode/src/vs/workbench/api/common/extHostStatusBar.js +3 -7
  64. package/vscode/src/vs/workbench/api/common/extHostTelemetry.js +2 -6
  65. package/vscode/src/vs/workbench/api/common/extHostTerminalService.js +2 -6
  66. package/vscode/src/vs/workbench/api/common/extHostTreeViews.js +55 -57
  67. package/vscode/src/vs/workbench/api/common/extHostTunnelService.js +28 -28
  68. package/vscode/src/vs/workbench/api/common/extHostTypeConverters.js +265 -277
  69. package/vscode/src/vs/workbench/api/common/extHostWorkspace.js +2 -7
  70. package/vscode/src/vs/workbench/api/common/extensionHostMain.js +17 -19
  71. package/vscode/src/vs/workbench/api/common/jsonValidationExtensionPoint.js +9 -34
  72. package/vscode/src/vs/workbench/api/worker/extHostExtensionService.js +5 -5
  73. package/vscode/src/vs/workbench/browser/actions/layoutActions.js +898 -68
  74. package/vscode/src/vs/workbench/browser/actions/quickAccessActions.js +7 -7
  75. package/vscode/src/vs/workbench/browser/actions/windowActions.js +32 -38
  76. package/vscode/src/vs/workbench/browser/actions/workspaceActions.js +103 -13
  77. package/vscode/src/vs/workbench/browser/actions/workspaceCommands.js +2 -2
  78. package/vscode/src/vs/workbench/browser/editor.js +3 -3
  79. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions.js +12 -27
  80. package/vscode/src/vs/workbench/browser/parts/compositeBarActions.js +12 -12
  81. package/vscode/src/vs/workbench/browser/parts/editor/binaryDiffEditor.js +2 -7
  82. package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.js +4 -7
  83. package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbs.js +42 -90
  84. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +140 -272
  85. package/vscode/src/vs/workbench/browser/parts/editor/editorActions.js +115 -148
  86. package/vscode/src/vs/workbench/browser/parts/editor/editorCommands.js +21 -33
  87. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +7 -19
  88. package/vscode/src/vs/workbench/browser/parts/editor/editorPlaceholder.js +10 -26
  89. package/vscode/src/vs/workbench/browser/parts/editor/editorQuickAccess.js +7 -17
  90. package/vscode/src/vs/workbench/browser/parts/editor/editorStatus.js +60 -81
  91. package/vscode/src/vs/workbench/browser/parts/editor/sideBySideEditor.js +27 -33
  92. package/vscode/src/vs/workbench/browser/parts/editor/textCodeEditor.js +2 -2
  93. package/vscode/src/vs/workbench/browser/parts/editor/textDiffEditor.js +19 -32
  94. package/vscode/src/vs/workbench/browser/parts/editor/textEditor.js +2 -2
  95. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCommands.js +8 -8
  96. package/vscode/src/vs/workbench/browser/parts/panel/panelActions.js +69 -34
  97. package/vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.js +58 -34
  98. package/vscode/src/vs/workbench/browser/parts/views/viewFilter.js +2 -2
  99. package/vscode/src/vs/workbench/browser/parts/views/viewPane.js +3 -9
  100. package/vscode/src/vs/workbench/browser/parts/views/viewPaneContainer.js +6 -6
  101. package/vscode/src/vs/workbench/browser/parts/views/viewsService.js +7 -11
  102. package/vscode/src/vs/workbench/browser/quickaccess.js +7 -3
  103. package/vscode/src/vs/workbench/browser/workbench.contribution.js +186 -683
  104. package/vscode/src/vs/workbench/common/configuration.js +12 -15
  105. package/vscode/src/vs/workbench/common/contextkeys.js +272 -90
  106. package/vscode/src/vs/workbench/common/editor/diffEditorInput.js +2 -2
  107. package/vscode/src/vs/workbench/common/editor/sideBySideEditorInput.js +2 -7
  108. package/vscode/src/vs/workbench/common/editor/textEditorModel.js +2 -6
  109. package/vscode/src/vs/workbench/common/editor.js +5 -5
  110. package/vscode/src/vs/workbench/common/theme.js +137 -527
  111. package/vscode/src/vs/workbench/common/views.js +4 -8
  112. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.js +15 -55
  113. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.js +3 -8
  114. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleView.js +22 -60
  115. package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewActions.js +9 -15
  116. package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.js +18 -48
  117. package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.js +58 -74
  118. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +2 -0
  119. package/vscode/src/vs/workbench/contrib/chat/common/chatAgents.js +5 -10
  120. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +5 -13
  121. package/vscode/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.js +8 -27
  122. package/vscode/src/vs/workbench/contrib/codeActions/common/codeActionsExtensionPoint.js +5 -17
  123. package/vscode/src/vs/workbench/contrib/codeActions/common/documentationExtensionPoint.js +6 -15
  124. package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorHelper.js +7 -20
  125. package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.js +2 -2
  126. package/vscode/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.js +63 -216
  127. package/vscode/src/vs/workbench/contrib/codeEditor/browser/largeFileOptimizations.js +4 -7
  128. package/vscode/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoLineQuickAccess.js +5 -8
  129. package/vscode/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.js +8 -11
  130. package/vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.js +5 -15
  131. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.js +3 -3
  132. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMultiCursorModifier.js +5 -5
  133. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.js +3 -6
  134. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.js +3 -6
  135. package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.js +10 -9
  136. package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +6 -15
  137. package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +5 -20
  138. package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +3 -10
  139. package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +4 -4
  140. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +3 -20
  141. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +9 -3
  142. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +4 -13
  143. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +19 -19
  144. package/vscode/src/vs/workbench/contrib/comments/browser/comments.contribution.js +26 -77
  145. package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +5 -17
  146. package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +31 -40
  147. package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +10 -29
  148. package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +10 -10
  149. package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +8 -8
  150. package/vscode/src/vs/workbench/contrib/comments/common/commentContextKeys.js +25 -21
  151. package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +2 -2
  152. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +1 -4
  153. package/vscode/src/vs/workbench/contrib/debug/browser/debugColors.js +20 -20
  154. package/vscode/src/vs/workbench/contrib/debug/browser/debugIcons.js +56 -98
  155. package/vscode/src/vs/workbench/contrib/debug/common/abstractDebugAdapter.js +2 -2
  156. package/vscode/src/vs/workbench/contrib/debug/common/debug.js +96 -180
  157. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsIcons.js +25 -79
  158. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/configuration.js +4 -15
  159. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService.js +4 -8
  160. package/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.js +56 -19
  161. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.js +76 -230
  162. package/vscode/src/vs/workbench/contrib/files/browser/fileConstants.js +6 -5
  163. package/vscode/src/vs/workbench/contrib/files/browser/fileImportExport.js +33 -103
  164. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +228 -99
  165. package/vscode/src/vs/workbench/contrib/files/browser/views/emptyView.js +1 -1
  166. package/vscode/src/vs/workbench/contrib/files/browser/views/explorerDecorationsProvider.js +5 -9
  167. package/vscode/src/vs/workbench/contrib/files/browser/views/explorerView.js +5 -5
  168. package/vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.js +15 -35
  169. package/vscode/src/vs/workbench/contrib/files/browser/views/openEditorsView.js +5 -8
  170. package/vscode/src/vs/workbench/contrib/files/common/files.js +27 -48
  171. package/vscode/src/vs/workbench/contrib/folding/browser/folding.contribution.js +3 -6
  172. package/vscode/src/vs/workbench/contrib/format/browser/formatModified.js +1 -1
  173. package/vscode/src/vs/workbench/contrib/inlayHints/browser/inlayHintsAccessibilty.js +5 -8
  174. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +112 -52
  175. package/vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js +1 -1
  176. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +2 -2
  177. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +30 -96
  178. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +73 -126
  179. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +3 -3
  180. package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +42 -0
  181. package/vscode/src/vs/workbench/contrib/output/browser/output.contribution.js +23 -29
  182. package/vscode/src/vs/workbench/contrib/output/browser/outputView.js +3 -3
  183. package/vscode/src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.js +13 -16
  184. package/vscode/src/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.js +15 -34
  185. package/vscode/src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.js +12 -17
  186. package/vscode/src/vs/workbench/contrib/scm/browser/dirtyDiffSwitcher.js +2 -2
  187. package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +26 -75
  188. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCompletionProvider.js +4 -19
  189. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsFile.js +4 -4
  190. package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsService.js +60 -99
  191. package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +5 -14
  192. package/vscode/src/vs/workbench/contrib/tasks/common/taskService.js +26 -13
  193. package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +88 -96
  194. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.js +5 -17
  195. package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +7 -28
  196. package/vscode/src/vs/workbench/contrib/terminal/common/terminalColorRegistry.js +21 -78
  197. package/vscode/src/vs/workbench/contrib/terminal/common/terminalContextKey.js +21 -53
  198. package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +2 -2
  199. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditor.js +2 -5
  200. package/vscode/src/vs/workbench/services/actions/common/menusExtensionPoint.js +113 -348
  201. package/vscode/src/vs/workbench/services/assignment/common/assignmentService.js +2 -5
  202. package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +31 -1
  203. package/vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js +1 -4
  204. package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +16 -16
  205. package/vscode/src/vs/workbench/services/decorations/browser/decorationsService.js +2 -2
  206. package/vscode/src/vs/workbench/services/editor/common/editorResolverService.js +2 -5
  207. package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +4 -4
  208. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +27 -29
  209. package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +104 -141
  210. package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +35 -39
  211. package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +25 -25
  212. package/vscode/src/vs/workbench/services/extensions/common/extensionsRegistry.js +80 -296
  213. package/vscode/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.js +6 -21
  214. package/vscode/src/vs/workbench/services/host/browser/browserHostService.js +3 -6
  215. package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +24 -81
  216. package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +2 -2
  217. package/vscode/src/vs/workbench/services/keybinding/common/keybindingEditing.js +11 -17
  218. package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +30 -32
  219. package/vscode/src/vs/workbench/services/language/common/languageService.js +23 -98
  220. package/vscode/src/vs/workbench/services/remote/common/tunnelModel.js +83 -95
  221. package/vscode/src/vs/workbench/services/search/common/queryBuilder.js +1 -5
  222. package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +11 -23
  223. package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModel.js +32 -32
  224. package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +2 -7
  225. package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +2 -2
  226. package/vscode/src/vs/workbench/services/themes/common/colorExtensionPoint.js +16 -53
  227. package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +50 -1
  228. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +25 -99
  229. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +16 -16
  230. package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +6 -3
  231. package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +15 -3
  232. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopySaveParticipant.js +2 -2
  233. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackupService.js +32 -42
@@ -0,0 +1,137 @@
1
+ function countMapFrom(values) {
2
+ const map = ( new Map());
3
+ for (const value of values) {
4
+ map.set(value, (map.get(value) ?? 0) + 1);
5
+ }
6
+ return map;
7
+ }
8
+ class TfIdfCalculator {
9
+ constructor() {
10
+ this.chunkCount = 0;
11
+ this.chunkOccurrences = ( new Map());
12
+ this.documents = ( new Map());
13
+ }
14
+ calculateScores(query, token) {
15
+ const embedding = this.computeEmbedding(query);
16
+ const idfCache = ( new Map());
17
+ const scores = [];
18
+ for (const [key, doc] of this.documents) {
19
+ if (token.isCancellationRequested) {
20
+ return [];
21
+ }
22
+ for (const chunk of doc.chunks) {
23
+ const score = this.computeSimilarityScore(chunk, embedding, idfCache);
24
+ if (score > 0) {
25
+ scores.push({ key, score });
26
+ }
27
+ }
28
+ }
29
+ return scores;
30
+ }
31
+ static termFrequencies(input) {
32
+ return countMapFrom(TfIdfCalculator.splitTerms(input));
33
+ }
34
+ static *splitTerms(input) {
35
+ const normalize = (word) => word.toLowerCase();
36
+ for (const [word] of input.matchAll(/\b\p{Letter}[\p{Letter}\d]{2,}\b/gu)) {
37
+ yield normalize(word);
38
+ const camelParts = word.split(/(?<=[a-z])(?=[A-Z])/g);
39
+ if (camelParts.length > 1) {
40
+ for (const part of camelParts) {
41
+ if (part.length > 2 && /\p{Letter}{3,}/gu.test(part)) {
42
+ yield normalize(part);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ updateDocuments(documents) {
49
+ for (const { key } of documents) {
50
+ this.deleteDocument(key);
51
+ }
52
+ for (const doc of documents) {
53
+ const chunks = [];
54
+ for (const text of doc.textChunks) {
55
+ const tf = TfIdfCalculator.termFrequencies(text);
56
+ for (const term of ( tf.keys())) {
57
+ this.chunkOccurrences.set(term, (this.chunkOccurrences.get(term) ?? 0) + 1);
58
+ }
59
+ chunks.push({ text, tf });
60
+ }
61
+ this.chunkCount += chunks.length;
62
+ this.documents.set(doc.key, { chunks });
63
+ }
64
+ return this;
65
+ }
66
+ deleteDocument(key) {
67
+ const doc = this.documents.get(key);
68
+ if (!doc) {
69
+ return;
70
+ }
71
+ this.documents.delete(key);
72
+ this.chunkCount -= doc.chunks.length;
73
+ for (const chunk of doc.chunks) {
74
+ for (const term of ( chunk.tf.keys())) {
75
+ const currentOccurrences = this.chunkOccurrences.get(term);
76
+ if (typeof currentOccurrences === 'number') {
77
+ const newOccurrences = currentOccurrences - 1;
78
+ if (newOccurrences <= 0) {
79
+ this.chunkOccurrences.delete(term);
80
+ }
81
+ else {
82
+ this.chunkOccurrences.set(term, newOccurrences);
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ computeSimilarityScore(chunk, queryEmbedding, idfCache) {
89
+ let sum = 0;
90
+ for (const [term, termTfidf] of Object.entries(queryEmbedding)) {
91
+ const chunkTf = chunk.tf.get(term);
92
+ if (!chunkTf) {
93
+ continue;
94
+ }
95
+ let chunkIdf = idfCache.get(term);
96
+ if (typeof chunkIdf !== 'number') {
97
+ chunkIdf = this.computeIdf(term);
98
+ idfCache.set(term, chunkIdf);
99
+ }
100
+ const chunkTfidf = chunkTf * chunkIdf;
101
+ sum += chunkTfidf * termTfidf;
102
+ }
103
+ return sum;
104
+ }
105
+ computeEmbedding(input) {
106
+ const tf = TfIdfCalculator.termFrequencies(input);
107
+ return this.computeTfidf(tf);
108
+ }
109
+ computeIdf(term) {
110
+ const chunkOccurrences = this.chunkOccurrences.get(term) ?? 0;
111
+ return chunkOccurrences > 0
112
+ ? Math.log((this.chunkCount + 1) / chunkOccurrences)
113
+ : 0;
114
+ }
115
+ computeTfidf(termFrequencies) {
116
+ const embedding = Object.create(null);
117
+ for (const [word, occurrences] of termFrequencies) {
118
+ const idf = this.computeIdf(word);
119
+ if (idf > 0) {
120
+ embedding[word] = occurrences * idf;
121
+ }
122
+ }
123
+ return embedding;
124
+ }
125
+ }
126
+ function normalizeTfIdfScores(scores) {
127
+ const result = scores.slice(0);
128
+ result.sort((a, b) => b.score - a.score);
129
+ const max = result[0]?.score ?? 0;
130
+ if (max > 0) {
131
+ for (const score of result) {
132
+ score.score /= max;
133
+ }
134
+ }
135
+ return result;
136
+ }
137
+ export { TfIdfCalculator, normalizeTfIdfScores };
@@ -0,0 +1,23 @@
1
+ import { stripIcons } from 'monaco-editor/esm/vs/base/common/iconLabels.js';
2
+ import { AbstractCommandsQuickAccessProvider } from '../../../../platform/quickinput/browser/commandsQuickAccess.js';
3
+ class AbstractEditorCommandsQuickAccessProvider extends AbstractCommandsQuickAccessProvider {
4
+ constructor(options, instantiationService, keybindingService, commandService, telemetryService, dialogService) {
5
+ super(options, instantiationService, keybindingService, commandService, telemetryService, dialogService);
6
+ }
7
+ getCodeEditorCommandPicks() {
8
+ const activeTextEditorControl = this.activeTextEditorControl;
9
+ if (!activeTextEditorControl) {
10
+ return [];
11
+ }
12
+ const editorCommandPicks = [];
13
+ for (const editorAction of activeTextEditorControl.getSupportedActions()) {
14
+ editorCommandPicks.push({
15
+ commandId: editorAction.id,
16
+ commandAlias: editorAction.alias,
17
+ label: stripIcons(editorAction.label) || editorAction.id,
18
+ });
19
+ }
20
+ return editorCommandPicks;
21
+ }
22
+ }
23
+ export { AbstractEditorCommandsQuickAccessProvider };
@@ -0,0 +1,115 @@
1
+ import { createSingleCallFunction } from 'monaco-editor/esm/vs/base/common/functional.js';
2
+ import { MutableDisposable, toDisposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
3
+ import { getCodeEditor, isDiffEditor } from 'monaco-editor/esm/vs/editor/browser/editorBrowser.js';
4
+ import { OverviewRulerLane } from 'monaco-editor/esm/vs/editor/common/model.js';
5
+ import { overviewRulerRangeHighlight } from 'monaco-editor/esm/vs/editor/common/core/editorColorRegistry.js';
6
+ import { themeColorFromId } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
7
+ import { status } from 'monaco-editor/esm/vs/base/browser/ui/aria/aria.js';
8
+ class AbstractEditorNavigationQuickAccessProvider {
9
+ constructor(options) {
10
+ this.options = options;
11
+ this.rangeHighlightDecorationId = undefined;
12
+ }
13
+ provide(picker, token) {
14
+ const disposables = ( new DisposableStore());
15
+ picker.canAcceptInBackground = !!this.options?.canAcceptInBackground;
16
+ picker.matchOnLabel = picker.matchOnDescription = picker.matchOnDetail = picker.sortByLabel = false;
17
+ const pickerDisposable = disposables.add(( new MutableDisposable()));
18
+ pickerDisposable.value = this.doProvide(picker, token);
19
+ disposables.add(this.onDidActiveTextEditorControlChange(() => {
20
+ pickerDisposable.value = undefined;
21
+ pickerDisposable.value = this.doProvide(picker, token);
22
+ }));
23
+ return disposables;
24
+ }
25
+ doProvide(picker, token) {
26
+ const disposables = ( new DisposableStore());
27
+ const editor = this.activeTextEditorControl;
28
+ if (editor && this.canProvideWithTextEditor(editor)) {
29
+ const context = { editor };
30
+ const codeEditor = getCodeEditor(editor);
31
+ if (codeEditor) {
32
+ let lastKnownEditorViewState = editor.saveViewState() ?? undefined;
33
+ disposables.add(codeEditor.onDidChangeCursorPosition(() => {
34
+ lastKnownEditorViewState = editor.saveViewState() ?? undefined;
35
+ }));
36
+ context.restoreViewState = () => {
37
+ if (lastKnownEditorViewState && editor === this.activeTextEditorControl) {
38
+ editor.restoreViewState(lastKnownEditorViewState);
39
+ }
40
+ };
41
+ disposables.add(createSingleCallFunction(token.onCancellationRequested)(() => context.restoreViewState?.()));
42
+ }
43
+ disposables.add(toDisposable(() => this.clearDecorations(editor)));
44
+ disposables.add(this.provideWithTextEditor(context, picker, token));
45
+ }
46
+ else {
47
+ disposables.add(this.provideWithoutTextEditor(picker, token));
48
+ }
49
+ return disposables;
50
+ }
51
+ canProvideWithTextEditor(editor) {
52
+ return true;
53
+ }
54
+ gotoLocation({ editor }, options) {
55
+ editor.setSelection(options.range);
56
+ editor.revealRangeInCenter(options.range, 0 );
57
+ if (!options.preserveFocus) {
58
+ editor.focus();
59
+ }
60
+ const model = editor.getModel();
61
+ if (model && 'getLineContent' in model) {
62
+ status(`${model.getLineContent(options.range.startLineNumber)}`);
63
+ }
64
+ }
65
+ getModel(editor) {
66
+ return isDiffEditor(editor) ?
67
+ editor.getModel()?.modified :
68
+ editor.getModel();
69
+ }
70
+ addDecorations(editor, range) {
71
+ editor.changeDecorations(changeAccessor => {
72
+ const deleteDecorations = [];
73
+ if (this.rangeHighlightDecorationId) {
74
+ deleteDecorations.push(this.rangeHighlightDecorationId.overviewRulerDecorationId);
75
+ deleteDecorations.push(this.rangeHighlightDecorationId.rangeHighlightId);
76
+ this.rangeHighlightDecorationId = undefined;
77
+ }
78
+ const newDecorations = [
79
+ {
80
+ range,
81
+ options: {
82
+ description: 'quick-access-range-highlight',
83
+ className: 'rangeHighlight',
84
+ isWholeLine: true
85
+ }
86
+ },
87
+ {
88
+ range,
89
+ options: {
90
+ description: 'quick-access-range-highlight-overview',
91
+ overviewRuler: {
92
+ color: themeColorFromId(overviewRulerRangeHighlight),
93
+ position: OverviewRulerLane.Full
94
+ }
95
+ }
96
+ }
97
+ ];
98
+ const [rangeHighlightId, overviewRulerDecorationId] = changeAccessor.deltaDecorations(deleteDecorations, newDecorations);
99
+ this.rangeHighlightDecorationId = { rangeHighlightId, overviewRulerDecorationId };
100
+ });
101
+ }
102
+ clearDecorations(editor) {
103
+ const rangeHighlightDecorationId = this.rangeHighlightDecorationId;
104
+ if (rangeHighlightDecorationId) {
105
+ editor.changeDecorations(changeAccessor => {
106
+ changeAccessor.deltaDecorations([
107
+ rangeHighlightDecorationId.overviewRulerDecorationId,
108
+ rangeHighlightDecorationId.rangeHighlightId
109
+ ], []);
110
+ });
111
+ this.rangeHighlightDecorationId = undefined;
112
+ }
113
+ }
114
+ }
115
+ export { AbstractEditorNavigationQuickAccessProvider };
@@ -0,0 +1,112 @@
1
+ import { Disposable, toDisposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
2
+ import { getCodeEditor } from 'monaco-editor/esm/vs/editor/browser/editorBrowser.js';
3
+ import { AbstractEditorNavigationQuickAccessProvider } from './editorNavigationQuickAccess.js';
4
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
5
+ class AbstractGotoLineQuickAccessProvider extends AbstractEditorNavigationQuickAccessProvider {
6
+ static { this.PREFIX = ':'; }
7
+ constructor() {
8
+ super({ canAcceptInBackground: true });
9
+ }
10
+ provideWithoutTextEditor(picker) {
11
+ const label = localizeWithPath('vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess', 'cannotRunGotoLine', "Open a text editor first to go to a line.");
12
+ picker.items = [{ label }];
13
+ picker.ariaLabel = label;
14
+ return Disposable.None;
15
+ }
16
+ provideWithTextEditor(context, picker, token) {
17
+ const editor = context.editor;
18
+ const disposables = ( new DisposableStore());
19
+ disposables.add(picker.onDidAccept(event => {
20
+ const [item] = picker.selectedItems;
21
+ if (item) {
22
+ if (!this.isValidLineNumber(editor, item.lineNumber)) {
23
+ return;
24
+ }
25
+ this.gotoLocation(context, { range: this.toRange(item.lineNumber, item.column), keyMods: picker.keyMods, preserveFocus: event.inBackground });
26
+ if (!event.inBackground) {
27
+ picker.hide();
28
+ }
29
+ }
30
+ }));
31
+ const updatePickerAndEditor = () => {
32
+ const position = this.parsePosition(editor, picker.value.trim().substr(AbstractGotoLineQuickAccessProvider.PREFIX.length));
33
+ const label = this.getPickLabel(editor, position.lineNumber, position.column);
34
+ picker.items = [{
35
+ lineNumber: position.lineNumber,
36
+ column: position.column,
37
+ label
38
+ }];
39
+ picker.ariaLabel = label;
40
+ if (!this.isValidLineNumber(editor, position.lineNumber)) {
41
+ this.clearDecorations(editor);
42
+ return;
43
+ }
44
+ const range = this.toRange(position.lineNumber, position.column);
45
+ editor.revealRangeInCenter(range, 0 );
46
+ this.addDecorations(editor, range);
47
+ };
48
+ updatePickerAndEditor();
49
+ disposables.add(picker.onDidChangeValue(() => updatePickerAndEditor()));
50
+ const codeEditor = getCodeEditor(editor);
51
+ if (codeEditor) {
52
+ const options = codeEditor.getOptions();
53
+ const lineNumbers = options.get(67 );
54
+ if (lineNumbers.renderType === 2 ) {
55
+ codeEditor.updateOptions({ lineNumbers: 'on' });
56
+ disposables.add(toDisposable(() => codeEditor.updateOptions({ lineNumbers: 'relative' })));
57
+ }
58
+ }
59
+ return disposables;
60
+ }
61
+ toRange(lineNumber = 1, column = 1) {
62
+ return {
63
+ startLineNumber: lineNumber,
64
+ startColumn: column,
65
+ endLineNumber: lineNumber,
66
+ endColumn: column
67
+ };
68
+ }
69
+ parsePosition(editor, value) {
70
+ const numbers = ( value.split(/,|:|#/).map(part => parseInt(part, 10))).filter(part => !isNaN(part));
71
+ const endLine = this.lineCount(editor) + 1;
72
+ return {
73
+ lineNumber: numbers[0] > 0 ? numbers[0] : endLine + numbers[0],
74
+ column: numbers[1]
75
+ };
76
+ }
77
+ getPickLabel(editor, lineNumber, column) {
78
+ if (this.isValidLineNumber(editor, lineNumber)) {
79
+ if (this.isValidColumn(editor, lineNumber, column)) {
80
+ return localizeWithPath('vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess', 'gotoLineColumnLabel', "Go to line {0} and character {1}.", lineNumber, column);
81
+ }
82
+ return localizeWithPath('vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess', 'gotoLineLabel', "Go to line {0}.", lineNumber);
83
+ }
84
+ const position = editor.getPosition() || { lineNumber: 1, column: 1 };
85
+ const lineCount = this.lineCount(editor);
86
+ if (lineCount > 1) {
87
+ return localizeWithPath('vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess', 'gotoLineLabelEmptyWithLimit', "Current Line: {0}, Character: {1}. Type a line number between 1 and {2} to navigate to.", position.lineNumber, position.column, lineCount);
88
+ }
89
+ return localizeWithPath('vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess', 'gotoLineLabelEmpty', "Current Line: {0}, Character: {1}. Type a line number to navigate to.", position.lineNumber, position.column);
90
+ }
91
+ isValidLineNumber(editor, lineNumber) {
92
+ if (!lineNumber || typeof lineNumber !== 'number') {
93
+ return false;
94
+ }
95
+ return lineNumber > 0 && lineNumber <= this.lineCount(editor);
96
+ }
97
+ isValidColumn(editor, lineNumber, column) {
98
+ if (!column || typeof column !== 'number') {
99
+ return false;
100
+ }
101
+ const model = this.getModel(editor);
102
+ if (!model) {
103
+ return false;
104
+ }
105
+ const positionCandidate = { lineNumber, column };
106
+ return model.validatePosition(positionCandidate).equals(positionCandidate);
107
+ }
108
+ lineCount(editor) {
109
+ return this.getModel(editor)?.getLineCount() ?? 0;
110
+ }
111
+ }
112
+ export { AbstractGotoLineQuickAccessProvider };