monaco-editor-core 0.54.0 → 0.55.0-dev-20251007

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 (251) hide show
  1. package/esm/nls.messages.de.js +1 -1
  2. package/esm/nls.messages.es.js +1 -1
  3. package/esm/nls.messages.fr.js +1 -1
  4. package/esm/nls.messages.it.js +1 -1
  5. package/esm/nls.messages.ja.js +1 -1
  6. package/esm/nls.messages.ko.js +1 -1
  7. package/esm/nls.messages.ru.js +1 -1
  8. package/esm/nls.messages.zh-cn.js +1 -1
  9. package/esm/nls.messages.zh-tw.js +1 -1
  10. package/esm/vs/base/browser/canIUse.js +1 -0
  11. package/esm/vs/base/browser/canIUse.js.map +1 -1
  12. package/esm/vs/base/browser/dom.js +9 -0
  13. package/esm/vs/base/browser/dom.js.map +1 -1
  14. package/esm/vs/base/browser/fastDomNode.js.map +1 -1
  15. package/esm/vs/base/browser/mouseEvent.js +3 -0
  16. package/esm/vs/base/browser/mouseEvent.js.map +1 -1
  17. package/esm/vs/base/browser/trustedTypes.js +2 -0
  18. package/esm/vs/base/browser/trustedTypes.js.map +1 -1
  19. package/esm/vs/base/browser/ui/list/listWidget.js +5 -5
  20. package/esm/vs/base/browser/ui/list/listWidget.js.map +1 -1
  21. package/esm/vs/base/browser/ui/sash/sash.css +1 -1
  22. package/esm/vs/base/browser/ui/sash/sash.js +4 -0
  23. package/esm/vs/base/browser/ui/sash/sash.js.map +1 -1
  24. package/esm/vs/base/browser/ui/scrollbar/scrollableElement.js +1 -1
  25. package/esm/vs/base/browser/ui/scrollbar/scrollableElement.js.map +1 -1
  26. package/esm/vs/base/browser/ui/table/table.css +2 -2
  27. package/esm/vs/base/browser/ui/tree/abstractTree.js +7 -3
  28. package/esm/vs/base/browser/ui/tree/abstractTree.js.map +1 -1
  29. package/esm/vs/base/browser/ui/tree/asyncDataTree.js +4 -0
  30. package/esm/vs/base/browser/ui/tree/asyncDataTree.js.map +1 -1
  31. package/esm/vs/base/browser/ui/tree/indexTreeModel.js +1 -0
  32. package/esm/vs/base/browser/ui/tree/indexTreeModel.js.map +1 -1
  33. package/esm/vs/base/browser/ui/tree/media/tree.css +2 -2
  34. package/esm/vs/base/browser/webWorkerFactory.js +3 -0
  35. package/esm/vs/base/browser/webWorkerFactory.js.map +1 -1
  36. package/esm/vs/base/common/buffer.js.map +1 -1
  37. package/esm/vs/base/common/decorators.js +1 -0
  38. package/esm/vs/base/common/decorators.js.map +1 -1
  39. package/esm/vs/base/common/errors.js +1 -0
  40. package/esm/vs/base/common/errors.js.map +1 -1
  41. package/esm/vs/base/common/glob.js +1 -1
  42. package/esm/vs/base/common/glob.js.map +1 -1
  43. package/esm/vs/base/common/hash.js.map +1 -1
  44. package/esm/vs/base/common/hotReload.js +2 -0
  45. package/esm/vs/base/common/hotReload.js.map +1 -1
  46. package/esm/vs/base/common/hotReloadHelpers.js +1 -0
  47. package/esm/vs/base/common/hotReloadHelpers.js.map +1 -1
  48. package/esm/vs/base/common/lifecycle.js +19 -0
  49. package/esm/vs/base/common/lifecycle.js.map +1 -1
  50. package/esm/vs/base/common/map.js.map +1 -1
  51. package/esm/vs/base/common/marshalling.js +4 -0
  52. package/esm/vs/base/common/marshalling.js.map +1 -1
  53. package/esm/vs/base/common/network.js +1 -0
  54. package/esm/vs/base/common/network.js.map +1 -1
  55. package/esm/vs/base/common/objects.js +1 -0
  56. package/esm/vs/base/common/objects.js.map +1 -1
  57. package/esm/vs/base/common/observableInternal/changeTracker.js +4 -0
  58. package/esm/vs/base/common/observableInternal/changeTracker.js.map +1 -1
  59. package/esm/vs/base/common/observableInternal/debugLocation.js +1 -0
  60. package/esm/vs/base/common/observableInternal/debugLocation.js.map +1 -1
  61. package/esm/vs/base/common/observableInternal/debugName.js +1 -0
  62. package/esm/vs/base/common/observableInternal/debugName.js.map +1 -1
  63. package/esm/vs/base/common/observableInternal/logging/consoleObservableLogger.js +1 -0
  64. package/esm/vs/base/common/observableInternal/logging/consoleObservableLogger.js.map +1 -1
  65. package/esm/vs/base/common/observableInternal/logging/debugger/debuggerRpc.js +1 -0
  66. package/esm/vs/base/common/observableInternal/logging/debugger/debuggerRpc.js.map +1 -1
  67. package/esm/vs/base/common/observableInternal/logging/debugger/rpc.js +1 -0
  68. package/esm/vs/base/common/observableInternal/logging/debugger/rpc.js.map +1 -1
  69. package/esm/vs/base/common/observableInternal/observables/derived.js +7 -1
  70. package/esm/vs/base/common/observableInternal/observables/derived.js.map +1 -1
  71. package/esm/vs/base/common/observableInternal/observables/derivedImpl.js +2 -0
  72. package/esm/vs/base/common/observableInternal/observables/derivedImpl.js.map +1 -1
  73. package/esm/vs/base/common/observableInternal/observables/observableFromEvent.js +1 -0
  74. package/esm/vs/base/common/observableInternal/observables/observableFromEvent.js.map +1 -1
  75. package/esm/vs/base/common/observableInternal/reactions/autorunImpl.js +1 -0
  76. package/esm/vs/base/common/observableInternal/reactions/autorunImpl.js.map +1 -1
  77. package/esm/vs/base/common/process.js +1 -0
  78. package/esm/vs/base/common/process.js.map +1 -1
  79. package/esm/vs/base/common/product.js.map +1 -1
  80. package/esm/vs/base/common/types.js +2 -0
  81. package/esm/vs/base/common/types.js.map +1 -1
  82. package/esm/vs/base/common/worker/webWorker.js +26 -14
  83. package/esm/vs/base/common/worker/webWorker.js.map +1 -1
  84. package/esm/vs/base/parts/sandbox/common/sandboxTypes.js +2 -0
  85. package/esm/vs/base/parts/sandbox/common/sandboxTypes.js.map +1 -0
  86. package/esm/vs/editor/browser/config/editorConfiguration.js +3 -2
  87. package/esm/vs/editor/browser/config/editorConfiguration.js.map +1 -1
  88. package/esm/vs/editor/browser/config/migrateOptions.js +1 -1
  89. package/esm/vs/editor/browser/config/migrateOptions.js.map +1 -1
  90. package/esm/vs/editor/browser/controller/editContext/native/editContextFactory.js.map +1 -1
  91. package/esm/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.js +2 -0
  92. package/esm/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.js.map +1 -1
  93. package/esm/vs/editor/browser/controller/mouseHandler.js +2 -1
  94. package/esm/vs/editor/browser/controller/mouseHandler.js.map +1 -1
  95. package/esm/vs/editor/browser/controller/mouseTarget.js +7 -0
  96. package/esm/vs/editor/browser/controller/mouseTarget.js.map +1 -1
  97. package/esm/vs/editor/browser/controller/pointerHandler.js.map +1 -1
  98. package/esm/vs/editor/browser/coreCommands.js.map +1 -1
  99. package/esm/vs/editor/browser/editorBrowser.js.map +1 -1
  100. package/esm/vs/editor/browser/editorDom.js.map +1 -1
  101. package/esm/vs/editor/browser/editorExtensions.js.map +1 -1
  102. package/esm/vs/editor/browser/gpu/gpuUtils.js +1 -0
  103. package/esm/vs/editor/browser/gpu/gpuUtils.js.map +1 -1
  104. package/esm/vs/editor/browser/gpu/viewGpuContext.js +1 -0
  105. package/esm/vs/editor/browser/gpu/viewGpuContext.js.map +1 -1
  106. package/esm/vs/editor/browser/services/abstractCodeEditorService.js.map +1 -1
  107. package/esm/vs/editor/browser/services/bulkEditService.js.map +1 -1
  108. package/esm/vs/editor/browser/services/codeEditorService.js.map +1 -1
  109. package/esm/vs/editor/browser/services/editorWorkerService.js.map +1 -1
  110. package/esm/vs/editor/browser/services/hoverService/hover.css +2 -0
  111. package/esm/vs/editor/browser/services/hoverService/hoverService.js.map +1 -1
  112. package/esm/vs/editor/browser/services/hoverService/hoverWidget.js +1 -1
  113. package/esm/vs/editor/browser/services/hoverService/hoverWidget.js.map +1 -1
  114. package/esm/vs/editor/browser/services/inlineCompletionsService.js +8 -8
  115. package/esm/vs/editor/browser/services/inlineCompletionsService.js.map +1 -1
  116. package/esm/vs/editor/browser/services/openerService.js.map +1 -1
  117. package/esm/vs/editor/browser/view/viewLayer.js +1 -1
  118. package/esm/vs/editor/browser/view/viewLayer.js.map +1 -1
  119. package/esm/vs/editor/browser/view.js.map +1 -1
  120. package/esm/vs/editor/browser/viewParts/contentWidgets/contentWidgets.js +1 -0
  121. package/esm/vs/editor/browser/viewParts/contentWidgets/contentWidgets.js.map +1 -1
  122. package/esm/vs/editor/browser/viewParts/viewZones/viewZones.js +1 -0
  123. package/esm/vs/editor/browser/viewParts/viewZones/viewZones.js.map +1 -1
  124. package/esm/vs/editor/browser/widget/codeEditor/codeEditorContributions.js.map +1 -1
  125. package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js +4 -1
  126. package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js.map +1 -1
  127. package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorEditors.js +1 -0
  128. package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorEditors.js.map +1 -1
  129. package/esm/vs/editor/browser/widget/diffEditor/delegatingEditorImpl.js.map +1 -1
  130. package/esm/vs/editor/browser/widget/diffEditor/diffEditorOptions.js +1 -0
  131. package/esm/vs/editor/browser/widget/diffEditor/diffEditorOptions.js.map +1 -1
  132. package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js +1 -0
  133. package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js.map +1 -1
  134. package/esm/vs/editor/browser/widget/diffEditor/utils.js +2 -0
  135. package/esm/vs/editor/browser/widget/diffEditor/utils.js.map +1 -1
  136. package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js +2 -0
  137. package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js.map +1 -1
  138. package/esm/vs/editor/common/config/editorOptions.js +122 -68
  139. package/esm/vs/editor/common/config/editorOptions.js.map +1 -1
  140. package/esm/vs/editor/common/config/fontInfo.js +32 -16
  141. package/esm/vs/editor/common/config/fontInfo.js.map +1 -1
  142. package/esm/vs/editor/common/config/fontInfoFromSettings.js +16 -0
  143. package/esm/vs/editor/common/config/fontInfoFromSettings.js.map +1 -0
  144. package/esm/vs/editor/common/core/edits/edit.js +1 -0
  145. package/esm/vs/editor/common/core/edits/edit.js.map +1 -1
  146. package/esm/vs/editor/common/core/edits/stringEdit.js +2 -0
  147. package/esm/vs/editor/common/core/edits/stringEdit.js.map +1 -1
  148. package/esm/vs/editor/common/core/position.js +1 -1
  149. package/esm/vs/editor/common/core/position.js.map +1 -1
  150. package/esm/vs/editor/common/core/range.js +1 -1
  151. package/esm/vs/editor/common/core/range.js.map +1 -1
  152. package/esm/vs/editor/common/core/selection.js +1 -1
  153. package/esm/vs/editor/common/core/selection.js.map +1 -1
  154. package/esm/vs/editor/common/cursor/cursorMoveCommands.js.map +1 -1
  155. package/esm/vs/editor/common/editorCommon.js.map +1 -1
  156. package/esm/vs/editor/common/languages.js +1 -1
  157. package/esm/vs/editor/common/languages.js.map +1 -1
  158. package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length.js +14 -0
  159. package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length.js.map +1 -1
  160. package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet.js +2 -0
  161. package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet.js.map +1 -1
  162. package/esm/vs/editor/common/model/textModel.js +1 -1
  163. package/esm/vs/editor/common/model/textModel.js.map +1 -1
  164. package/esm/vs/editor/common/model.js +1 -1
  165. package/esm/vs/editor/common/model.js.map +1 -1
  166. package/esm/vs/editor/common/services/editorBaseApi.js.map +1 -1
  167. package/esm/vs/editor/common/services/editorWebWorker.js +1 -0
  168. package/esm/vs/editor/common/services/editorWebWorker.js.map +1 -1
  169. package/esm/vs/editor/common/services/editorWorkerHost.js.map +1 -1
  170. package/esm/vs/editor/common/services/modelService.js +14 -21
  171. package/esm/vs/editor/common/services/modelService.js.map +1 -1
  172. package/esm/vs/editor/common/textModelEditSource.js +2 -0
  173. package/esm/vs/editor/common/textModelEditSource.js.map +1 -1
  174. package/esm/vs/editor/common/viewLayout/viewLineRenderer.js +40 -1
  175. package/esm/vs/editor/common/viewLayout/viewLineRenderer.js.map +1 -1
  176. package/esm/vs/editor/common/viewModel/viewModelImpl.js +2 -1
  177. package/esm/vs/editor/common/viewModel/viewModelImpl.js.map +1 -1
  178. package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js +1 -1
  179. package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js.map +1 -1
  180. package/esm/vs/editor/contrib/codelens/browser/codelensController.js +1 -1
  181. package/esm/vs/editor/contrib/codelens/browser/codelensController.js.map +1 -1
  182. package/esm/vs/editor/contrib/colorPicker/browser/colorDetector.js +1 -0
  183. package/esm/vs/editor/contrib/colorPicker/browser/colorDetector.js.map +1 -1
  184. package/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js +1 -0
  185. package/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js.map +1 -1
  186. package/esm/vs/editor/contrib/find/browser/findModel.js +1 -0
  187. package/esm/vs/editor/contrib/find/browser/findModel.js.map +1 -1
  188. package/esm/vs/editor/contrib/find/browser/findWidget.css +5 -5
  189. package/esm/vs/editor/contrib/folding/browser/folding.css +4 -4
  190. package/esm/vs/editor/contrib/folding/browser/foldingDecorations.js.map +1 -1
  191. package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js +1 -1
  192. package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js.map +1 -1
  193. package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsController.js +30 -14
  194. package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsController.js.map +1 -1
  195. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +4 -3
  196. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js.map +1 -1
  197. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js +56 -7
  198. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js.map +1 -1
  199. package/esm/vs/editor/contrib/inlineCompletions/browser/structuredLogger.js +1 -0
  200. package/esm/vs/editor/contrib/inlineCompletions/browser/structuredLogger.js.map +1 -1
  201. package/esm/vs/editor/contrib/inlineCompletions/browser/view/ghostText/ghostTextView.js +2 -0
  202. package/esm/vs/editor/contrib/inlineCompletions/browser/view/ghostText/ghostTextView.js.map +1 -1
  203. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js +1 -0
  204. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js.map +1 -1
  205. package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js +1 -1
  206. package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js.map +1 -1
  207. package/esm/vs/editor/contrib/rename/browser/renameWidget.js.map +1 -1
  208. package/esm/vs/editor/contrib/symbolIcons/browser/symbolIcons.css +2 -0
  209. package/esm/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js +2 -0
  210. package/esm/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js.map +1 -1
  211. package/esm/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js.map +1 -1
  212. package/esm/vs/editor/editor.api.d.ts +8 -8
  213. package/esm/vs/editor/editor.api.js +4 -0
  214. package/esm/vs/editor/editor.api.js.map +1 -1
  215. package/esm/vs/editor/standalone/browser/standaloneCodeEditor.js.map +1 -1
  216. package/esm/vs/editor/standalone/browser/standaloneEditor.js +37 -0
  217. package/esm/vs/editor/standalone/browser/standaloneEditor.js.map +1 -1
  218. package/esm/vs/editor/standalone/browser/standaloneLanguages.js +37 -0
  219. package/esm/vs/editor/standalone/browser/standaloneLanguages.js.map +1 -1
  220. package/esm/vs/editor/standalone/browser/standaloneServices.js.map +1 -1
  221. package/esm/vs/editor/standalone/browser/standaloneWebWorker.js.map +1 -1
  222. package/esm/vs/editor/standalone/common/monarch/monarchCompile.js +3 -0
  223. package/esm/vs/editor/standalone/common/monarch/monarchCompile.js.map +1 -1
  224. package/esm/vs/platform/accessibility/browser/accessibilityService.js +2 -2
  225. package/esm/vs/platform/accessibility/browser/accessibilityService.js.map +1 -1
  226. package/esm/vs/platform/actions/common/actions.js.map +1 -1
  227. package/esm/vs/platform/commands/common/commands.js.map +1 -1
  228. package/esm/vs/platform/contextkey/common/contextkey.js +5 -0
  229. package/esm/vs/platform/contextkey/common/contextkey.js.map +1 -1
  230. package/esm/vs/platform/dataChannel/browser/forwardingTelemetryService.js +1 -0
  231. package/esm/vs/platform/dataChannel/browser/forwardingTelemetryService.js.map +1 -1
  232. package/esm/vs/platform/dnd/browser/dnd.js +2 -0
  233. package/esm/vs/platform/dnd/browser/dnd.js.map +1 -1
  234. package/esm/vs/platform/instantiation/common/descriptors.js.map +1 -1
  235. package/esm/vs/platform/instantiation/common/instantiation.js.map +1 -1
  236. package/esm/vs/platform/instantiation/common/instantiationService.js +1 -0
  237. package/esm/vs/platform/instantiation/common/instantiationService.js.map +1 -1
  238. package/esm/vs/platform/list/browser/listService.js +5 -0
  239. package/esm/vs/platform/list/browser/listService.js.map +1 -1
  240. package/esm/vs/platform/log/common/log.js.map +1 -1
  241. package/esm/vs/platform/log/common/logService.js.map +1 -1
  242. package/esm/vs/platform/observable/common/wrapInHotClass.js +2 -0
  243. package/esm/vs/platform/observable/common/wrapInHotClass.js.map +1 -1
  244. package/esm/vs/platform/observable/common/wrapInReloadableClass.js +3 -0
  245. package/esm/vs/platform/observable/common/wrapInReloadableClass.js.map +1 -1
  246. package/esm/vs/platform/product/common/product.js +69 -0
  247. package/esm/vs/platform/product/common/product.js.map +1 -0
  248. package/esm/vs/platform/quickinput/browser/quickInput.js +1 -1
  249. package/esm/vs/platform/quickinput/browser/quickInput.js.map +1 -1
  250. package/monaco.d.ts +8 -8
  251. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/editorWebWorker.ts","vs/editor/common/services/editorWebWorker.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAI/D,OAAO,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I,EAAE,EAAE,CAAC,CAAC;QACxG,OAAO,MAAM,CAAC;IACf,CAAC;IAED,+GAA+G;IAE/G,yBAAyB;IAClB,IAAI,CAAC,MAAc,EAAE,IAAW;QACtC,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;YAC/E,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,GAAG,MAAM,CAAC,CAAC,CAAC;QACjF,CAAC;QAED,IAAI,CAAC;YACJ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;;AAQF,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;IACzC,0BAA0B;IAC1B,UAAU,CAAC,MAAM,GAAG,mBAAmB,EAAE,CAAC;AAC3C,CAAC","file":"editorWebWorker.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { stringDiff } from '../../../base/common/diff/diff.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IWebWorkerServerRequestHandler } from '../../../base/common/worker/webWorker.js';\nimport { IRange, Range } from '../core/range.js';\nimport { EndOfLineSequence, ITextModel } from '../model.js';\nimport { IMirrorTextModel, IModelChangedEvent } from '../model/mirrorTextModel.js';\nimport { IColorInformation, IInplaceReplaceSupportResult, ILink, TextEdit } from '../languages.js';\nimport { computeLinks } from '../languages/linkComputer.js';\nimport { BasicInplaceReplace } from '../languages/supports/inplaceReplaceSupport.js';\nimport { DiffAlgorithmName, IDiffComputationResult, ILineChange, IUnicodeHighlightsResult } from './editorWorker.js';\nimport { createMonacoBaseAPI } from './editorBaseApi.js';\nimport { StopWatch } from '../../../base/common/stopwatch.js';\nimport { UnicodeTextModelHighlighter, UnicodeHighlighterOptions } from './unicodeTextModelHighlighter.js';\nimport { ILinesDiffComputer } from '../diff/linesDiffComputer.js';\nimport { DetailedLineRangeMapping } from '../diff/rangeMapping.js';\nimport { linesDiffComputers } from '../diff/linesDiffComputers.js';\nimport { IDocumentDiffProviderOptions } from '../diff/documentDiffProvider.js';\nimport { computeDefaultDocumentColors } from '../languages/defaultDocumentColorsComputer.js';\nimport { FindSectionHeaderOptions, SectionHeader, findSectionHeaders } from './findSectionHeaders.js';\nimport { IRawModelData, IWorkerTextModelSyncChannelServer } from './textModelSync/textModelSync.protocol.js';\nimport { ICommonModel, WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';\n\nexport interface IMirrorModel extends IMirrorTextModel {\n\treadonly uri: URI;\n\treadonly version: number;\n\tgetValue(): string;\n}\n\nexport interface IWorkerContext<H = {}> {\n\t/**\n\t * A proxy to the main thread host object.\n\t */\n\thost: H;\n\t/**\n\t * Get all available mirror models in this worker.\n\t */\n\tgetMirrorModels(): IMirrorModel[];\n}\n\n/**\n * Range of a word inside a model.\n * @internal\n */\nexport interface IWordRange {\n\t/**\n\t * The index where the word starts.\n\t */\n\treadonly start: number;\n\t/**\n\t * The index where the word ends.\n\t */\n\treadonly end: number;\n}\n\n/**\n * @internal\n */\nexport class EditorWorker implements IDisposable, IWorkerTextModelSyncChannelServer, IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: any;\n\n\tprivate readonly _workerTextModelSyncServer = new WorkerTextModelSyncServer();\n\n\tconstructor(\n\t\tprivate readonly _foreignModule: any | null = null\n\t) { }\n\n\tdispose(): void {\n\t}\n\n\tpublic async $ping() {\n\t\treturn 'pong';\n\t}\n\n\tprotected _getModel(uri: string): ICommonModel | undefined {\n\t\treturn this._workerTextModelSyncServer.getModel(uri);\n\t}\n\n\tpublic getModels(): ICommonModel[] {\n\t\treturn this._workerTextModelSyncServer.getModels();\n\t}\n\n\tpublic $acceptNewModel(data: IRawModelData): void {\n\t\tthis._workerTextModelSyncServer.$acceptNewModel(data);\n\t}\n\n\tpublic $acceptModelChanged(uri: string, e: IModelChangedEvent): void {\n\t\tthis._workerTextModelSyncServer.$acceptModelChanged(uri, e);\n\t}\n\n\tpublic $acceptRemovedModel(uri: string): void {\n\t\tthis._workerTextModelSyncServer.$acceptRemovedModel(uri);\n\t}\n\n\tpublic async $computeUnicodeHighlights(url: string, options: UnicodeHighlighterOptions, range?: IRange): Promise<IUnicodeHighlightsResult> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };\n\t\t}\n\t\treturn UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);\n\t}\n\n\tpublic async $findSectionHeaders(url: string, options: FindSectionHeaderOptions): Promise<SectionHeader[]> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn [];\n\t\t}\n\t\treturn findSectionHeaders(model, options);\n\t}\n\n\t// ---- BEGIN diff --------------------------------------------------------------------------\n\n\tpublic async $computeDiff(originalUrl: string, modifiedUrl: string, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): Promise<IDiffComputationResult | null> {\n\t\tconst original = this._getModel(originalUrl);\n\t\tconst modified = this._getModel(modifiedUrl);\n\t\tif (!original || !modified) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst result = EditorWorker.computeDiff(original, modified, options, algorithm);\n\t\treturn result;\n\t}\n\n\tprivate static computeDiff(originalTextModel: ICommonModel | ITextModel, modifiedTextModel: ICommonModel | ITextModel, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): IDiffComputationResult {\n\t\tconst diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.getDefault() : linesDiffComputers.getLegacy();\n\n\t\tconst originalLines = originalTextModel.getLinesContent();\n\t\tconst modifiedLines = modifiedTextModel.getLinesContent();\n\n\t\tconst result = diffAlgorithm.computeDiff(originalLines, modifiedLines, options);\n\n\t\tconst identical = (result.changes.length > 0 ? false : this._modelsAreIdentical(originalTextModel, modifiedTextModel));\n\n\t\tfunction getLineChanges(changes: readonly DetailedLineRangeMapping[]): ILineChange[] {\n\t\t\treturn changes.map(m => ([m.original.startLineNumber, m.original.endLineNumberExclusive, m.modified.startLineNumber, m.modified.endLineNumberExclusive, m.innerChanges?.map(m => [\n\t\t\t\tm.originalRange.startLineNumber,\n\t\t\t\tm.originalRange.startColumn,\n\t\t\t\tm.originalRange.endLineNumber,\n\t\t\t\tm.originalRange.endColumn,\n\t\t\t\tm.modifiedRange.startLineNumber,\n\t\t\t\tm.modifiedRange.startColumn,\n\t\t\t\tm.modifiedRange.endLineNumber,\n\t\t\t\tm.modifiedRange.endColumn,\n\t\t\t])]));\n\t\t}\n\n\t\treturn {\n\t\t\tidentical,\n\t\t\tquitEarly: result.hitTimeout,\n\t\t\tchanges: getLineChanges(result.changes),\n\t\t\tmoves: result.moves.map(m => ([\n\t\t\t\tm.lineRangeMapping.original.startLineNumber,\n\t\t\t\tm.lineRangeMapping.original.endLineNumberExclusive,\n\t\t\t\tm.lineRangeMapping.modified.startLineNumber,\n\t\t\t\tm.lineRangeMapping.modified.endLineNumberExclusive,\n\t\t\t\tgetLineChanges(m.changes)\n\t\t\t])),\n\t\t};\n\t}\n\n\tprivate static _modelsAreIdentical(original: ICommonModel | ITextModel, modified: ICommonModel | ITextModel): boolean {\n\t\tconst originalLineCount = original.getLineCount();\n\t\tconst modifiedLineCount = modified.getLineCount();\n\t\tif (originalLineCount !== modifiedLineCount) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let line = 1; line <= originalLineCount; line++) {\n\t\t\tconst originalLine = original.getLineContent(line);\n\t\t\tconst modifiedLine = modified.getLineContent(line);\n\t\t\tif (originalLine !== modifiedLine) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ---- END diff --------------------------------------------------------------------------\n\n\n\t// ---- BEGIN minimal edits ---------------------------------------------------------------\n\n\tprivate static readonly _diffLimit = 100000;\n\n\tpublic async $computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): Promise<TextEdit[]> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn edits;\n\t\t}\n\n\t\tconst result: TextEdit[] = [];\n\t\tlet lastEol: EndOfLineSequence | undefined = undefined;\n\n\t\tedits = edits.slice(0).sort((a, b) => {\n\t\t\tif (a.range && b.range) {\n\t\t\t\treturn Range.compareRangesUsingStarts(a.range, b.range);\n\t\t\t}\n\t\t\t// eol only changes should go to the end\n\t\t\tconst aRng = a.range ? 0 : 1;\n\t\t\tconst bRng = b.range ? 0 : 1;\n\t\t\treturn aRng - bRng;\n\t\t});\n\n\t\t// merge adjacent edits\n\t\tlet writeIndex = 0;\n\t\tfor (let readIndex = 1; readIndex < edits.length; readIndex++) {\n\t\t\tif (Range.getEndPosition(edits[writeIndex].range).equals(Range.getStartPosition(edits[readIndex].range))) {\n\t\t\t\tedits[writeIndex].range = Range.fromPositions(Range.getStartPosition(edits[writeIndex].range), Range.getEndPosition(edits[readIndex].range));\n\t\t\t\tedits[writeIndex].text += edits[readIndex].text;\n\t\t\t} else {\n\t\t\t\twriteIndex++;\n\t\t\t\tedits[writeIndex] = edits[readIndex];\n\t\t\t}\n\t\t}\n\t\tedits.length = writeIndex + 1;\n\n\t\tfor (let { range, text, eol } of edits) {\n\n\t\t\tif (typeof eol === 'number') {\n\t\t\t\tlastEol = eol;\n\t\t\t}\n\n\t\t\tif (Range.isEmpty(range) && !text) {\n\t\t\t\t// empty change\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst original = model.getValueInRange(range);\n\t\t\ttext = text.replace(/\\r\\n|\\n|\\r/g, model.eol);\n\n\t\t\tif (original === text) {\n\t\t\t\t// noop\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// make sure diff won't take too long\n\t\t\tif (Math.max(text.length, original.length) > EditorWorker._diffLimit) {\n\t\t\t\tresult.push({ range, text });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// compute diff between original and edit.text\n\t\t\tconst changes = stringDiff(original, text, pretty);\n\t\t\tconst editOffset = model.offsetAt(Range.lift(range).getStartPosition());\n\n\t\t\tfor (const change of changes) {\n\t\t\t\tconst start = model.positionAt(editOffset + change.originalStart);\n\t\t\t\tconst end = model.positionAt(editOffset + change.originalStart + change.originalLength);\n\t\t\t\tconst newEdit: TextEdit = {\n\t\t\t\t\ttext: text.substr(change.modifiedStart, change.modifiedLength),\n\t\t\t\t\trange: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }\n\t\t\t\t};\n\n\t\t\t\tif (model.getValueInRange(newEdit.range) !== newEdit.text) {\n\t\t\t\t\tresult.push(newEdit);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof lastEol === 'number') {\n\t\t\tresult.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// ---- END minimal edits ---------------------------------------------------------------\n\n\tpublic async $computeLinks(modelUrl: string): Promise<ILink[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn computeLinks(model);\n\t}\n\n\t// --- BEGIN default document colors -----------------------------------------------------------\n\n\tpublic async $computeDefaultDocumentColors(modelUrl: string): Promise<IColorInformation[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\t\treturn computeDefaultDocumentColors(model);\n\t}\n\n\t// ---- BEGIN suggest --------------------------------------------------------------------------\n\n\tprivate static readonly _suggestionsLimit = 10000;\n\n\tpublic async $textualSuggest(modelUrls: string[], leadingWord: string | undefined, wordDef: string, wordDefFlags: string): Promise<{ words: string[]; duration: number } | null> {\n\n\t\tconst sw = new StopWatch();\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst seen = new Set<string>();\n\n\t\touter: for (const url of modelUrls) {\n\t\t\tconst model = this._getModel(url);\n\t\t\tif (!model) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const word of model.words(wordDefRegExp)) {\n\t\t\t\tif (word === leadingWord || !isNaN(Number(word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseen.add(word);\n\t\t\t\tif (seen.size > EditorWorker._suggestionsLimit) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { words: Array.from(seen), duration: sw.elapsed() };\n\t}\n\n\n\t// ---- END suggest --------------------------------------------------------------------------\n\n\t//#region -- word ranges --\n\n\tpublic async $computeWordRanges(modelUrl: string, range: IRange, wordDef: string, wordDefFlags: string): Promise<{ [word: string]: IRange[] }> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn Object.create(null);\n\t\t}\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst result: { [word: string]: IRange[] } = Object.create(null);\n\t\tfor (let line = range.startLineNumber; line < range.endLineNumber; line++) {\n\t\t\tconst words = model.getLineWords(line, wordDefRegExp);\n\t\t\tfor (const word of words) {\n\t\t\t\tif (!isNaN(Number(word.word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet array = result[word.word];\n\t\t\t\tif (!array) {\n\t\t\t\t\tarray = [];\n\t\t\t\t\tresult[word.word] = array;\n\t\t\t\t}\n\t\t\t\tarray.push({\n\t\t\t\t\tstartLineNumber: line,\n\t\t\t\t\tstartColumn: word.startColumn,\n\t\t\t\t\tendLineNumber: line,\n\t\t\t\t\tendColumn: word.endColumn\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t//#endregion\n\n\tpublic async $navigateValueSet(modelUrl: string, range: IRange, up: boolean, wordDef: string, wordDefFlags: string): Promise<IInplaceReplaceSupportResult | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\n\t\tif (range.startColumn === range.endColumn) {\n\t\t\trange = {\n\t\t\t\tstartLineNumber: range.startLineNumber,\n\t\t\t\tstartColumn: range.startColumn,\n\t\t\t\tendLineNumber: range.endLineNumber,\n\t\t\t\tendColumn: range.endColumn + 1\n\t\t\t};\n\t\t}\n\n\t\tconst selectionText = model.getValueInRange(range);\n\n\t\tconst wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);\n\t\tif (!wordRange) {\n\t\t\treturn null;\n\t\t}\n\t\tconst word = model.getValueInRange(wordRange);\n\t\tconst result = BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);\n\t\treturn result;\n\t}\n\n\t// ---- BEGIN foreign module support --------------------------------------------------------------------------\n\n\t// foreign method request\n\tpublic $fmr(method: string, args: any[]): Promise<any> {\n\t\tif (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error('Missing requestHandler or method: ' + method));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\t// ---- END foreign module support --------------------------------------------------------------------------\n}\n\n// This is only available in a Web Worker\ndeclare function importScripts(...urls: string[]): void;\n\nif (typeof importScripts === 'function') {\n\t// Running in a web worker\n\tglobalThis.monaco = createMonacoBaseAPI();\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { stringDiff } from '../../../base/common/diff/diff.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IWebWorkerServerRequestHandler } from '../../../base/common/worker/webWorker.js';\nimport { IRange, Range } from '../core/range.js';\nimport { EndOfLineSequence, ITextModel } from '../model.js';\nimport { IMirrorTextModel, IModelChangedEvent } from '../model/mirrorTextModel.js';\nimport { IColorInformation, IInplaceReplaceSupportResult, ILink, TextEdit } from '../languages.js';\nimport { computeLinks } from '../languages/linkComputer.js';\nimport { BasicInplaceReplace } from '../languages/supports/inplaceReplaceSupport.js';\nimport { DiffAlgorithmName, IDiffComputationResult, ILineChange, IUnicodeHighlightsResult } from './editorWorker.js';\nimport { createMonacoBaseAPI } from './editorBaseApi.js';\nimport { StopWatch } from '../../../base/common/stopwatch.js';\nimport { UnicodeTextModelHighlighter, UnicodeHighlighterOptions } from './unicodeTextModelHighlighter.js';\nimport { ILinesDiffComputer } from '../diff/linesDiffComputer.js';\nimport { DetailedLineRangeMapping } from '../diff/rangeMapping.js';\nimport { linesDiffComputers } from '../diff/linesDiffComputers.js';\nimport { IDocumentDiffProviderOptions } from '../diff/documentDiffProvider.js';\nimport { computeDefaultDocumentColors } from '../languages/defaultDocumentColorsComputer.js';\nimport { FindSectionHeaderOptions, SectionHeader, findSectionHeaders } from './findSectionHeaders.js';\nimport { IRawModelData, IWorkerTextModelSyncChannelServer } from './textModelSync/textModelSync.protocol.js';\nimport { ICommonModel, WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';\n\nexport interface IMirrorModel extends IMirrorTextModel {\n\treadonly uri: URI;\n\treadonly version: number;\n\tgetValue(): string;\n}\n\nexport interface IWorkerContext<H = {}> {\n\t/**\n\t * A proxy to the main thread host object.\n\t */\n\thost: H;\n\t/**\n\t * Get all available mirror models in this worker.\n\t */\n\tgetMirrorModels(): IMirrorModel[];\n}\n\n/**\n * Range of a word inside a model.\n * @internal\n */\nexport interface IWordRange {\n\t/**\n\t * The index where the word starts.\n\t */\n\treadonly start: number;\n\t/**\n\t * The index where the word ends.\n\t */\n\treadonly end: number;\n}\n\n/**\n * @internal\n */\nexport class EditorWorker implements IDisposable, IWorkerTextModelSyncChannelServer, IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: any;\n\n\tprivate readonly _workerTextModelSyncServer = new WorkerTextModelSyncServer();\n\n\tconstructor(\n\t\tprivate readonly _foreignModule: any | null = null\n\t) { }\n\n\tdispose(): void {\n\t}\n\n\tpublic async $ping() {\n\t\treturn 'pong';\n\t}\n\n\tprotected _getModel(uri: string): ICommonModel | undefined {\n\t\treturn this._workerTextModelSyncServer.getModel(uri);\n\t}\n\n\tpublic getModels(): ICommonModel[] {\n\t\treturn this._workerTextModelSyncServer.getModels();\n\t}\n\n\tpublic $acceptNewModel(data: IRawModelData): void {\n\t\tthis._workerTextModelSyncServer.$acceptNewModel(data);\n\t}\n\n\tpublic $acceptModelChanged(uri: string, e: IModelChangedEvent): void {\n\t\tthis._workerTextModelSyncServer.$acceptModelChanged(uri, e);\n\t}\n\n\tpublic $acceptRemovedModel(uri: string): void {\n\t\tthis._workerTextModelSyncServer.$acceptRemovedModel(uri);\n\t}\n\n\tpublic async $computeUnicodeHighlights(url: string, options: UnicodeHighlighterOptions, range?: IRange): Promise<IUnicodeHighlightsResult> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };\n\t\t}\n\t\treturn UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);\n\t}\n\n\tpublic async $findSectionHeaders(url: string, options: FindSectionHeaderOptions): Promise<SectionHeader[]> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn [];\n\t\t}\n\t\treturn findSectionHeaders(model, options);\n\t}\n\n\t// ---- BEGIN diff --------------------------------------------------------------------------\n\n\tpublic async $computeDiff(originalUrl: string, modifiedUrl: string, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): Promise<IDiffComputationResult | null> {\n\t\tconst original = this._getModel(originalUrl);\n\t\tconst modified = this._getModel(modifiedUrl);\n\t\tif (!original || !modified) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst result = EditorWorker.computeDiff(original, modified, options, algorithm);\n\t\treturn result;\n\t}\n\n\tprivate static computeDiff(originalTextModel: ICommonModel | ITextModel, modifiedTextModel: ICommonModel | ITextModel, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): IDiffComputationResult {\n\t\tconst diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.getDefault() : linesDiffComputers.getLegacy();\n\n\t\tconst originalLines = originalTextModel.getLinesContent();\n\t\tconst modifiedLines = modifiedTextModel.getLinesContent();\n\n\t\tconst result = diffAlgorithm.computeDiff(originalLines, modifiedLines, options);\n\n\t\tconst identical = (result.changes.length > 0 ? false : this._modelsAreIdentical(originalTextModel, modifiedTextModel));\n\n\t\tfunction getLineChanges(changes: readonly DetailedLineRangeMapping[]): ILineChange[] {\n\t\t\treturn changes.map(m => ([m.original.startLineNumber, m.original.endLineNumberExclusive, m.modified.startLineNumber, m.modified.endLineNumberExclusive, m.innerChanges?.map(m => [\n\t\t\t\tm.originalRange.startLineNumber,\n\t\t\t\tm.originalRange.startColumn,\n\t\t\t\tm.originalRange.endLineNumber,\n\t\t\t\tm.originalRange.endColumn,\n\t\t\t\tm.modifiedRange.startLineNumber,\n\t\t\t\tm.modifiedRange.startColumn,\n\t\t\t\tm.modifiedRange.endLineNumber,\n\t\t\t\tm.modifiedRange.endColumn,\n\t\t\t])]));\n\t\t}\n\n\t\treturn {\n\t\t\tidentical,\n\t\t\tquitEarly: result.hitTimeout,\n\t\t\tchanges: getLineChanges(result.changes),\n\t\t\tmoves: result.moves.map(m => ([\n\t\t\t\tm.lineRangeMapping.original.startLineNumber,\n\t\t\t\tm.lineRangeMapping.original.endLineNumberExclusive,\n\t\t\t\tm.lineRangeMapping.modified.startLineNumber,\n\t\t\t\tm.lineRangeMapping.modified.endLineNumberExclusive,\n\t\t\t\tgetLineChanges(m.changes)\n\t\t\t])),\n\t\t};\n\t}\n\n\tprivate static _modelsAreIdentical(original: ICommonModel | ITextModel, modified: ICommonModel | ITextModel): boolean {\n\t\tconst originalLineCount = original.getLineCount();\n\t\tconst modifiedLineCount = modified.getLineCount();\n\t\tif (originalLineCount !== modifiedLineCount) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let line = 1; line <= originalLineCount; line++) {\n\t\t\tconst originalLine = original.getLineContent(line);\n\t\t\tconst modifiedLine = modified.getLineContent(line);\n\t\t\tif (originalLine !== modifiedLine) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ---- END diff --------------------------------------------------------------------------\n\n\n\t// ---- BEGIN minimal edits ---------------------------------------------------------------\n\n\tprivate static readonly _diffLimit = 100000;\n\n\tpublic async $computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): Promise<TextEdit[]> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn edits;\n\t\t}\n\n\t\tconst result: TextEdit[] = [];\n\t\tlet lastEol: EndOfLineSequence | undefined = undefined;\n\n\t\tedits = edits.slice(0).sort((a, b) => {\n\t\t\tif (a.range && b.range) {\n\t\t\t\treturn Range.compareRangesUsingStarts(a.range, b.range);\n\t\t\t}\n\t\t\t// eol only changes should go to the end\n\t\t\tconst aRng = a.range ? 0 : 1;\n\t\t\tconst bRng = b.range ? 0 : 1;\n\t\t\treturn aRng - bRng;\n\t\t});\n\n\t\t// merge adjacent edits\n\t\tlet writeIndex = 0;\n\t\tfor (let readIndex = 1; readIndex < edits.length; readIndex++) {\n\t\t\tif (Range.getEndPosition(edits[writeIndex].range).equals(Range.getStartPosition(edits[readIndex].range))) {\n\t\t\t\tedits[writeIndex].range = Range.fromPositions(Range.getStartPosition(edits[writeIndex].range), Range.getEndPosition(edits[readIndex].range));\n\t\t\t\tedits[writeIndex].text += edits[readIndex].text;\n\t\t\t} else {\n\t\t\t\twriteIndex++;\n\t\t\t\tedits[writeIndex] = edits[readIndex];\n\t\t\t}\n\t\t}\n\t\tedits.length = writeIndex + 1;\n\n\t\tfor (let { range, text, eol } of edits) {\n\n\t\t\tif (typeof eol === 'number') {\n\t\t\t\tlastEol = eol;\n\t\t\t}\n\n\t\t\tif (Range.isEmpty(range) && !text) {\n\t\t\t\t// empty change\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst original = model.getValueInRange(range);\n\t\t\ttext = text.replace(/\\r\\n|\\n|\\r/g, model.eol);\n\n\t\t\tif (original === text) {\n\t\t\t\t// noop\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// make sure diff won't take too long\n\t\t\tif (Math.max(text.length, original.length) > EditorWorker._diffLimit) {\n\t\t\t\tresult.push({ range, text });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// compute diff between original and edit.text\n\t\t\tconst changes = stringDiff(original, text, pretty);\n\t\t\tconst editOffset = model.offsetAt(Range.lift(range).getStartPosition());\n\n\t\t\tfor (const change of changes) {\n\t\t\t\tconst start = model.positionAt(editOffset + change.originalStart);\n\t\t\t\tconst end = model.positionAt(editOffset + change.originalStart + change.originalLength);\n\t\t\t\tconst newEdit: TextEdit = {\n\t\t\t\t\ttext: text.substr(change.modifiedStart, change.modifiedLength),\n\t\t\t\t\trange: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }\n\t\t\t\t};\n\n\t\t\t\tif (model.getValueInRange(newEdit.range) !== newEdit.text) {\n\t\t\t\t\tresult.push(newEdit);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof lastEol === 'number') {\n\t\t\tresult.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// ---- END minimal edits ---------------------------------------------------------------\n\n\tpublic async $computeLinks(modelUrl: string): Promise<ILink[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn computeLinks(model);\n\t}\n\n\t// --- BEGIN default document colors -----------------------------------------------------------\n\n\tpublic async $computeDefaultDocumentColors(modelUrl: string): Promise<IColorInformation[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\t\treturn computeDefaultDocumentColors(model);\n\t}\n\n\t// ---- BEGIN suggest --------------------------------------------------------------------------\n\n\tprivate static readonly _suggestionsLimit = 10000;\n\n\tpublic async $textualSuggest(modelUrls: string[], leadingWord: string | undefined, wordDef: string, wordDefFlags: string): Promise<{ words: string[]; duration: number } | null> {\n\n\t\tconst sw = new StopWatch();\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst seen = new Set<string>();\n\n\t\touter: for (const url of modelUrls) {\n\t\t\tconst model = this._getModel(url);\n\t\t\tif (!model) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const word of model.words(wordDefRegExp)) {\n\t\t\t\tif (word === leadingWord || !isNaN(Number(word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseen.add(word);\n\t\t\t\tif (seen.size > EditorWorker._suggestionsLimit) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { words: Array.from(seen), duration: sw.elapsed() };\n\t}\n\n\n\t// ---- END suggest --------------------------------------------------------------------------\n\n\t//#region -- word ranges --\n\n\tpublic async $computeWordRanges(modelUrl: string, range: IRange, wordDef: string, wordDefFlags: string): Promise<{ [word: string]: IRange[] }> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn Object.create(null);\n\t\t}\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst result: { [word: string]: IRange[] } = Object.create(null);\n\t\tfor (let line = range.startLineNumber; line < range.endLineNumber; line++) {\n\t\t\tconst words = model.getLineWords(line, wordDefRegExp);\n\t\t\tfor (const word of words) {\n\t\t\t\tif (!isNaN(Number(word.word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet array = result[word.word];\n\t\t\t\tif (!array) {\n\t\t\t\t\tarray = [];\n\t\t\t\t\tresult[word.word] = array;\n\t\t\t\t}\n\t\t\t\tarray.push({\n\t\t\t\t\tstartLineNumber: line,\n\t\t\t\t\tstartColumn: word.startColumn,\n\t\t\t\t\tendLineNumber: line,\n\t\t\t\t\tendColumn: word.endColumn\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t//#endregion\n\n\tpublic async $navigateValueSet(modelUrl: string, range: IRange, up: boolean, wordDef: string, wordDefFlags: string): Promise<IInplaceReplaceSupportResult | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\n\t\tif (range.startColumn === range.endColumn) {\n\t\t\trange = {\n\t\t\t\tstartLineNumber: range.startLineNumber,\n\t\t\t\tstartColumn: range.startColumn,\n\t\t\t\tendLineNumber: range.endLineNumber,\n\t\t\t\tendColumn: range.endColumn + 1\n\t\t\t};\n\t\t}\n\n\t\tconst selectionText = model.getValueInRange(range);\n\n\t\tconst wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);\n\t\tif (!wordRange) {\n\t\t\treturn null;\n\t\t}\n\t\tconst word = model.getValueInRange(wordRange);\n\t\tconst result = BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);\n\t\treturn result;\n\t}\n\n\t// ---- BEGIN foreign module support --------------------------------------------------------------------------\n\n\t// foreign method request\n\tpublic $fmr(method: string, args: any[]): Promise<any> {\n\t\tif (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error('Missing requestHandler or method: ' + method));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\t// ---- END foreign module support --------------------------------------------------------------------------\n}\n\n// This is only available in a Web Worker\ndeclare function importScripts(...urls: string[]): void;\n\nif (typeof importScripts === 'function') {\n\t// Running in a web worker\n\tglobalThis.monaco = createMonacoBaseAPI();\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/editorWebWorker.ts","vs/editor/common/services/editorWebWorker.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAI/D,OAAO,EAAU,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAA6B,MAAM,kCAAkC,CAAC;AAG1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAA2C,kBAAkB,EAAE,MAAM,yBAAyB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CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;QACpH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;;AAQF,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;IACzC,0BAA0B;IAC1B,UAAU,CAAC,MAAM,GAAG,mBAAmB,EAAE,CAAC;AAC3C,CAAC","file":"editorWebWorker.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { stringDiff } from '../../../base/common/diff/diff.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IWebWorkerServerRequestHandler } from '../../../base/common/worker/webWorker.js';\nimport { IRange, Range } from '../core/range.js';\nimport { EndOfLineSequence, ITextModel } from '../model.js';\nimport { IMirrorTextModel, IModelChangedEvent } from '../model/mirrorTextModel.js';\nimport { IColorInformation, IInplaceReplaceSupportResult, ILink, TextEdit } from '../languages.js';\nimport { computeLinks } from '../languages/linkComputer.js';\nimport { BasicInplaceReplace } from '../languages/supports/inplaceReplaceSupport.js';\nimport { DiffAlgorithmName, IDiffComputationResult, ILineChange, IUnicodeHighlightsResult } from './editorWorker.js';\nimport { createMonacoBaseAPI } from './editorBaseApi.js';\nimport { StopWatch } from '../../../base/common/stopwatch.js';\nimport { UnicodeTextModelHighlighter, UnicodeHighlighterOptions } from './unicodeTextModelHighlighter.js';\nimport { ILinesDiffComputer } from '../diff/linesDiffComputer.js';\nimport { DetailedLineRangeMapping } from '../diff/rangeMapping.js';\nimport { linesDiffComputers } from '../diff/linesDiffComputers.js';\nimport { IDocumentDiffProviderOptions } from '../diff/documentDiffProvider.js';\nimport { computeDefaultDocumentColors } from '../languages/defaultDocumentColorsComputer.js';\nimport { FindSectionHeaderOptions, SectionHeader, findSectionHeaders } from './findSectionHeaders.js';\nimport { IRawModelData, IWorkerTextModelSyncChannelServer } from './textModelSync/textModelSync.protocol.js';\nimport { ICommonModel, WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';\n\nexport interface IMirrorModel extends IMirrorTextModel {\n\treadonly uri: URI;\n\treadonly version: number;\n\tgetValue(): string;\n}\n\nexport interface IWorkerContext<H = {}> {\n\t/**\n\t * A proxy to the main thread host object.\n\t */\n\thost: H;\n\t/**\n\t * Get all available mirror models in this worker.\n\t */\n\tgetMirrorModels(): IMirrorModel[];\n}\n\n/**\n * Range of a word inside a model.\n * @internal\n */\nexport interface IWordRange {\n\t/**\n\t * The index where the word starts.\n\t */\n\treadonly start: number;\n\t/**\n\t * The index where the word ends.\n\t */\n\treadonly end: number;\n}\n\n/**\n * @internal\n */\nexport class EditorWorker implements IDisposable, IWorkerTextModelSyncChannelServer, IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: void = undefined;\n\n\tprivate readonly _workerTextModelSyncServer = new WorkerTextModelSyncServer();\n\n\tconstructor(\n\t\tprivate readonly _foreignModule: unknown | null = null\n\t) { }\n\n\tdispose(): void {\n\t}\n\n\tpublic async $ping() {\n\t\treturn 'pong';\n\t}\n\n\tprotected _getModel(uri: string): ICommonModel | undefined {\n\t\treturn this._workerTextModelSyncServer.getModel(uri);\n\t}\n\n\tpublic getModels(): ICommonModel[] {\n\t\treturn this._workerTextModelSyncServer.getModels();\n\t}\n\n\tpublic $acceptNewModel(data: IRawModelData): void {\n\t\tthis._workerTextModelSyncServer.$acceptNewModel(data);\n\t}\n\n\tpublic $acceptModelChanged(uri: string, e: IModelChangedEvent): void {\n\t\tthis._workerTextModelSyncServer.$acceptModelChanged(uri, e);\n\t}\n\n\tpublic $acceptRemovedModel(uri: string): void {\n\t\tthis._workerTextModelSyncServer.$acceptRemovedModel(uri);\n\t}\n\n\tpublic async $computeUnicodeHighlights(url: string, options: UnicodeHighlighterOptions, range?: IRange): Promise<IUnicodeHighlightsResult> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };\n\t\t}\n\t\treturn UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);\n\t}\n\n\tpublic async $findSectionHeaders(url: string, options: FindSectionHeaderOptions): Promise<SectionHeader[]> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn [];\n\t\t}\n\t\treturn findSectionHeaders(model, options);\n\t}\n\n\t// ---- BEGIN diff --------------------------------------------------------------------------\n\n\tpublic async $computeDiff(originalUrl: string, modifiedUrl: string, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): Promise<IDiffComputationResult | null> {\n\t\tconst original = this._getModel(originalUrl);\n\t\tconst modified = this._getModel(modifiedUrl);\n\t\tif (!original || !modified) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst result = EditorWorker.computeDiff(original, modified, options, algorithm);\n\t\treturn result;\n\t}\n\n\tprivate static computeDiff(originalTextModel: ICommonModel | ITextModel, modifiedTextModel: ICommonModel | ITextModel, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): IDiffComputationResult {\n\t\tconst diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.getDefault() : linesDiffComputers.getLegacy();\n\n\t\tconst originalLines = originalTextModel.getLinesContent();\n\t\tconst modifiedLines = modifiedTextModel.getLinesContent();\n\n\t\tconst result = diffAlgorithm.computeDiff(originalLines, modifiedLines, options);\n\n\t\tconst identical = (result.changes.length > 0 ? false : this._modelsAreIdentical(originalTextModel, modifiedTextModel));\n\n\t\tfunction getLineChanges(changes: readonly DetailedLineRangeMapping[]): ILineChange[] {\n\t\t\treturn changes.map(m => ([m.original.startLineNumber, m.original.endLineNumberExclusive, m.modified.startLineNumber, m.modified.endLineNumberExclusive, m.innerChanges?.map(m => [\n\t\t\t\tm.originalRange.startLineNumber,\n\t\t\t\tm.originalRange.startColumn,\n\t\t\t\tm.originalRange.endLineNumber,\n\t\t\t\tm.originalRange.endColumn,\n\t\t\t\tm.modifiedRange.startLineNumber,\n\t\t\t\tm.modifiedRange.startColumn,\n\t\t\t\tm.modifiedRange.endLineNumber,\n\t\t\t\tm.modifiedRange.endColumn,\n\t\t\t])]));\n\t\t}\n\n\t\treturn {\n\t\t\tidentical,\n\t\t\tquitEarly: result.hitTimeout,\n\t\t\tchanges: getLineChanges(result.changes),\n\t\t\tmoves: result.moves.map(m => ([\n\t\t\t\tm.lineRangeMapping.original.startLineNumber,\n\t\t\t\tm.lineRangeMapping.original.endLineNumberExclusive,\n\t\t\t\tm.lineRangeMapping.modified.startLineNumber,\n\t\t\t\tm.lineRangeMapping.modified.endLineNumberExclusive,\n\t\t\t\tgetLineChanges(m.changes)\n\t\t\t])),\n\t\t};\n\t}\n\n\tprivate static _modelsAreIdentical(original: ICommonModel | ITextModel, modified: ICommonModel | ITextModel): boolean {\n\t\tconst originalLineCount = original.getLineCount();\n\t\tconst modifiedLineCount = modified.getLineCount();\n\t\tif (originalLineCount !== modifiedLineCount) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let line = 1; line <= originalLineCount; line++) {\n\t\t\tconst originalLine = original.getLineContent(line);\n\t\t\tconst modifiedLine = modified.getLineContent(line);\n\t\t\tif (originalLine !== modifiedLine) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ---- END diff --------------------------------------------------------------------------\n\n\n\t// ---- BEGIN minimal edits ---------------------------------------------------------------\n\n\tprivate static readonly _diffLimit = 100000;\n\n\tpublic async $computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): Promise<TextEdit[]> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn edits;\n\t\t}\n\n\t\tconst result: TextEdit[] = [];\n\t\tlet lastEol: EndOfLineSequence | undefined = undefined;\n\n\t\tedits = edits.slice(0).sort((a, b) => {\n\t\t\tif (a.range && b.range) {\n\t\t\t\treturn Range.compareRangesUsingStarts(a.range, b.range);\n\t\t\t}\n\t\t\t// eol only changes should go to the end\n\t\t\tconst aRng = a.range ? 0 : 1;\n\t\t\tconst bRng = b.range ? 0 : 1;\n\t\t\treturn aRng - bRng;\n\t\t});\n\n\t\t// merge adjacent edits\n\t\tlet writeIndex = 0;\n\t\tfor (let readIndex = 1; readIndex < edits.length; readIndex++) {\n\t\t\tif (Range.getEndPosition(edits[writeIndex].range).equals(Range.getStartPosition(edits[readIndex].range))) {\n\t\t\t\tedits[writeIndex].range = Range.fromPositions(Range.getStartPosition(edits[writeIndex].range), Range.getEndPosition(edits[readIndex].range));\n\t\t\t\tedits[writeIndex].text += edits[readIndex].text;\n\t\t\t} else {\n\t\t\t\twriteIndex++;\n\t\t\t\tedits[writeIndex] = edits[readIndex];\n\t\t\t}\n\t\t}\n\t\tedits.length = writeIndex + 1;\n\n\t\tfor (let { range, text, eol } of edits) {\n\n\t\t\tif (typeof eol === 'number') {\n\t\t\t\tlastEol = eol;\n\t\t\t}\n\n\t\t\tif (Range.isEmpty(range) && !text) {\n\t\t\t\t// empty change\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst original = model.getValueInRange(range);\n\t\t\ttext = text.replace(/\\r\\n|\\n|\\r/g, model.eol);\n\n\t\t\tif (original === text) {\n\t\t\t\t// noop\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// make sure diff won't take too long\n\t\t\tif (Math.max(text.length, original.length) > EditorWorker._diffLimit) {\n\t\t\t\tresult.push({ range, text });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// compute diff between original and edit.text\n\t\t\tconst changes = stringDiff(original, text, pretty);\n\t\t\tconst editOffset = model.offsetAt(Range.lift(range).getStartPosition());\n\n\t\t\tfor (const change of changes) {\n\t\t\t\tconst start = model.positionAt(editOffset + change.originalStart);\n\t\t\t\tconst end = model.positionAt(editOffset + change.originalStart + change.originalLength);\n\t\t\t\tconst newEdit: TextEdit = {\n\t\t\t\t\ttext: text.substr(change.modifiedStart, change.modifiedLength),\n\t\t\t\t\trange: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }\n\t\t\t\t};\n\n\t\t\t\tif (model.getValueInRange(newEdit.range) !== newEdit.text) {\n\t\t\t\t\tresult.push(newEdit);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof lastEol === 'number') {\n\t\t\tresult.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// ---- END minimal edits ---------------------------------------------------------------\n\n\tpublic async $computeLinks(modelUrl: string): Promise<ILink[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn computeLinks(model);\n\t}\n\n\t// --- BEGIN default document colors -----------------------------------------------------------\n\n\tpublic async $computeDefaultDocumentColors(modelUrl: string): Promise<IColorInformation[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\t\treturn computeDefaultDocumentColors(model);\n\t}\n\n\t// ---- BEGIN suggest --------------------------------------------------------------------------\n\n\tprivate static readonly _suggestionsLimit = 10000;\n\n\tpublic async $textualSuggest(modelUrls: string[], leadingWord: string | undefined, wordDef: string, wordDefFlags: string): Promise<{ words: string[]; duration: number } | null> {\n\n\t\tconst sw = new StopWatch();\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst seen = new Set<string>();\n\n\t\touter: for (const url of modelUrls) {\n\t\t\tconst model = this._getModel(url);\n\t\t\tif (!model) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const word of model.words(wordDefRegExp)) {\n\t\t\t\tif (word === leadingWord || !isNaN(Number(word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseen.add(word);\n\t\t\t\tif (seen.size > EditorWorker._suggestionsLimit) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { words: Array.from(seen), duration: sw.elapsed() };\n\t}\n\n\n\t// ---- END suggest --------------------------------------------------------------------------\n\n\t//#region -- word ranges --\n\n\tpublic async $computeWordRanges(modelUrl: string, range: IRange, wordDef: string, wordDefFlags: string): Promise<{ [word: string]: IRange[] }> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn Object.create(null);\n\t\t}\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst result: { [word: string]: IRange[] } = Object.create(null);\n\t\tfor (let line = range.startLineNumber; line < range.endLineNumber; line++) {\n\t\t\tconst words = model.getLineWords(line, wordDefRegExp);\n\t\t\tfor (const word of words) {\n\t\t\t\tif (!isNaN(Number(word.word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet array = result[word.word];\n\t\t\t\tif (!array) {\n\t\t\t\t\tarray = [];\n\t\t\t\t\tresult[word.word] = array;\n\t\t\t\t}\n\t\t\t\tarray.push({\n\t\t\t\t\tstartLineNumber: line,\n\t\t\t\t\tstartColumn: word.startColumn,\n\t\t\t\t\tendLineNumber: line,\n\t\t\t\t\tendColumn: word.endColumn\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t//#endregion\n\n\tpublic async $navigateValueSet(modelUrl: string, range: IRange, up: boolean, wordDef: string, wordDefFlags: string): Promise<IInplaceReplaceSupportResult | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\n\t\tif (range.startColumn === range.endColumn) {\n\t\t\trange = {\n\t\t\t\tstartLineNumber: range.startLineNumber,\n\t\t\t\tstartColumn: range.startColumn,\n\t\t\t\tendLineNumber: range.endLineNumber,\n\t\t\t\tendColumn: range.endColumn + 1\n\t\t\t};\n\t\t}\n\n\t\tconst selectionText = model.getValueInRange(range);\n\n\t\tconst wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);\n\t\tif (!wordRange) {\n\t\t\treturn null;\n\t\t}\n\t\tconst word = model.getValueInRange(wordRange);\n\t\tconst result = BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);\n\t\treturn result;\n\t}\n\n\t// ---- BEGIN foreign module support --------------------------------------------------------------------------\n\n\t// foreign method request\n\tpublic $fmr(method: string, args: unknown[]): Promise<unknown> {\n\t\tif (!this._foreignModule || typeof (this._foreignModule as Record<string, unknown>)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error('Missing requestHandler or method: ' + method));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve((this._foreignModule as Record<string, Function>)[method].apply(this._foreignModule, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\t// ---- END foreign module support --------------------------------------------------------------------------\n}\n\n// This is only available in a Web Worker\ndeclare function importScripts(...urls: string[]): void;\n\nif (typeof importScripts === 'function') {\n\t// Running in a web worker\n\tglobalThis.monaco = createMonacoBaseAPI();\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { stringDiff } from '../../../base/common/diff/diff.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IWebWorkerServerRequestHandler } from '../../../base/common/worker/webWorker.js';\nimport { IRange, Range } from '../core/range.js';\nimport { EndOfLineSequence, ITextModel } from '../model.js';\nimport { IMirrorTextModel, IModelChangedEvent } from '../model/mirrorTextModel.js';\nimport { IColorInformation, IInplaceReplaceSupportResult, ILink, TextEdit } from '../languages.js';\nimport { computeLinks } from '../languages/linkComputer.js';\nimport { BasicInplaceReplace } from '../languages/supports/inplaceReplaceSupport.js';\nimport { DiffAlgorithmName, IDiffComputationResult, ILineChange, IUnicodeHighlightsResult } from './editorWorker.js';\nimport { createMonacoBaseAPI } from './editorBaseApi.js';\nimport { StopWatch } from '../../../base/common/stopwatch.js';\nimport { UnicodeTextModelHighlighter, UnicodeHighlighterOptions } from './unicodeTextModelHighlighter.js';\nimport { ILinesDiffComputer } from '../diff/linesDiffComputer.js';\nimport { DetailedLineRangeMapping } from '../diff/rangeMapping.js';\nimport { linesDiffComputers } from '../diff/linesDiffComputers.js';\nimport { IDocumentDiffProviderOptions } from '../diff/documentDiffProvider.js';\nimport { computeDefaultDocumentColors } from '../languages/defaultDocumentColorsComputer.js';\nimport { FindSectionHeaderOptions, SectionHeader, findSectionHeaders } from './findSectionHeaders.js';\nimport { IRawModelData, IWorkerTextModelSyncChannelServer } from './textModelSync/textModelSync.protocol.js';\nimport { ICommonModel, WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';\n\nexport interface IMirrorModel extends IMirrorTextModel {\n\treadonly uri: URI;\n\treadonly version: number;\n\tgetValue(): string;\n}\n\nexport interface IWorkerContext<H = {}> {\n\t/**\n\t * A proxy to the main thread host object.\n\t */\n\thost: H;\n\t/**\n\t * Get all available mirror models in this worker.\n\t */\n\tgetMirrorModels(): IMirrorModel[];\n}\n\n/**\n * Range of a word inside a model.\n * @internal\n */\nexport interface IWordRange {\n\t/**\n\t * The index where the word starts.\n\t */\n\treadonly start: number;\n\t/**\n\t * The index where the word ends.\n\t */\n\treadonly end: number;\n}\n\n/**\n * @internal\n */\nexport class EditorWorker implements IDisposable, IWorkerTextModelSyncChannelServer, IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: void = undefined;\n\n\tprivate readonly _workerTextModelSyncServer = new WorkerTextModelSyncServer();\n\n\tconstructor(\n\t\tprivate readonly _foreignModule: unknown | null = null\n\t) { }\n\n\tdispose(): void {\n\t}\n\n\tpublic async $ping() {\n\t\treturn 'pong';\n\t}\n\n\tprotected _getModel(uri: string): ICommonModel | undefined {\n\t\treturn this._workerTextModelSyncServer.getModel(uri);\n\t}\n\n\tpublic getModels(): ICommonModel[] {\n\t\treturn this._workerTextModelSyncServer.getModels();\n\t}\n\n\tpublic $acceptNewModel(data: IRawModelData): void {\n\t\tthis._workerTextModelSyncServer.$acceptNewModel(data);\n\t}\n\n\tpublic $acceptModelChanged(uri: string, e: IModelChangedEvent): void {\n\t\tthis._workerTextModelSyncServer.$acceptModelChanged(uri, e);\n\t}\n\n\tpublic $acceptRemovedModel(uri: string): void {\n\t\tthis._workerTextModelSyncServer.$acceptRemovedModel(uri);\n\t}\n\n\tpublic async $computeUnicodeHighlights(url: string, options: UnicodeHighlighterOptions, range?: IRange): Promise<IUnicodeHighlightsResult> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };\n\t\t}\n\t\treturn UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);\n\t}\n\n\tpublic async $findSectionHeaders(url: string, options: FindSectionHeaderOptions): Promise<SectionHeader[]> {\n\t\tconst model = this._getModel(url);\n\t\tif (!model) {\n\t\t\treturn [];\n\t\t}\n\t\treturn findSectionHeaders(model, options);\n\t}\n\n\t// ---- BEGIN diff --------------------------------------------------------------------------\n\n\tpublic async $computeDiff(originalUrl: string, modifiedUrl: string, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): Promise<IDiffComputationResult | null> {\n\t\tconst original = this._getModel(originalUrl);\n\t\tconst modified = this._getModel(modifiedUrl);\n\t\tif (!original || !modified) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst result = EditorWorker.computeDiff(original, modified, options, algorithm);\n\t\treturn result;\n\t}\n\n\tprivate static computeDiff(originalTextModel: ICommonModel | ITextModel, modifiedTextModel: ICommonModel | ITextModel, options: IDocumentDiffProviderOptions, algorithm: DiffAlgorithmName): IDiffComputationResult {\n\t\tconst diffAlgorithm: ILinesDiffComputer = algorithm === 'advanced' ? linesDiffComputers.getDefault() : linesDiffComputers.getLegacy();\n\n\t\tconst originalLines = originalTextModel.getLinesContent();\n\t\tconst modifiedLines = modifiedTextModel.getLinesContent();\n\n\t\tconst result = diffAlgorithm.computeDiff(originalLines, modifiedLines, options);\n\n\t\tconst identical = (result.changes.length > 0 ? false : this._modelsAreIdentical(originalTextModel, modifiedTextModel));\n\n\t\tfunction getLineChanges(changes: readonly DetailedLineRangeMapping[]): ILineChange[] {\n\t\t\treturn changes.map(m => ([m.original.startLineNumber, m.original.endLineNumberExclusive, m.modified.startLineNumber, m.modified.endLineNumberExclusive, m.innerChanges?.map(m => [\n\t\t\t\tm.originalRange.startLineNumber,\n\t\t\t\tm.originalRange.startColumn,\n\t\t\t\tm.originalRange.endLineNumber,\n\t\t\t\tm.originalRange.endColumn,\n\t\t\t\tm.modifiedRange.startLineNumber,\n\t\t\t\tm.modifiedRange.startColumn,\n\t\t\t\tm.modifiedRange.endLineNumber,\n\t\t\t\tm.modifiedRange.endColumn,\n\t\t\t])]));\n\t\t}\n\n\t\treturn {\n\t\t\tidentical,\n\t\t\tquitEarly: result.hitTimeout,\n\t\t\tchanges: getLineChanges(result.changes),\n\t\t\tmoves: result.moves.map(m => ([\n\t\t\t\tm.lineRangeMapping.original.startLineNumber,\n\t\t\t\tm.lineRangeMapping.original.endLineNumberExclusive,\n\t\t\t\tm.lineRangeMapping.modified.startLineNumber,\n\t\t\t\tm.lineRangeMapping.modified.endLineNumberExclusive,\n\t\t\t\tgetLineChanges(m.changes)\n\t\t\t])),\n\t\t};\n\t}\n\n\tprivate static _modelsAreIdentical(original: ICommonModel | ITextModel, modified: ICommonModel | ITextModel): boolean {\n\t\tconst originalLineCount = original.getLineCount();\n\t\tconst modifiedLineCount = modified.getLineCount();\n\t\tif (originalLineCount !== modifiedLineCount) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let line = 1; line <= originalLineCount; line++) {\n\t\t\tconst originalLine = original.getLineContent(line);\n\t\t\tconst modifiedLine = modified.getLineContent(line);\n\t\t\tif (originalLine !== modifiedLine) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ---- END diff --------------------------------------------------------------------------\n\n\n\t// ---- BEGIN minimal edits ---------------------------------------------------------------\n\n\tprivate static readonly _diffLimit = 100000;\n\n\tpublic async $computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[], pretty: boolean): Promise<TextEdit[]> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn edits;\n\t\t}\n\n\t\tconst result: TextEdit[] = [];\n\t\tlet lastEol: EndOfLineSequence | undefined = undefined;\n\n\t\tedits = edits.slice(0).sort((a, b) => {\n\t\t\tif (a.range && b.range) {\n\t\t\t\treturn Range.compareRangesUsingStarts(a.range, b.range);\n\t\t\t}\n\t\t\t// eol only changes should go to the end\n\t\t\tconst aRng = a.range ? 0 : 1;\n\t\t\tconst bRng = b.range ? 0 : 1;\n\t\t\treturn aRng - bRng;\n\t\t});\n\n\t\t// merge adjacent edits\n\t\tlet writeIndex = 0;\n\t\tfor (let readIndex = 1; readIndex < edits.length; readIndex++) {\n\t\t\tif (Range.getEndPosition(edits[writeIndex].range).equals(Range.getStartPosition(edits[readIndex].range))) {\n\t\t\t\tedits[writeIndex].range = Range.fromPositions(Range.getStartPosition(edits[writeIndex].range), Range.getEndPosition(edits[readIndex].range));\n\t\t\t\tedits[writeIndex].text += edits[readIndex].text;\n\t\t\t} else {\n\t\t\t\twriteIndex++;\n\t\t\t\tedits[writeIndex] = edits[readIndex];\n\t\t\t}\n\t\t}\n\t\tedits.length = writeIndex + 1;\n\n\t\tfor (let { range, text, eol } of edits) {\n\n\t\t\tif (typeof eol === 'number') {\n\t\t\t\tlastEol = eol;\n\t\t\t}\n\n\t\t\tif (Range.isEmpty(range) && !text) {\n\t\t\t\t// empty change\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst original = model.getValueInRange(range);\n\t\t\ttext = text.replace(/\\r\\n|\\n|\\r/g, model.eol);\n\n\t\t\tif (original === text) {\n\t\t\t\t// noop\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// make sure diff won't take too long\n\t\t\tif (Math.max(text.length, original.length) > EditorWorker._diffLimit) {\n\t\t\t\tresult.push({ range, text });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// compute diff between original and edit.text\n\t\t\tconst changes = stringDiff(original, text, pretty);\n\t\t\tconst editOffset = model.offsetAt(Range.lift(range).getStartPosition());\n\n\t\t\tfor (const change of changes) {\n\t\t\t\tconst start = model.positionAt(editOffset + change.originalStart);\n\t\t\t\tconst end = model.positionAt(editOffset + change.originalStart + change.originalLength);\n\t\t\t\tconst newEdit: TextEdit = {\n\t\t\t\t\ttext: text.substr(change.modifiedStart, change.modifiedLength),\n\t\t\t\t\trange: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }\n\t\t\t\t};\n\n\t\t\t\tif (model.getValueInRange(newEdit.range) !== newEdit.text) {\n\t\t\t\t\tresult.push(newEdit);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof lastEol === 'number') {\n\t\t\tresult.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// ---- END minimal edits ---------------------------------------------------------------\n\n\tpublic async $computeLinks(modelUrl: string): Promise<ILink[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn computeLinks(model);\n\t}\n\n\t// --- BEGIN default document colors -----------------------------------------------------------\n\n\tpublic async $computeDefaultDocumentColors(modelUrl: string): Promise<IColorInformation[] | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\t\treturn computeDefaultDocumentColors(model);\n\t}\n\n\t// ---- BEGIN suggest --------------------------------------------------------------------------\n\n\tprivate static readonly _suggestionsLimit = 10000;\n\n\tpublic async $textualSuggest(modelUrls: string[], leadingWord: string | undefined, wordDef: string, wordDefFlags: string): Promise<{ words: string[]; duration: number } | null> {\n\n\t\tconst sw = new StopWatch();\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst seen = new Set<string>();\n\n\t\touter: for (const url of modelUrls) {\n\t\t\tconst model = this._getModel(url);\n\t\t\tif (!model) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const word of model.words(wordDefRegExp)) {\n\t\t\t\tif (word === leadingWord || !isNaN(Number(word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseen.add(word);\n\t\t\t\tif (seen.size > EditorWorker._suggestionsLimit) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { words: Array.from(seen), duration: sw.elapsed() };\n\t}\n\n\n\t// ---- END suggest --------------------------------------------------------------------------\n\n\t//#region -- word ranges --\n\n\tpublic async $computeWordRanges(modelUrl: string, range: IRange, wordDef: string, wordDefFlags: string): Promise<{ [word: string]: IRange[] }> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn Object.create(null);\n\t\t}\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\t\tconst result: { [word: string]: IRange[] } = Object.create(null);\n\t\tfor (let line = range.startLineNumber; line < range.endLineNumber; line++) {\n\t\t\tconst words = model.getLineWords(line, wordDefRegExp);\n\t\t\tfor (const word of words) {\n\t\t\t\tif (!isNaN(Number(word.word))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet array = result[word.word];\n\t\t\t\tif (!array) {\n\t\t\t\t\tarray = [];\n\t\t\t\t\tresult[word.word] = array;\n\t\t\t\t}\n\t\t\t\tarray.push({\n\t\t\t\t\tstartLineNumber: line,\n\t\t\t\t\tstartColumn: word.startColumn,\n\t\t\t\t\tendLineNumber: line,\n\t\t\t\t\tendColumn: word.endColumn\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t//#endregion\n\n\tpublic async $navigateValueSet(modelUrl: string, range: IRange, up: boolean, wordDef: string, wordDefFlags: string): Promise<IInplaceReplaceSupportResult | null> {\n\t\tconst model = this._getModel(modelUrl);\n\t\tif (!model) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst wordDefRegExp = new RegExp(wordDef, wordDefFlags);\n\n\t\tif (range.startColumn === range.endColumn) {\n\t\t\trange = {\n\t\t\t\tstartLineNumber: range.startLineNumber,\n\t\t\t\tstartColumn: range.startColumn,\n\t\t\t\tendLineNumber: range.endLineNumber,\n\t\t\t\tendColumn: range.endColumn + 1\n\t\t\t};\n\t\t}\n\n\t\tconst selectionText = model.getValueInRange(range);\n\n\t\tconst wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);\n\t\tif (!wordRange) {\n\t\t\treturn null;\n\t\t}\n\t\tconst word = model.getValueInRange(wordRange);\n\t\tconst result = BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);\n\t\treturn result;\n\t}\n\n\t// ---- BEGIN foreign module support --------------------------------------------------------------------------\n\n\t// foreign method request\n\tpublic $fmr(method: string, args: unknown[]): Promise<unknown> {\n\t\tif (!this._foreignModule || typeof (this._foreignModule as Record<string, unknown>)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error('Missing requestHandler or method: ' + method));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve((this._foreignModule as Record<string, Function>)[method].apply(this._foreignModule, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\t// ---- END foreign module support --------------------------------------------------------------------------\n}\n\n// This is only available in a Web Worker\ndeclare function importScripts(...urls: string[]): void;\n\nif (typeof importScripts === 'function') {\n\t// Running in a web worker\n\tglobalThis.monaco = createMonacoBaseAPI();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/editorWorkerHost.ts","vs/editor/common/services/editorWorkerHost.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,MAAM,OAAgB,gBAAgB;aACvB,iBAAY,GAAG,kBAAkB,CAAC;IACzC,MAAM,CAAC,UAAU,CAAC,YAA8B;QACtD,OAAO,YAAY,CAAC,UAAU,CAAmB,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjF,CAAC;IACM,MAAM,CAAC,UAAU,CAAC,YAAmC,EAAE,GAAqB;QAClF,YAAY,CAAC,UAAU,CAAmB,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC/E,CAAC","file":"editorWorkerHost.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IWebWorkerServer, IWebWorkerClient } from '../../../base/common/worker/webWorker.js';\n\nexport abstract class EditorWorkerHost {\n\tpublic static CHANNEL_NAME = 'editorWorkerHost';\n\tpublic static getChannel(workerServer: IWebWorkerServer): EditorWorkerHost {\n\t\treturn workerServer.getChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME);\n\t}\n\tpublic static setChannel(workerClient: IWebWorkerClient<any>, obj: EditorWorkerHost): void {\n\t\tworkerClient.setChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME, obj);\n\t}\n\n\t// foreign host request\n\tabstract $fhr(method: string, args: any[]): Promise<any>;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IWebWorkerServer, IWebWorkerClient } from '../../../base/common/worker/webWorker.js';\n\nexport abstract class EditorWorkerHost {\n\tpublic static CHANNEL_NAME = 'editorWorkerHost';\n\tpublic static getChannel(workerServer: IWebWorkerServer): EditorWorkerHost {\n\t\treturn workerServer.getChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME);\n\t}\n\tpublic static setChannel(workerClient: IWebWorkerClient<any>, obj: EditorWorkerHost): void {\n\t\tworkerClient.setChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME, obj);\n\t}\n\n\t// foreign host request\n\tabstract $fhr(method: string, args: any[]): Promise<any>;\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/editorWorkerHost.ts","vs/editor/common/services/editorWorkerHost.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,MAAM,OAAgB,gBAAgB;aACvB,iBAAY,GAAG,kBAAkB,CAAC;IACzC,MAAM,CAAC,UAAU,CAAC,YAA8B;QACtD,OAAO,YAAY,CAAC,UAAU,CAAmB,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACjF,CAAC;IACM,MAAM,CAAC,UAAU,CAAC,YAAuC,EAAE,GAAqB;QACtF,YAAY,CAAC,UAAU,CAAmB,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC/E,CAAC","file":"editorWorkerHost.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IWebWorkerServer, IWebWorkerClient } from '../../../base/common/worker/webWorker.js';\n\nexport abstract class EditorWorkerHost {\n\tpublic static CHANNEL_NAME = 'editorWorkerHost';\n\tpublic static getChannel(workerServer: IWebWorkerServer): EditorWorkerHost {\n\t\treturn workerServer.getChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME);\n\t}\n\tpublic static setChannel(workerClient: IWebWorkerClient<unknown>, obj: EditorWorkerHost): void {\n\t\tworkerClient.setChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME, obj);\n\t}\n\n\t// foreign host request\n\tabstract $fhr(method: string, args: unknown[]): Promise<unknown>;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IWebWorkerServer, IWebWorkerClient } from '../../../base/common/worker/webWorker.js';\n\nexport abstract class EditorWorkerHost {\n\tpublic static CHANNEL_NAME = 'editorWorkerHost';\n\tpublic static getChannel(workerServer: IWebWorkerServer): EditorWorkerHost {\n\t\treturn workerServer.getChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME);\n\t}\n\tpublic static setChannel(workerClient: IWebWorkerClient<unknown>, obj: EditorWorkerHost): void {\n\t\tworkerClient.setChannel<EditorWorkerHost>(EditorWorkerHost.CHANNEL_NAME, obj);\n\t}\n\n\t// foreign host request\n\tabstract $fhr(method: string, args: unknown[]): Promise<unknown>;\n}\n"]}
@@ -13,19 +13,20 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  var ModelService_1;
15
15
  import { Emitter } from '../../../base/common/event.js';
16
+ import { StringSHA1 } from '../../../base/common/hash.js';
16
17
  import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
18
+ import { Schemas } from '../../../base/common/network.js';
19
+ import { equals } from '../../../base/common/objects.js';
17
20
  import * as platform from '../../../base/common/platform.js';
18
- import { TextModel } from '../model/textModel.js';
19
- import { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';
20
- import { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';
21
- import { ITextResourcePropertiesService } from './textResourceConfiguration.js';
22
21
  import { IConfigurationService } from '../../../platform/configuration/common/configuration.js';
22
+ import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
23
23
  import { IUndoRedoService } from '../../../platform/undoRedo/common/undoRedo.js';
24
- import { StringSHA1 } from '../../../base/common/hash.js';
24
+ import { clampedInt } from '../config/editorOptions.js';
25
+ import { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';
26
+ import { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';
25
27
  import { isEditStackElement } from '../model/editStack.js';
26
- import { Schemas } from '../../../base/common/network.js';
27
- import { equals } from '../../../base/common/objects.js';
28
- import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
28
+ import { TextModel } from '../model/textModel.js';
29
+ import { ITextResourcePropertiesService } from './textResourceConfiguration.js';
29
30
  function MODEL_ID(resource) {
30
31
  return resource.toString();
31
32
  }
@@ -79,20 +80,11 @@ let ModelService = class ModelService extends Disposable {
79
80
  static _readModelOptions(config, isForSimpleWidget) {
80
81
  let tabSize = EDITOR_MODEL_DEFAULTS.tabSize;
81
82
  if (config.editor && typeof config.editor.tabSize !== 'undefined') {
82
- const parsedTabSize = parseInt(config.editor.tabSize, 10);
83
- if (!isNaN(parsedTabSize)) {
84
- tabSize = parsedTabSize;
85
- }
86
- if (tabSize < 1) {
87
- tabSize = 1;
88
- }
83
+ tabSize = clampedInt(config.editor.tabSize, EDITOR_MODEL_DEFAULTS.tabSize, 1, 100);
89
84
  }
90
85
  let indentSize = 'tabSize';
91
86
  if (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {
92
- const parsedIndentSize = parseInt(config.editor.indentSize, 10);
93
- if (!isNaN(parsedIndentSize)) {
94
- indentSize = Math.max(parsedIndentSize, 1);
95
- }
87
+ indentSize = clampedInt(config.editor.indentSize, 'tabSize', 1, 100);
96
88
  }
97
89
  let insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;
98
90
  if (config.editor && typeof config.editor.insertSpaces !== 'undefined') {
@@ -120,9 +112,10 @@ let ModelService = class ModelService extends Disposable {
120
112
  }
121
113
  let bracketPairColorizationOptions = EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions;
122
114
  if (config.editor?.bracketPairColorization && typeof config.editor.bracketPairColorization === 'object') {
115
+ const bpConfig = config.editor.bracketPairColorization;
123
116
  bracketPairColorizationOptions = {
124
- enabled: !!config.editor.bracketPairColorization.enabled,
125
- independentColorPoolPerBracketType: !!config.editor.bracketPairColorization.independentColorPoolPerBracketType
117
+ enabled: !!bpConfig.enabled,
118
+ independentColorPoolPerBracketType: !!bpConfig.independentColorPoolPerBracketType
126
119
  };
127
120
  }
128
121
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/modelService.ts","vs/editor/common/services/modelService.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;AAEhG,OAAO,EAAE,OAAO,EAAS,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAe,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAA6B,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAC3H,OAAO,EAAE,gBAAgB,EAA6B,MAAM,+CAA+C,CAA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B,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACjC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC","file":"modelService.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Emitter, Event } from '../../../base/common/event.js';\nimport { Disposable, IDisposable, DisposableStore } from '../../../base/common/lifecycle.js';\nimport * as platform from '../../../base/common/platform.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { DefaultEndOfLine, EndOfLineSequence, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from '../model.js';\nimport { TextModel } from '../model/textModel.js';\nimport { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';\nimport { IModelLanguageChangedEvent } from '../textModelEvents.js';\nimport { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';\nimport { ILanguageSelection } from '../languages/language.js';\nimport { IModelService } from './model.js';\nimport { ITextResourcePropertiesService } from './textResourceConfiguration.js';\nimport { IConfigurationChangeEvent, IConfigurationService } from '../../../platform/configuration/common/configuration.js';\nimport { IUndoRedoService, ResourceEditStackSnapshot } from '../../../platform/undoRedo/common/undoRedo.js';\nimport { StringSHA1 } from '../../../base/common/hash.js';\nimport { isEditStackElement } from '../model/editStack.js';\nimport { Schemas } from '../../../base/common/network.js';\nimport { equals } from '../../../base/common/objects.js';\nimport { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';\n\nfunction MODEL_ID(resource: URI): string {\n\treturn resource.toString();\n}\n\nclass ModelData implements IDisposable {\n\n\tprivate readonly _modelEventListeners = new DisposableStore();\n\n\tconstructor(\n\t\tpublic readonly model: TextModel,\n\t\tonWillDispose: (model: ITextModel) => void,\n\t\tonDidChangeLanguage: (model: ITextModel, e: IModelLanguageChangedEvent) => void\n\t) {\n\t\tthis.model = model;\n\t\tthis._modelEventListeners.add(model.onWillDispose(() => onWillDispose(model)));\n\t\tthis._modelEventListeners.add(model.onDidChangeLanguage((e) => onDidChangeLanguage(model, e)));\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._modelEventListeners.dispose();\n\t}\n}\n\ninterface IRawEditorConfig {\n\ttabSize?: any;\n\tindentSize?: any;\n\tinsertSpaces?: any;\n\tdetectIndentation?: any;\n\ttrimAutoWhitespace?: any;\n\tlargeFileOptimizations?: any;\n\tbracketPairColorization?: any;\n}\n\ninterface IRawConfig {\n\teol?: any;\n\teditor?: IRawEditorConfig;\n}\n\nconst DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;\n\nclass DisposedModelInfo {\n\tconstructor(\n\t\tpublic readonly uri: URI,\n\t\tpublic readonly initialUndoRedoSnapshot: ResourceEditStackSnapshot | null,\n\t\tpublic readonly time: number,\n\t\tpublic readonly sharesUndoRedoStack: boolean,\n\t\tpublic readonly heapSize: number,\n\t\tpublic readonly sha1: string,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly alternativeVersionId: number,\n\t) { }\n}\n\nexport class ModelService extends Disposable implements IModelService {\n\n\tpublic static MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK = 20 * 1024 * 1024;\n\n\tpublic _serviceBrand: undefined;\n\n\tprivate readonly _onModelAdded: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelAdded: Event<ITextModel> = this._onModelAdded.event;\n\n\tprivate readonly _onModelRemoved: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelRemoved: Event<ITextModel> = this._onModelRemoved.event;\n\n\tprivate readonly _onModelModeChanged = this._register(new Emitter<{ model: ITextModel; oldLanguageId: string }>());\n\tpublic readonly onModelLanguageChanged = this._onModelModeChanged.event;\n\n\tprivate _modelCreationOptionsByLanguageAndResource: { [languageAndResource: string]: ITextModelCreationOptions };\n\n\t/**\n\t * All the models known in the system.\n\t */\n\tprivate readonly _models: { [modelId: string]: ModelData };\n\tprivate readonly _disposedModels: Map<string, DisposedModelInfo>;\n\tprivate _disposedModelsHeapSize: number;\n\n\tconstructor(\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@ITextResourcePropertiesService private readonly _resourcePropertiesService: ITextResourcePropertiesService,\n\t\t@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService\n\t) {\n\t\tsuper();\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\t\tthis._models = {};\n\t\tthis._disposedModels = new Map<string, DisposedModelInfo>();\n\t\tthis._disposedModelsHeapSize = 0;\n\n\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => this._updateModelOptions(e)));\n\t\tthis._updateModelOptions(undefined);\n\t}\n\n\tprivate static _readModelOptions(config: IRawConfig, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tlet tabSize = EDITOR_MODEL_DEFAULTS.tabSize;\n\t\tif (config.editor && typeof config.editor.tabSize !== 'undefined') {\n\t\t\tconst parsedTabSize = parseInt(config.editor.tabSize, 10);\n\t\t\tif (!isNaN(parsedTabSize)) {\n\t\t\t\ttabSize = parsedTabSize;\n\t\t\t}\n\t\t\tif (tabSize < 1) {\n\t\t\t\ttabSize = 1;\n\t\t\t}\n\t\t}\n\n\t\tlet indentSize: number | 'tabSize' = 'tabSize';\n\t\tif (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {\n\t\t\tconst parsedIndentSize = parseInt(config.editor.indentSize, 10);\n\t\t\tif (!isNaN(parsedIndentSize)) {\n\t\t\t\tindentSize = Math.max(parsedIndentSize, 1);\n\t\t\t}\n\t\t}\n\n\t\tlet insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;\n\t\tif (config.editor && typeof config.editor.insertSpaces !== 'undefined') {\n\t\t\tinsertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));\n\t\t}\n\n\t\tlet newDefaultEOL = DEFAULT_EOL;\n\t\tconst eol = config.eol;\n\t\tif (eol === '\\r\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.CRLF;\n\t\t} else if (eol === '\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.LF;\n\t\t}\n\n\t\tlet trimAutoWhitespace = EDITOR_MODEL_DEFAULTS.trimAutoWhitespace;\n\t\tif (config.editor && typeof config.editor.trimAutoWhitespace !== 'undefined') {\n\t\t\ttrimAutoWhitespace = (config.editor.trimAutoWhitespace === 'false' ? false : Boolean(config.editor.trimAutoWhitespace));\n\t\t}\n\n\t\tlet detectIndentation = EDITOR_MODEL_DEFAULTS.detectIndentation;\n\t\tif (config.editor && typeof config.editor.detectIndentation !== 'undefined') {\n\t\t\tdetectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));\n\t\t}\n\n\t\tlet largeFileOptimizations = EDITOR_MODEL_DEFAULTS.largeFileOptimizations;\n\t\tif (config.editor && typeof config.editor.largeFileOptimizations !== 'undefined') {\n\t\t\tlargeFileOptimizations = (config.editor.largeFileOptimizations === 'false' ? false : Boolean(config.editor.largeFileOptimizations));\n\t\t}\n\t\tlet bracketPairColorizationOptions = EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions;\n\t\tif (config.editor?.bracketPairColorization && typeof config.editor.bracketPairColorization === 'object') {\n\t\t\tbracketPairColorizationOptions = {\n\t\t\t\tenabled: !!config.editor.bracketPairColorization.enabled,\n\t\t\t\tindependentColorPoolPerBracketType: !!config.editor.bracketPairColorization.independentColorPoolPerBracketType\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisForSimpleWidget: isForSimpleWidget,\n\t\t\ttabSize: tabSize,\n\t\t\tindentSize: indentSize,\n\t\t\tinsertSpaces: insertSpaces,\n\t\t\tdetectIndentation: detectIndentation,\n\t\t\tdefaultEOL: newDefaultEOL,\n\t\t\ttrimAutoWhitespace: trimAutoWhitespace,\n\t\t\tlargeFileOptimizations: largeFileOptimizations,\n\t\t\tbracketPairColorizationOptions\n\t\t};\n\t}\n\n\tprivate _getEOL(resource: URI | undefined, language: string): string {\n\t\tif (resource) {\n\t\t\treturn this._resourcePropertiesService.getEOL(resource, language);\n\t\t}\n\t\tconst eol = this._configurationService.getValue('files.eol', { overrideIdentifier: language });\n\t\tif (eol && typeof eol === 'string' && eol !== 'auto') {\n\t\t\treturn eol;\n\t\t}\n\t\treturn platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\\n' : '\\r\\n';\n\t}\n\n\tprivate _shouldRestoreUndoStack(): boolean {\n\t\tconst result = this._configurationService.getValue('files.restoreUndoStack');\n\t\tif (typeof result === 'boolean') {\n\t\t\treturn result;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic getCreationOptions(languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tconst language = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId);\n\t\tlet creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];\n\t\tif (!creationOptions) {\n\t\t\tconst editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });\n\t\t\tconst eol = this._getEOL(resource, language);\n\t\t\tcreationOptions = ModelService._readModelOptions({ editor, eol }, isForSimpleWidget);\n\t\t\tthis._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;\n\t\t}\n\t\treturn creationOptions;\n\t}\n\n\tprivate _updateModelOptions(e: IConfigurationChangeEvent | undefined): void {\n\t\tconst oldOptionsByLanguageAndResource = this._modelCreationOptionsByLanguageAndResource;\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\n\t\t// Update options on all models\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tconst modelData = this._models[modelId];\n\t\t\tconst language = modelData.model.getLanguageId();\n\t\t\tconst uri = modelData.model.uri;\n\n\t\t\tif (e && !e.affectsConfiguration('editor', { overrideIdentifier: language, resource: uri }) && !e.affectsConfiguration('files.eol', { overrideIdentifier: language, resource: uri })) {\n\t\t\t\tcontinue; // perf: skip if this model is not affected by configuration change\n\t\t\t}\n\n\t\t\tconst oldOptions = oldOptionsByLanguageAndResource[language + uri];\n\t\t\tconst newOptions = this.getCreationOptions(language, uri, modelData.model.isForSimpleWidget);\n\t\t\tModelService._setModelOptionsForModel(modelData.model, newOptions, oldOptions);\n\t\t}\n\t}\n\n\tprivate static _setModelOptionsForModel(model: ITextModel, newOptions: ITextModelCreationOptions, currentOptions: ITextModelCreationOptions): void {\n\t\tif (currentOptions && currentOptions.defaultEOL !== newOptions.defaultEOL && model.getLineCount() === 1) {\n\t\t\tmodel.setEOL(newOptions.defaultEOL === DefaultEndOfLine.LF ? EndOfLineSequence.LF : EndOfLineSequence.CRLF);\n\t\t}\n\n\t\tif (currentOptions\n\t\t\t&& (currentOptions.detectIndentation === newOptions.detectIndentation)\n\t\t\t&& (currentOptions.insertSpaces === newOptions.insertSpaces)\n\t\t\t&& (currentOptions.tabSize === newOptions.tabSize)\n\t\t\t&& (currentOptions.indentSize === newOptions.indentSize)\n\t\t\t&& (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)\n\t\t\t&& equals(currentOptions.bracketPairColorizationOptions, newOptions.bracketPairColorizationOptions)\n\t\t) {\n\t\t\t// Same indent opts, no need to touch the model\n\t\t\treturn;\n\t\t}\n\n\t\tif (newOptions.detectIndentation) {\n\t\t\tmodel.detectIndentation(newOptions.insertSpaces, newOptions.tabSize);\n\t\t\tmodel.updateOptions({\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t} else {\n\t\t\tmodel.updateOptions({\n\t\t\t\tinsertSpaces: newOptions.insertSpaces,\n\t\t\t\ttabSize: newOptions.tabSize,\n\t\t\t\tindentSize: newOptions.indentSize,\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- begin IModelService\n\n\tprivate _insertDisposedModel(disposedModelData: DisposedModelInfo): void {\n\t\tthis._disposedModels.set(MODEL_ID(disposedModelData.uri), disposedModelData);\n\t\tthis._disposedModelsHeapSize += disposedModelData.heapSize;\n\t}\n\n\tprivate _removeDisposedModel(resource: URI): DisposedModelInfo | undefined {\n\t\tconst disposedModelData = this._disposedModels.get(MODEL_ID(resource));\n\t\tif (disposedModelData) {\n\t\t\tthis._disposedModelsHeapSize -= disposedModelData.heapSize;\n\t\t}\n\t\tthis._disposedModels.delete(MODEL_ID(resource));\n\t\treturn disposedModelData;\n\t}\n\n\tprivate _ensureDisposedModelsHeapSize(maxModelsHeapSize: number): void {\n\t\tif (this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t// we must remove some old undo stack elements to free up some memory\n\t\t\tconst disposedModels: DisposedModelInfo[] = [];\n\t\t\tthis._disposedModels.forEach(entry => {\n\t\t\t\tif (!entry.sharesUndoRedoStack) {\n\t\t\t\t\tdisposedModels.push(entry);\n\t\t\t\t}\n\t\t\t});\n\t\t\tdisposedModels.sort((a, b) => a.time - b.time);\n\t\t\twhile (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t\tconst disposedModel = disposedModels.shift()!;\n\t\t\t\tthis._removeDisposedModel(disposedModel.uri);\n\t\t\t\tif (disposedModel.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModel.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _createModelData(value: string | ITextBufferFactory, languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ModelData {\n\t\t// create & save the model\n\t\tconst options = this.getCreationOptions(languageIdOrSelection, resource, isForSimpleWidget);\n\t\tconst model: TextModel = this._instantiationService.createInstance(TextModel,\n\t\t\tvalue,\n\t\t\tlanguageIdOrSelection,\n\t\t\toptions,\n\t\t\tresource\n\t\t);\n\t\tif (resource && this._disposedModels.has(MODEL_ID(resource))) {\n\t\t\tconst disposedModelData = this._removeDisposedModel(resource)!;\n\t\t\tconst elements = this._undoRedoService.getElements(resource);\n\t\t\tconst sha1Computer = this._getSHA1Computer();\n\t\t\tconst sha1IsEqual = (\n\t\t\t\tsha1Computer.canComputeSHA1(model)\n\t\t\t\t\t? sha1Computer.computeSHA1(model) === disposedModelData.sha1\n\t\t\t\t\t: false\n\t\t\t);\n\t\t\tif (sha1IsEqual || disposedModelData.sharesUndoRedoStack) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis._undoRedoService.setElementsValidFlag(resource, true, (element) => (isEditStackElement(element) && element.matchesResource(resource)));\n\t\t\t\tif (sha1IsEqual) {\n\t\t\t\t\tmodel._overwriteVersionId(disposedModelData.versionId);\n\t\t\t\t\tmodel._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);\n\t\t\t\t\tmodel._overwriteInitialUndoRedoSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (disposedModelData.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst modelId = MODEL_ID(model.uri);\n\n\t\tif (this._models[modelId]) {\n\t\t\t// There already exists a model with this id => this is a programmer error\n\t\t\tthrow new Error('ModelService: Cannot add model because it already exists!');\n\t\t}\n\n\t\tconst modelData = new ModelData(\n\t\t\tmodel,\n\t\t\t(model) => this._onWillDispose(model),\n\t\t\t(model, e) => this._onDidChangeLanguage(model, e)\n\t\t);\n\t\tthis._models[modelId] = modelData;\n\n\t\treturn modelData;\n\t}\n\n\tpublic createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget: boolean = false): ITextModel {\n\t\tlet modelData: ModelData;\n\n\t\tif (languageSelection) {\n\t\t\tmodelData = this._createModelData(value, languageSelection, resource, isForSimpleWidget);\n\t\t} else {\n\t\t\tmodelData = this._createModelData(value, PLAINTEXT_LANGUAGE_ID, resource, isForSimpleWidget);\n\t\t}\n\n\t\tthis._onModelAdded.fire(modelData.model);\n\n\t\treturn modelData.model;\n\t}\n\n\tpublic getModels(): ITextModel[] {\n\t\tconst ret: ITextModel[] = [];\n\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tret.push(this._models[modelId].model);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tpublic getModel(resource: URI): ITextModel | null {\n\t\tconst modelId = MODEL_ID(resource);\n\t\tconst modelData = this._models[modelId];\n\t\tif (!modelData) {\n\t\t\treturn null;\n\t\t}\n\t\treturn modelData.model;\n\t}\n\n\t// --- end IModelService\n\n\tprotected _schemaShouldMaintainUndoRedoElements(resource: URI) {\n\t\treturn (\n\t\t\tresource.scheme === Schemas.file\n\t\t\t|| resource.scheme === Schemas.vscodeRemote\n\t\t\t|| resource.scheme === Schemas.vscodeUserData\n\t\t\t|| resource.scheme === Schemas.vscodeNotebookCell\n\t\t\t|| resource.scheme === 'fake-fs' // for tests\n\t\t);\n\t}\n\n\tprivate _onWillDispose(model: ITextModel): void {\n\t\tconst modelId = MODEL_ID(model.uri);\n\t\tconst modelData = this._models[modelId];\n\n\t\tconst sharesUndoRedoStack = (this._undoRedoService.getUriComparisonKey(model.uri) !== model.uri.toString());\n\t\tlet maintainUndoRedoStack = false;\n\t\tlet heapSize = 0;\n\t\tif (sharesUndoRedoStack || (this._shouldRestoreUndoStack() && this._schemaShouldMaintainUndoRedoElements(model.uri))) {\n\t\t\tconst elements = this._undoRedoService.getElements(model.uri);\n\t\t\tif (elements.past.length > 0 || elements.future.length > 0) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst maxMemory = ModelService.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;\n\t\tconst sha1Computer = this._getSHA1Computer();\n\t\tif (!maintainUndoRedoStack) {\n\t\t\tif (!sharesUndoRedoStack) {\n\t\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!sharesUndoRedoStack && (heapSize > maxMemory || !sha1Computer.canComputeSHA1(model))) {\n\t\t\t// the undo stack for this file would never fit in the configured memory or the file is very large, so don't bother with it.\n\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t}\n\t\t} else {\n\t\t\tthis._ensureDisposedModelsHeapSize(maxMemory - heapSize);\n\t\t\t// We only invalidate the elements, but they remain in the undo-redo service.\n\t\t\tthis._undoRedoService.setElementsValidFlag(model.uri, false, (element) => (isEditStackElement(element) && element.matchesResource(model.uri)));\n\t\t\tthis._insertDisposedModel(new DisposedModelInfo(model.uri, modelData.model.getInitialUndoRedoSnapshot(), Date.now(), sharesUndoRedoStack, heapSize, sha1Computer.computeSHA1(model), model.getVersionId(), model.getAlternativeVersionId()));\n\t\t}\n\n\t\tdelete this._models[modelId];\n\t\tmodelData.dispose();\n\n\t\t// clean up cache\n\t\tdelete this._modelCreationOptionsByLanguageAndResource[model.getLanguageId() + model.uri];\n\n\t\tthis._onModelRemoved.fire(model);\n\t}\n\n\tprivate _onDidChangeLanguage(model: ITextModel, e: IModelLanguageChangedEvent): void {\n\t\tconst oldLanguageId = e.oldLanguage;\n\t\tconst newLanguageId = model.getLanguageId();\n\t\tconst oldOptions = this.getCreationOptions(oldLanguageId, model.uri, model.isForSimpleWidget);\n\t\tconst newOptions = this.getCreationOptions(newLanguageId, model.uri, model.isForSimpleWidget);\n\t\tModelService._setModelOptionsForModel(model, newOptions, oldOptions);\n\t\tthis._onModelModeChanged.fire({ model, oldLanguageId: oldLanguageId });\n\t}\n\n\tprotected _getSHA1Computer(): ITextModelSHA1Computer {\n\t\treturn new DefaultModelSHA1Computer();\n\t}\n}\n\nexport interface ITextModelSHA1Computer {\n\tcanComputeSHA1(model: ITextModel): boolean;\n\tcomputeSHA1(model: ITextModel): string;\n}\n\nexport class DefaultModelSHA1Computer implements ITextModelSHA1Computer {\n\n\tpublic static MAX_MODEL_SIZE = 10 * 1024 * 1024; // takes 200ms to compute a sha1 on a 10MB model on a new machine\n\n\tcanComputeSHA1(model: ITextModel): boolean {\n\t\treturn (model.getValueLength() <= DefaultModelSHA1Computer.MAX_MODEL_SIZE);\n\t}\n\n\tcomputeSHA1(model: ITextModel): string {\n\t\t// compute the sha1\n\t\tconst shaComputer = new StringSHA1();\n\t\tconst snapshot = model.createSnapshot();\n\t\tlet text: string | null;\n\t\twhile ((text = snapshot.read())) {\n\t\t\tshaComputer.update(text);\n\t\t}\n\t\treturn shaComputer.digest();\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Emitter, Event } from '../../../base/common/event.js';\nimport { Disposable, IDisposable, DisposableStore } from '../../../base/common/lifecycle.js';\nimport * as platform from '../../../base/common/platform.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { DefaultEndOfLine, EndOfLineSequence, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from '../model.js';\nimport { TextModel } from '../model/textModel.js';\nimport { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';\nimport { IModelLanguageChangedEvent } from '../textModelEvents.js';\nimport { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';\nimport { ILanguageSelection } from '../languages/language.js';\nimport { IModelService } from './model.js';\nimport { ITextResourcePropertiesService } from './textResourceConfiguration.js';\nimport { IConfigurationChangeEvent, IConfigurationService } from '../../../platform/configuration/common/configuration.js';\nimport { IUndoRedoService, ResourceEditStackSnapshot } from '../../../platform/undoRedo/common/undoRedo.js';\nimport { StringSHA1 } from '../../../base/common/hash.js';\nimport { isEditStackElement } from '../model/editStack.js';\nimport { Schemas } from '../../../base/common/network.js';\nimport { equals } from '../../../base/common/objects.js';\nimport { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';\n\nfunction MODEL_ID(resource: URI): string {\n\treturn resource.toString();\n}\n\nclass ModelData implements IDisposable {\n\n\tprivate readonly _modelEventListeners = new DisposableStore();\n\n\tconstructor(\n\t\tpublic readonly model: TextModel,\n\t\tonWillDispose: (model: ITextModel) => void,\n\t\tonDidChangeLanguage: (model: ITextModel, e: IModelLanguageChangedEvent) => void\n\t) {\n\t\tthis.model = model;\n\t\tthis._modelEventListeners.add(model.onWillDispose(() => onWillDispose(model)));\n\t\tthis._modelEventListeners.add(model.onDidChangeLanguage((e) => onDidChangeLanguage(model, e)));\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._modelEventListeners.dispose();\n\t}\n}\n\ninterface IRawEditorConfig {\n\ttabSize?: any;\n\tindentSize?: any;\n\tinsertSpaces?: any;\n\tdetectIndentation?: any;\n\ttrimAutoWhitespace?: any;\n\tlargeFileOptimizations?: any;\n\tbracketPairColorization?: any;\n}\n\ninterface IRawConfig {\n\teol?: any;\n\teditor?: IRawEditorConfig;\n}\n\nconst DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;\n\nclass DisposedModelInfo {\n\tconstructor(\n\t\tpublic readonly uri: URI,\n\t\tpublic readonly initialUndoRedoSnapshot: ResourceEditStackSnapshot | null,\n\t\tpublic readonly time: number,\n\t\tpublic readonly sharesUndoRedoStack: boolean,\n\t\tpublic readonly heapSize: number,\n\t\tpublic readonly sha1: string,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly alternativeVersionId: number,\n\t) { }\n}\n\nexport class ModelService extends Disposable implements IModelService {\n\n\tpublic static MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK = 20 * 1024 * 1024;\n\n\tpublic _serviceBrand: undefined;\n\n\tprivate readonly _onModelAdded: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelAdded: Event<ITextModel> = this._onModelAdded.event;\n\n\tprivate readonly _onModelRemoved: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelRemoved: Event<ITextModel> = this._onModelRemoved.event;\n\n\tprivate readonly _onModelModeChanged = this._register(new Emitter<{ model: ITextModel; oldLanguageId: string }>());\n\tpublic readonly onModelLanguageChanged = this._onModelModeChanged.event;\n\n\tprivate _modelCreationOptionsByLanguageAndResource: { [languageAndResource: string]: ITextModelCreationOptions };\n\n\t/**\n\t * All the models known in the system.\n\t */\n\tprivate readonly _models: { [modelId: string]: ModelData };\n\tprivate readonly _disposedModels: Map<string, DisposedModelInfo>;\n\tprivate _disposedModelsHeapSize: number;\n\n\tconstructor(\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@ITextResourcePropertiesService private readonly _resourcePropertiesService: ITextResourcePropertiesService,\n\t\t@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService\n\t) {\n\t\tsuper();\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\t\tthis._models = {};\n\t\tthis._disposedModels = new Map<string, DisposedModelInfo>();\n\t\tthis._disposedModelsHeapSize = 0;\n\n\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => this._updateModelOptions(e)));\n\t\tthis._updateModelOptions(undefined);\n\t}\n\n\tprivate static _readModelOptions(config: IRawConfig, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tlet tabSize = EDITOR_MODEL_DEFAULTS.tabSize;\n\t\tif (config.editor && typeof config.editor.tabSize !== 'undefined') {\n\t\t\tconst parsedTabSize = parseInt(config.editor.tabSize, 10);\n\t\t\tif (!isNaN(parsedTabSize)) {\n\t\t\t\ttabSize = parsedTabSize;\n\t\t\t}\n\t\t\tif (tabSize < 1) {\n\t\t\t\ttabSize = 1;\n\t\t\t}\n\t\t}\n\n\t\tlet indentSize: number | 'tabSize' = 'tabSize';\n\t\tif (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {\n\t\t\tconst parsedIndentSize = parseInt(config.editor.indentSize, 10);\n\t\t\tif (!isNaN(parsedIndentSize)) {\n\t\t\t\tindentSize = Math.max(parsedIndentSize, 1);\n\t\t\t}\n\t\t}\n\n\t\tlet insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;\n\t\tif (config.editor && typeof config.editor.insertSpaces !== 'undefined') {\n\t\t\tinsertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));\n\t\t}\n\n\t\tlet newDefaultEOL = DEFAULT_EOL;\n\t\tconst eol = config.eol;\n\t\tif (eol === '\\r\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.CRLF;\n\t\t} else if (eol === '\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.LF;\n\t\t}\n\n\t\tlet trimAutoWhitespace = EDITOR_MODEL_DEFAULTS.trimAutoWhitespace;\n\t\tif (config.editor && typeof config.editor.trimAutoWhitespace !== 'undefined') {\n\t\t\ttrimAutoWhitespace = (config.editor.trimAutoWhitespace === 'false' ? false : Boolean(config.editor.trimAutoWhitespace));\n\t\t}\n\n\t\tlet detectIndentation = EDITOR_MODEL_DEFAULTS.detectIndentation;\n\t\tif (config.editor && typeof config.editor.detectIndentation !== 'undefined') {\n\t\t\tdetectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));\n\t\t}\n\n\t\tlet largeFileOptimizations = EDITOR_MODEL_DEFAULTS.largeFileOptimizations;\n\t\tif (config.editor && typeof config.editor.largeFileOptimizations !== 'undefined') {\n\t\t\tlargeFileOptimizations = (config.editor.largeFileOptimizations === 'false' ? false : Boolean(config.editor.largeFileOptimizations));\n\t\t}\n\t\tlet bracketPairColorizationOptions = EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions;\n\t\tif (config.editor?.bracketPairColorization && typeof config.editor.bracketPairColorization === 'object') {\n\t\t\tbracketPairColorizationOptions = {\n\t\t\t\tenabled: !!config.editor.bracketPairColorization.enabled,\n\t\t\t\tindependentColorPoolPerBracketType: !!config.editor.bracketPairColorization.independentColorPoolPerBracketType\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisForSimpleWidget: isForSimpleWidget,\n\t\t\ttabSize: tabSize,\n\t\t\tindentSize: indentSize,\n\t\t\tinsertSpaces: insertSpaces,\n\t\t\tdetectIndentation: detectIndentation,\n\t\t\tdefaultEOL: newDefaultEOL,\n\t\t\ttrimAutoWhitespace: trimAutoWhitespace,\n\t\t\tlargeFileOptimizations: largeFileOptimizations,\n\t\t\tbracketPairColorizationOptions\n\t\t};\n\t}\n\n\tprivate _getEOL(resource: URI | undefined, language: string): string {\n\t\tif (resource) {\n\t\t\treturn this._resourcePropertiesService.getEOL(resource, language);\n\t\t}\n\t\tconst eol = this._configurationService.getValue('files.eol', { overrideIdentifier: language });\n\t\tif (eol && typeof eol === 'string' && eol !== 'auto') {\n\t\t\treturn eol;\n\t\t}\n\t\treturn platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\\n' : '\\r\\n';\n\t}\n\n\tprivate _shouldRestoreUndoStack(): boolean {\n\t\tconst result = this._configurationService.getValue('files.restoreUndoStack');\n\t\tif (typeof result === 'boolean') {\n\t\t\treturn result;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic getCreationOptions(languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tconst language = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId);\n\t\tlet creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];\n\t\tif (!creationOptions) {\n\t\t\tconst editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });\n\t\t\tconst eol = this._getEOL(resource, language);\n\t\t\tcreationOptions = ModelService._readModelOptions({ editor, eol }, isForSimpleWidget);\n\t\t\tthis._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;\n\t\t}\n\t\treturn creationOptions;\n\t}\n\n\tprivate _updateModelOptions(e: IConfigurationChangeEvent | undefined): void {\n\t\tconst oldOptionsByLanguageAndResource = this._modelCreationOptionsByLanguageAndResource;\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\n\t\t// Update options on all models\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tconst modelData = this._models[modelId];\n\t\t\tconst language = modelData.model.getLanguageId();\n\t\t\tconst uri = modelData.model.uri;\n\n\t\t\tif (e && !e.affectsConfiguration('editor', { overrideIdentifier: language, resource: uri }) && !e.affectsConfiguration('files.eol', { overrideIdentifier: language, resource: uri })) {\n\t\t\t\tcontinue; // perf: skip if this model is not affected by configuration change\n\t\t\t}\n\n\t\t\tconst oldOptions = oldOptionsByLanguageAndResource[language + uri];\n\t\t\tconst newOptions = this.getCreationOptions(language, uri, modelData.model.isForSimpleWidget);\n\t\t\tModelService._setModelOptionsForModel(modelData.model, newOptions, oldOptions);\n\t\t}\n\t}\n\n\tprivate static _setModelOptionsForModel(model: ITextModel, newOptions: ITextModelCreationOptions, currentOptions: ITextModelCreationOptions): void {\n\t\tif (currentOptions && currentOptions.defaultEOL !== newOptions.defaultEOL && model.getLineCount() === 1) {\n\t\t\tmodel.setEOL(newOptions.defaultEOL === DefaultEndOfLine.LF ? EndOfLineSequence.LF : EndOfLineSequence.CRLF);\n\t\t}\n\n\t\tif (currentOptions\n\t\t\t&& (currentOptions.detectIndentation === newOptions.detectIndentation)\n\t\t\t&& (currentOptions.insertSpaces === newOptions.insertSpaces)\n\t\t\t&& (currentOptions.tabSize === newOptions.tabSize)\n\t\t\t&& (currentOptions.indentSize === newOptions.indentSize)\n\t\t\t&& (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)\n\t\t\t&& equals(currentOptions.bracketPairColorizationOptions, newOptions.bracketPairColorizationOptions)\n\t\t) {\n\t\t\t// Same indent opts, no need to touch the model\n\t\t\treturn;\n\t\t}\n\n\t\tif (newOptions.detectIndentation) {\n\t\t\tmodel.detectIndentation(newOptions.insertSpaces, newOptions.tabSize);\n\t\t\tmodel.updateOptions({\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t} else {\n\t\t\tmodel.updateOptions({\n\t\t\t\tinsertSpaces: newOptions.insertSpaces,\n\t\t\t\ttabSize: newOptions.tabSize,\n\t\t\t\tindentSize: newOptions.indentSize,\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- begin IModelService\n\n\tprivate _insertDisposedModel(disposedModelData: DisposedModelInfo): void {\n\t\tthis._disposedModels.set(MODEL_ID(disposedModelData.uri), disposedModelData);\n\t\tthis._disposedModelsHeapSize += disposedModelData.heapSize;\n\t}\n\n\tprivate _removeDisposedModel(resource: URI): DisposedModelInfo | undefined {\n\t\tconst disposedModelData = this._disposedModels.get(MODEL_ID(resource));\n\t\tif (disposedModelData) {\n\t\t\tthis._disposedModelsHeapSize -= disposedModelData.heapSize;\n\t\t}\n\t\tthis._disposedModels.delete(MODEL_ID(resource));\n\t\treturn disposedModelData;\n\t}\n\n\tprivate _ensureDisposedModelsHeapSize(maxModelsHeapSize: number): void {\n\t\tif (this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t// we must remove some old undo stack elements to free up some memory\n\t\t\tconst disposedModels: DisposedModelInfo[] = [];\n\t\t\tthis._disposedModels.forEach(entry => {\n\t\t\t\tif (!entry.sharesUndoRedoStack) {\n\t\t\t\t\tdisposedModels.push(entry);\n\t\t\t\t}\n\t\t\t});\n\t\t\tdisposedModels.sort((a, b) => a.time - b.time);\n\t\t\twhile (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t\tconst disposedModel = disposedModels.shift()!;\n\t\t\t\tthis._removeDisposedModel(disposedModel.uri);\n\t\t\t\tif (disposedModel.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModel.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _createModelData(value: string | ITextBufferFactory, languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ModelData {\n\t\t// create & save the model\n\t\tconst options = this.getCreationOptions(languageIdOrSelection, resource, isForSimpleWidget);\n\t\tconst model: TextModel = this._instantiationService.createInstance(TextModel,\n\t\t\tvalue,\n\t\t\tlanguageIdOrSelection,\n\t\t\toptions,\n\t\t\tresource\n\t\t);\n\t\tif (resource && this._disposedModels.has(MODEL_ID(resource))) {\n\t\t\tconst disposedModelData = this._removeDisposedModel(resource)!;\n\t\t\tconst elements = this._undoRedoService.getElements(resource);\n\t\t\tconst sha1Computer = this._getSHA1Computer();\n\t\t\tconst sha1IsEqual = (\n\t\t\t\tsha1Computer.canComputeSHA1(model)\n\t\t\t\t\t? sha1Computer.computeSHA1(model) === disposedModelData.sha1\n\t\t\t\t\t: false\n\t\t\t);\n\t\t\tif (sha1IsEqual || disposedModelData.sharesUndoRedoStack) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis._undoRedoService.setElementsValidFlag(resource, true, (element) => (isEditStackElement(element) && element.matchesResource(resource)));\n\t\t\t\tif (sha1IsEqual) {\n\t\t\t\t\tmodel._overwriteVersionId(disposedModelData.versionId);\n\t\t\t\t\tmodel._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);\n\t\t\t\t\tmodel._overwriteInitialUndoRedoSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (disposedModelData.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst modelId = MODEL_ID(model.uri);\n\n\t\tif (this._models[modelId]) {\n\t\t\t// There already exists a model with this id => this is a programmer error\n\t\t\tthrow new Error('ModelService: Cannot add model because it already exists!');\n\t\t}\n\n\t\tconst modelData = new ModelData(\n\t\t\tmodel,\n\t\t\t(model) => this._onWillDispose(model),\n\t\t\t(model, e) => this._onDidChangeLanguage(model, e)\n\t\t);\n\t\tthis._models[modelId] = modelData;\n\n\t\treturn modelData;\n\t}\n\n\tpublic createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget: boolean = false): ITextModel {\n\t\tlet modelData: ModelData;\n\n\t\tif (languageSelection) {\n\t\t\tmodelData = this._createModelData(value, languageSelection, resource, isForSimpleWidget);\n\t\t} else {\n\t\t\tmodelData = this._createModelData(value, PLAINTEXT_LANGUAGE_ID, resource, isForSimpleWidget);\n\t\t}\n\n\t\tthis._onModelAdded.fire(modelData.model);\n\n\t\treturn modelData.model;\n\t}\n\n\tpublic getModels(): ITextModel[] {\n\t\tconst ret: ITextModel[] = [];\n\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tret.push(this._models[modelId].model);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tpublic getModel(resource: URI): ITextModel | null {\n\t\tconst modelId = MODEL_ID(resource);\n\t\tconst modelData = this._models[modelId];\n\t\tif (!modelData) {\n\t\t\treturn null;\n\t\t}\n\t\treturn modelData.model;\n\t}\n\n\t// --- end IModelService\n\n\tprotected _schemaShouldMaintainUndoRedoElements(resource: URI) {\n\t\treturn (\n\t\t\tresource.scheme === Schemas.file\n\t\t\t|| resource.scheme === Schemas.vscodeRemote\n\t\t\t|| resource.scheme === Schemas.vscodeUserData\n\t\t\t|| resource.scheme === Schemas.vscodeNotebookCell\n\t\t\t|| resource.scheme === 'fake-fs' // for tests\n\t\t);\n\t}\n\n\tprivate _onWillDispose(model: ITextModel): void {\n\t\tconst modelId = MODEL_ID(model.uri);\n\t\tconst modelData = this._models[modelId];\n\n\t\tconst sharesUndoRedoStack = (this._undoRedoService.getUriComparisonKey(model.uri) !== model.uri.toString());\n\t\tlet maintainUndoRedoStack = false;\n\t\tlet heapSize = 0;\n\t\tif (sharesUndoRedoStack || (this._shouldRestoreUndoStack() && this._schemaShouldMaintainUndoRedoElements(model.uri))) {\n\t\t\tconst elements = this._undoRedoService.getElements(model.uri);\n\t\t\tif (elements.past.length > 0 || elements.future.length > 0) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst maxMemory = ModelService.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;\n\t\tconst sha1Computer = this._getSHA1Computer();\n\t\tif (!maintainUndoRedoStack) {\n\t\t\tif (!sharesUndoRedoStack) {\n\t\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!sharesUndoRedoStack && (heapSize > maxMemory || !sha1Computer.canComputeSHA1(model))) {\n\t\t\t// the undo stack for this file would never fit in the configured memory or the file is very large, so don't bother with it.\n\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t}\n\t\t} else {\n\t\t\tthis._ensureDisposedModelsHeapSize(maxMemory - heapSize);\n\t\t\t// We only invalidate the elements, but they remain in the undo-redo service.\n\t\t\tthis._undoRedoService.setElementsValidFlag(model.uri, false, (element) => (isEditStackElement(element) && element.matchesResource(model.uri)));\n\t\t\tthis._insertDisposedModel(new DisposedModelInfo(model.uri, modelData.model.getInitialUndoRedoSnapshot(), Date.now(), sharesUndoRedoStack, heapSize, sha1Computer.computeSHA1(model), model.getVersionId(), model.getAlternativeVersionId()));\n\t\t}\n\n\t\tdelete this._models[modelId];\n\t\tmodelData.dispose();\n\n\t\t// clean up cache\n\t\tdelete this._modelCreationOptionsByLanguageAndResource[model.getLanguageId() + model.uri];\n\n\t\tthis._onModelRemoved.fire(model);\n\t}\n\n\tprivate _onDidChangeLanguage(model: ITextModel, e: IModelLanguageChangedEvent): void {\n\t\tconst oldLanguageId = e.oldLanguage;\n\t\tconst newLanguageId = model.getLanguageId();\n\t\tconst oldOptions = this.getCreationOptions(oldLanguageId, model.uri, model.isForSimpleWidget);\n\t\tconst newOptions = this.getCreationOptions(newLanguageId, model.uri, model.isForSimpleWidget);\n\t\tModelService._setModelOptionsForModel(model, newOptions, oldOptions);\n\t\tthis._onModelModeChanged.fire({ model, oldLanguageId: oldLanguageId });\n\t}\n\n\tprotected _getSHA1Computer(): ITextModelSHA1Computer {\n\t\treturn new DefaultModelSHA1Computer();\n\t}\n}\n\nexport interface ITextModelSHA1Computer {\n\tcanComputeSHA1(model: ITextModel): boolean;\n\tcomputeSHA1(model: ITextModel): string;\n}\n\nexport class DefaultModelSHA1Computer implements ITextModelSHA1Computer {\n\n\tpublic static MAX_MODEL_SIZE = 10 * 1024 * 1024; // takes 200ms to compute a sha1 on a 10MB model on a new machine\n\n\tcanComputeSHA1(model: ITextModel): boolean {\n\t\treturn (model.getValueLength() <= DefaultModelSHA1Computer.MAX_MODEL_SIZE);\n\t}\n\n\tcomputeSHA1(model: ITextModel): string {\n\t\t// compute the sha1\n\t\tconst shaComputer = new StringSHA1();\n\t\tconst snapshot = model.createSnapshot();\n\t\tlet text: string | null;\n\t\twhile ((text = snapshot.read())) {\n\t\t\tshaComputer.update(text);\n\t\t}\n\t\treturn shaComputer.digest();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/common/services/modelService.ts","vs/editor/common/services/modelService.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;AAEhG,OAAO,EAAE,OAAO,EAAS,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAe,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAA6B,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAC3H,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAA6B,MAAM,+CAA+C,CAAC;AAC5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/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Emitter, Event } from '../../../base/common/event.js';\nimport { StringSHA1 } from '../../../base/common/hash.js';\nimport { Disposable, DisposableStore, IDisposable } from '../../../base/common/lifecycle.js';\nimport { Schemas } from '../../../base/common/network.js';\nimport { equals } from '../../../base/common/objects.js';\nimport * as platform from '../../../base/common/platform.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IConfigurationChangeEvent, IConfigurationService } from '../../../platform/configuration/common/configuration.js';\nimport { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';\nimport { IUndoRedoService, ResourceEditStackSnapshot } from '../../../platform/undoRedo/common/undoRedo.js';\nimport { clampedInt } from '../config/editorOptions.js';\nimport { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';\nimport { ILanguageSelection } from '../languages/language.js';\nimport { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';\nimport { DefaultEndOfLine, EndOfLineSequence, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from '../model.js';\nimport { isEditStackElement } from '../model/editStack.js';\nimport { TextModel } from '../model/textModel.js';\nimport { IModelLanguageChangedEvent } from '../textModelEvents.js';\nimport { IModelService } from './model.js';\nimport { ITextResourcePropertiesService } from './textResourceConfiguration.js';\n\nfunction MODEL_ID(resource: URI): string {\n\treturn resource.toString();\n}\n\nclass ModelData implements IDisposable {\n\n\tprivate readonly _modelEventListeners = new DisposableStore();\n\n\tconstructor(\n\t\tpublic readonly model: TextModel,\n\t\tonWillDispose: (model: ITextModel) => void,\n\t\tonDidChangeLanguage: (model: ITextModel, e: IModelLanguageChangedEvent) => void\n\t) {\n\t\tthis.model = model;\n\t\tthis._modelEventListeners.add(model.onWillDispose(() => onWillDispose(model)));\n\t\tthis._modelEventListeners.add(model.onDidChangeLanguage((e) => onDidChangeLanguage(model, e)));\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._modelEventListeners.dispose();\n\t}\n}\n\ninterface IRawEditorConfig {\n\ttabSize?: unknown;\n\tindentSize?: unknown;\n\tinsertSpaces?: unknown;\n\tdetectIndentation?: unknown;\n\ttrimAutoWhitespace?: unknown;\n\tlargeFileOptimizations?: unknown;\n\tbracketPairColorization?: unknown;\n}\n\ninterface IRawConfig {\n\teol?: unknown;\n\teditor?: IRawEditorConfig;\n}\n\nconst DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;\n\nclass DisposedModelInfo {\n\tconstructor(\n\t\tpublic readonly uri: URI,\n\t\tpublic readonly initialUndoRedoSnapshot: ResourceEditStackSnapshot | null,\n\t\tpublic readonly time: number,\n\t\tpublic readonly sharesUndoRedoStack: boolean,\n\t\tpublic readonly heapSize: number,\n\t\tpublic readonly sha1: string,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly alternativeVersionId: number,\n\t) { }\n}\n\nexport class ModelService extends Disposable implements IModelService {\n\n\tpublic static MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK = 20 * 1024 * 1024;\n\n\tpublic _serviceBrand: undefined;\n\n\tprivate readonly _onModelAdded: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelAdded: Event<ITextModel> = this._onModelAdded.event;\n\n\tprivate readonly _onModelRemoved: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelRemoved: Event<ITextModel> = this._onModelRemoved.event;\n\n\tprivate readonly _onModelModeChanged = this._register(new Emitter<{ model: ITextModel; oldLanguageId: string }>());\n\tpublic readonly onModelLanguageChanged = this._onModelModeChanged.event;\n\n\tprivate _modelCreationOptionsByLanguageAndResource: { [languageAndResource: string]: ITextModelCreationOptions };\n\n\t/**\n\t * All the models known in the system.\n\t */\n\tprivate readonly _models: { [modelId: string]: ModelData };\n\tprivate readonly _disposedModels: Map<string, DisposedModelInfo>;\n\tprivate _disposedModelsHeapSize: number;\n\n\tconstructor(\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@ITextResourcePropertiesService private readonly _resourcePropertiesService: ITextResourcePropertiesService,\n\t\t@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService\n\t) {\n\t\tsuper();\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\t\tthis._models = {};\n\t\tthis._disposedModels = new Map<string, DisposedModelInfo>();\n\t\tthis._disposedModelsHeapSize = 0;\n\n\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => this._updateModelOptions(e)));\n\t\tthis._updateModelOptions(undefined);\n\t}\n\n\tprivate static _readModelOptions(config: IRawConfig, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tlet tabSize = EDITOR_MODEL_DEFAULTS.tabSize;\n\t\tif (config.editor && typeof config.editor.tabSize !== 'undefined') {\n\t\t\ttabSize = clampedInt(config.editor.tabSize, EDITOR_MODEL_DEFAULTS.tabSize, 1, 100);\n\t\t}\n\n\t\tlet indentSize: number | 'tabSize' = 'tabSize';\n\t\tif (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {\n\t\t\tindentSize = clampedInt(config.editor.indentSize, 'tabSize', 1, 100);\n\t\t}\n\n\t\tlet insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;\n\t\tif (config.editor && typeof config.editor.insertSpaces !== 'undefined') {\n\t\t\tinsertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));\n\t\t}\n\n\t\tlet newDefaultEOL = DEFAULT_EOL;\n\t\tconst eol = config.eol;\n\t\tif (eol === '\\r\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.CRLF;\n\t\t} else if (eol === '\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.LF;\n\t\t}\n\n\t\tlet trimAutoWhitespace = EDITOR_MODEL_DEFAULTS.trimAutoWhitespace;\n\t\tif (config.editor && typeof config.editor.trimAutoWhitespace !== 'undefined') {\n\t\t\ttrimAutoWhitespace = (config.editor.trimAutoWhitespace === 'false' ? false : Boolean(config.editor.trimAutoWhitespace));\n\t\t}\n\n\t\tlet detectIndentation = EDITOR_MODEL_DEFAULTS.detectIndentation;\n\t\tif (config.editor && typeof config.editor.detectIndentation !== 'undefined') {\n\t\t\tdetectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));\n\t\t}\n\n\t\tlet largeFileOptimizations = EDITOR_MODEL_DEFAULTS.largeFileOptimizations;\n\t\tif (config.editor && typeof config.editor.largeFileOptimizations !== 'undefined') {\n\t\t\tlargeFileOptimizations = (config.editor.largeFileOptimizations === 'false' ? false : Boolean(config.editor.largeFileOptimizations));\n\t\t}\n\t\tlet bracketPairColorizationOptions = EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions;\n\t\tif (config.editor?.bracketPairColorization && typeof config.editor.bracketPairColorization === 'object') {\n\t\t\tconst bpConfig = config.editor.bracketPairColorization as { enabled?: unknown; independentColorPoolPerBracketType?: unknown };\n\t\t\tbracketPairColorizationOptions = {\n\t\t\t\tenabled: !!bpConfig.enabled,\n\t\t\t\tindependentColorPoolPerBracketType: !!bpConfig.independentColorPoolPerBracketType\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisForSimpleWidget: isForSimpleWidget,\n\t\t\ttabSize: tabSize,\n\t\t\tindentSize: indentSize,\n\t\t\tinsertSpaces: insertSpaces,\n\t\t\tdetectIndentation: detectIndentation,\n\t\t\tdefaultEOL: newDefaultEOL,\n\t\t\ttrimAutoWhitespace: trimAutoWhitespace,\n\t\t\tlargeFileOptimizations: largeFileOptimizations,\n\t\t\tbracketPairColorizationOptions\n\t\t};\n\t}\n\n\tprivate _getEOL(resource: URI | undefined, language: string): string {\n\t\tif (resource) {\n\t\t\treturn this._resourcePropertiesService.getEOL(resource, language);\n\t\t}\n\t\tconst eol = this._configurationService.getValue('files.eol', { overrideIdentifier: language });\n\t\tif (eol && typeof eol === 'string' && eol !== 'auto') {\n\t\t\treturn eol;\n\t\t}\n\t\treturn platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\\n' : '\\r\\n';\n\t}\n\n\tprivate _shouldRestoreUndoStack(): boolean {\n\t\tconst result = this._configurationService.getValue('files.restoreUndoStack');\n\t\tif (typeof result === 'boolean') {\n\t\t\treturn result;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic getCreationOptions(languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tconst language = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId);\n\t\tlet creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];\n\t\tif (!creationOptions) {\n\t\t\tconst editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });\n\t\t\tconst eol = this._getEOL(resource, language);\n\t\t\tcreationOptions = ModelService._readModelOptions({ editor, eol }, isForSimpleWidget);\n\t\t\tthis._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;\n\t\t}\n\t\treturn creationOptions;\n\t}\n\n\tprivate _updateModelOptions(e: IConfigurationChangeEvent | undefined): void {\n\t\tconst oldOptionsByLanguageAndResource = this._modelCreationOptionsByLanguageAndResource;\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\n\t\t// Update options on all models\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tconst modelData = this._models[modelId];\n\t\t\tconst language = modelData.model.getLanguageId();\n\t\t\tconst uri = modelData.model.uri;\n\n\t\t\tif (e && !e.affectsConfiguration('editor', { overrideIdentifier: language, resource: uri }) && !e.affectsConfiguration('files.eol', { overrideIdentifier: language, resource: uri })) {\n\t\t\t\tcontinue; // perf: skip if this model is not affected by configuration change\n\t\t\t}\n\n\t\t\tconst oldOptions = oldOptionsByLanguageAndResource[language + uri];\n\t\t\tconst newOptions = this.getCreationOptions(language, uri, modelData.model.isForSimpleWidget);\n\t\t\tModelService._setModelOptionsForModel(modelData.model, newOptions, oldOptions);\n\t\t}\n\t}\n\n\tprivate static _setModelOptionsForModel(model: ITextModel, newOptions: ITextModelCreationOptions, currentOptions: ITextModelCreationOptions): void {\n\t\tif (currentOptions && currentOptions.defaultEOL !== newOptions.defaultEOL && model.getLineCount() === 1) {\n\t\t\tmodel.setEOL(newOptions.defaultEOL === DefaultEndOfLine.LF ? EndOfLineSequence.LF : EndOfLineSequence.CRLF);\n\t\t}\n\n\t\tif (currentOptions\n\t\t\t&& (currentOptions.detectIndentation === newOptions.detectIndentation)\n\t\t\t&& (currentOptions.insertSpaces === newOptions.insertSpaces)\n\t\t\t&& (currentOptions.tabSize === newOptions.tabSize)\n\t\t\t&& (currentOptions.indentSize === newOptions.indentSize)\n\t\t\t&& (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)\n\t\t\t&& equals(currentOptions.bracketPairColorizationOptions, newOptions.bracketPairColorizationOptions)\n\t\t) {\n\t\t\t// Same indent opts, no need to touch the model\n\t\t\treturn;\n\t\t}\n\n\t\tif (newOptions.detectIndentation) {\n\t\t\tmodel.detectIndentation(newOptions.insertSpaces, newOptions.tabSize);\n\t\t\tmodel.updateOptions({\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t} else {\n\t\t\tmodel.updateOptions({\n\t\t\t\tinsertSpaces: newOptions.insertSpaces,\n\t\t\t\ttabSize: newOptions.tabSize,\n\t\t\t\tindentSize: newOptions.indentSize,\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- begin IModelService\n\n\tprivate _insertDisposedModel(disposedModelData: DisposedModelInfo): void {\n\t\tthis._disposedModels.set(MODEL_ID(disposedModelData.uri), disposedModelData);\n\t\tthis._disposedModelsHeapSize += disposedModelData.heapSize;\n\t}\n\n\tprivate _removeDisposedModel(resource: URI): DisposedModelInfo | undefined {\n\t\tconst disposedModelData = this._disposedModels.get(MODEL_ID(resource));\n\t\tif (disposedModelData) {\n\t\t\tthis._disposedModelsHeapSize -= disposedModelData.heapSize;\n\t\t}\n\t\tthis._disposedModels.delete(MODEL_ID(resource));\n\t\treturn disposedModelData;\n\t}\n\n\tprivate _ensureDisposedModelsHeapSize(maxModelsHeapSize: number): void {\n\t\tif (this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t// we must remove some old undo stack elements to free up some memory\n\t\t\tconst disposedModels: DisposedModelInfo[] = [];\n\t\t\tthis._disposedModels.forEach(entry => {\n\t\t\t\tif (!entry.sharesUndoRedoStack) {\n\t\t\t\t\tdisposedModels.push(entry);\n\t\t\t\t}\n\t\t\t});\n\t\t\tdisposedModels.sort((a, b) => a.time - b.time);\n\t\t\twhile (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t\tconst disposedModel = disposedModels.shift()!;\n\t\t\t\tthis._removeDisposedModel(disposedModel.uri);\n\t\t\t\tif (disposedModel.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModel.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _createModelData(value: string | ITextBufferFactory, languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ModelData {\n\t\t// create & save the model\n\t\tconst options = this.getCreationOptions(languageIdOrSelection, resource, isForSimpleWidget);\n\t\tconst model: TextModel = this._instantiationService.createInstance(TextModel,\n\t\t\tvalue,\n\t\t\tlanguageIdOrSelection,\n\t\t\toptions,\n\t\t\tresource\n\t\t);\n\t\tif (resource && this._disposedModels.has(MODEL_ID(resource))) {\n\t\t\tconst disposedModelData = this._removeDisposedModel(resource)!;\n\t\t\tconst elements = this._undoRedoService.getElements(resource);\n\t\t\tconst sha1Computer = this._getSHA1Computer();\n\t\t\tconst sha1IsEqual = (\n\t\t\t\tsha1Computer.canComputeSHA1(model)\n\t\t\t\t\t? sha1Computer.computeSHA1(model) === disposedModelData.sha1\n\t\t\t\t\t: false\n\t\t\t);\n\t\t\tif (sha1IsEqual || disposedModelData.sharesUndoRedoStack) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis._undoRedoService.setElementsValidFlag(resource, true, (element) => (isEditStackElement(element) && element.matchesResource(resource)));\n\t\t\t\tif (sha1IsEqual) {\n\t\t\t\t\tmodel._overwriteVersionId(disposedModelData.versionId);\n\t\t\t\t\tmodel._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);\n\t\t\t\t\tmodel._overwriteInitialUndoRedoSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (disposedModelData.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst modelId = MODEL_ID(model.uri);\n\n\t\tif (this._models[modelId]) {\n\t\t\t// There already exists a model with this id => this is a programmer error\n\t\t\tthrow new Error('ModelService: Cannot add model because it already exists!');\n\t\t}\n\n\t\tconst modelData = new ModelData(\n\t\t\tmodel,\n\t\t\t(model) => this._onWillDispose(model),\n\t\t\t(model, e) => this._onDidChangeLanguage(model, e)\n\t\t);\n\t\tthis._models[modelId] = modelData;\n\n\t\treturn modelData;\n\t}\n\n\tpublic createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget: boolean = false): ITextModel {\n\t\tlet modelData: ModelData;\n\n\t\tif (languageSelection) {\n\t\t\tmodelData = this._createModelData(value, languageSelection, resource, isForSimpleWidget);\n\t\t} else {\n\t\t\tmodelData = this._createModelData(value, PLAINTEXT_LANGUAGE_ID, resource, isForSimpleWidget);\n\t\t}\n\n\t\tthis._onModelAdded.fire(modelData.model);\n\n\t\treturn modelData.model;\n\t}\n\n\tpublic getModels(): ITextModel[] {\n\t\tconst ret: ITextModel[] = [];\n\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tret.push(this._models[modelId].model);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tpublic getModel(resource: URI): ITextModel | null {\n\t\tconst modelId = MODEL_ID(resource);\n\t\tconst modelData = this._models[modelId];\n\t\tif (!modelData) {\n\t\t\treturn null;\n\t\t}\n\t\treturn modelData.model;\n\t}\n\n\t// --- end IModelService\n\n\tprotected _schemaShouldMaintainUndoRedoElements(resource: URI) {\n\t\treturn (\n\t\t\tresource.scheme === Schemas.file\n\t\t\t|| resource.scheme === Schemas.vscodeRemote\n\t\t\t|| resource.scheme === Schemas.vscodeUserData\n\t\t\t|| resource.scheme === Schemas.vscodeNotebookCell\n\t\t\t|| resource.scheme === 'fake-fs' // for tests\n\t\t);\n\t}\n\n\tprivate _onWillDispose(model: ITextModel): void {\n\t\tconst modelId = MODEL_ID(model.uri);\n\t\tconst modelData = this._models[modelId];\n\n\t\tconst sharesUndoRedoStack = (this._undoRedoService.getUriComparisonKey(model.uri) !== model.uri.toString());\n\t\tlet maintainUndoRedoStack = false;\n\t\tlet heapSize = 0;\n\t\tif (sharesUndoRedoStack || (this._shouldRestoreUndoStack() && this._schemaShouldMaintainUndoRedoElements(model.uri))) {\n\t\t\tconst elements = this._undoRedoService.getElements(model.uri);\n\t\t\tif (elements.past.length > 0 || elements.future.length > 0) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst maxMemory = ModelService.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;\n\t\tconst sha1Computer = this._getSHA1Computer();\n\t\tif (!maintainUndoRedoStack) {\n\t\t\tif (!sharesUndoRedoStack) {\n\t\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!sharesUndoRedoStack && (heapSize > maxMemory || !sha1Computer.canComputeSHA1(model))) {\n\t\t\t// the undo stack for this file would never fit in the configured memory or the file is very large, so don't bother with it.\n\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t}\n\t\t} else {\n\t\t\tthis._ensureDisposedModelsHeapSize(maxMemory - heapSize);\n\t\t\t// We only invalidate the elements, but they remain in the undo-redo service.\n\t\t\tthis._undoRedoService.setElementsValidFlag(model.uri, false, (element) => (isEditStackElement(element) && element.matchesResource(model.uri)));\n\t\t\tthis._insertDisposedModel(new DisposedModelInfo(model.uri, modelData.model.getInitialUndoRedoSnapshot(), Date.now(), sharesUndoRedoStack, heapSize, sha1Computer.computeSHA1(model), model.getVersionId(), model.getAlternativeVersionId()));\n\t\t}\n\n\t\tdelete this._models[modelId];\n\t\tmodelData.dispose();\n\n\t\t// clean up cache\n\t\tdelete this._modelCreationOptionsByLanguageAndResource[model.getLanguageId() + model.uri];\n\n\t\tthis._onModelRemoved.fire(model);\n\t}\n\n\tprivate _onDidChangeLanguage(model: ITextModel, e: IModelLanguageChangedEvent): void {\n\t\tconst oldLanguageId = e.oldLanguage;\n\t\tconst newLanguageId = model.getLanguageId();\n\t\tconst oldOptions = this.getCreationOptions(oldLanguageId, model.uri, model.isForSimpleWidget);\n\t\tconst newOptions = this.getCreationOptions(newLanguageId, model.uri, model.isForSimpleWidget);\n\t\tModelService._setModelOptionsForModel(model, newOptions, oldOptions);\n\t\tthis._onModelModeChanged.fire({ model, oldLanguageId: oldLanguageId });\n\t}\n\n\tprotected _getSHA1Computer(): ITextModelSHA1Computer {\n\t\treturn new DefaultModelSHA1Computer();\n\t}\n}\n\nexport interface ITextModelSHA1Computer {\n\tcanComputeSHA1(model: ITextModel): boolean;\n\tcomputeSHA1(model: ITextModel): string;\n}\n\nexport class DefaultModelSHA1Computer implements ITextModelSHA1Computer {\n\n\tpublic static MAX_MODEL_SIZE = 10 * 1024 * 1024; // takes 200ms to compute a sha1 on a 10MB model on a new machine\n\n\tcanComputeSHA1(model: ITextModel): boolean {\n\t\treturn (model.getValueLength() <= DefaultModelSHA1Computer.MAX_MODEL_SIZE);\n\t}\n\n\tcomputeSHA1(model: ITextModel): string {\n\t\t// compute the sha1\n\t\tconst shaComputer = new StringSHA1();\n\t\tconst snapshot = model.createSnapshot();\n\t\tlet text: string | null;\n\t\twhile ((text = snapshot.read())) {\n\t\t\tshaComputer.update(text);\n\t\t}\n\t\treturn shaComputer.digest();\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Emitter, Event } from '../../../base/common/event.js';\nimport { StringSHA1 } from '../../../base/common/hash.js';\nimport { Disposable, DisposableStore, IDisposable } from '../../../base/common/lifecycle.js';\nimport { Schemas } from '../../../base/common/network.js';\nimport { equals } from '../../../base/common/objects.js';\nimport * as platform from '../../../base/common/platform.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { IConfigurationChangeEvent, IConfigurationService } from '../../../platform/configuration/common/configuration.js';\nimport { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';\nimport { IUndoRedoService, ResourceEditStackSnapshot } from '../../../platform/undoRedo/common/undoRedo.js';\nimport { clampedInt } from '../config/editorOptions.js';\nimport { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';\nimport { ILanguageSelection } from '../languages/language.js';\nimport { PLAINTEXT_LANGUAGE_ID } from '../languages/modesRegistry.js';\nimport { DefaultEndOfLine, EndOfLineSequence, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from '../model.js';\nimport { isEditStackElement } from '../model/editStack.js';\nimport { TextModel } from '../model/textModel.js';\nimport { IModelLanguageChangedEvent } from '../textModelEvents.js';\nimport { IModelService } from './model.js';\nimport { ITextResourcePropertiesService } from './textResourceConfiguration.js';\n\nfunction MODEL_ID(resource: URI): string {\n\treturn resource.toString();\n}\n\nclass ModelData implements IDisposable {\n\n\tprivate readonly _modelEventListeners = new DisposableStore();\n\n\tconstructor(\n\t\tpublic readonly model: TextModel,\n\t\tonWillDispose: (model: ITextModel) => void,\n\t\tonDidChangeLanguage: (model: ITextModel, e: IModelLanguageChangedEvent) => void\n\t) {\n\t\tthis.model = model;\n\t\tthis._modelEventListeners.add(model.onWillDispose(() => onWillDispose(model)));\n\t\tthis._modelEventListeners.add(model.onDidChangeLanguage((e) => onDidChangeLanguage(model, e)));\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._modelEventListeners.dispose();\n\t}\n}\n\ninterface IRawEditorConfig {\n\ttabSize?: unknown;\n\tindentSize?: unknown;\n\tinsertSpaces?: unknown;\n\tdetectIndentation?: unknown;\n\ttrimAutoWhitespace?: unknown;\n\tlargeFileOptimizations?: unknown;\n\tbracketPairColorization?: unknown;\n}\n\ninterface IRawConfig {\n\teol?: unknown;\n\teditor?: IRawEditorConfig;\n}\n\nconst DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;\n\nclass DisposedModelInfo {\n\tconstructor(\n\t\tpublic readonly uri: URI,\n\t\tpublic readonly initialUndoRedoSnapshot: ResourceEditStackSnapshot | null,\n\t\tpublic readonly time: number,\n\t\tpublic readonly sharesUndoRedoStack: boolean,\n\t\tpublic readonly heapSize: number,\n\t\tpublic readonly sha1: string,\n\t\tpublic readonly versionId: number,\n\t\tpublic readonly alternativeVersionId: number,\n\t) { }\n}\n\nexport class ModelService extends Disposable implements IModelService {\n\n\tpublic static MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK = 20 * 1024 * 1024;\n\n\tpublic _serviceBrand: undefined;\n\n\tprivate readonly _onModelAdded: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelAdded: Event<ITextModel> = this._onModelAdded.event;\n\n\tprivate readonly _onModelRemoved: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());\n\tpublic readonly onModelRemoved: Event<ITextModel> = this._onModelRemoved.event;\n\n\tprivate readonly _onModelModeChanged = this._register(new Emitter<{ model: ITextModel; oldLanguageId: string }>());\n\tpublic readonly onModelLanguageChanged = this._onModelModeChanged.event;\n\n\tprivate _modelCreationOptionsByLanguageAndResource: { [languageAndResource: string]: ITextModelCreationOptions };\n\n\t/**\n\t * All the models known in the system.\n\t */\n\tprivate readonly _models: { [modelId: string]: ModelData };\n\tprivate readonly _disposedModels: Map<string, DisposedModelInfo>;\n\tprivate _disposedModelsHeapSize: number;\n\n\tconstructor(\n\t\t@IConfigurationService private readonly _configurationService: IConfigurationService,\n\t\t@ITextResourcePropertiesService private readonly _resourcePropertiesService: ITextResourcePropertiesService,\n\t\t@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,\n\t\t@IInstantiationService private readonly _instantiationService: IInstantiationService\n\t) {\n\t\tsuper();\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\t\tthis._models = {};\n\t\tthis._disposedModels = new Map<string, DisposedModelInfo>();\n\t\tthis._disposedModelsHeapSize = 0;\n\n\t\tthis._register(this._configurationService.onDidChangeConfiguration(e => this._updateModelOptions(e)));\n\t\tthis._updateModelOptions(undefined);\n\t}\n\n\tprivate static _readModelOptions(config: IRawConfig, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tlet tabSize = EDITOR_MODEL_DEFAULTS.tabSize;\n\t\tif (config.editor && typeof config.editor.tabSize !== 'undefined') {\n\t\t\ttabSize = clampedInt(config.editor.tabSize, EDITOR_MODEL_DEFAULTS.tabSize, 1, 100);\n\t\t}\n\n\t\tlet indentSize: number | 'tabSize' = 'tabSize';\n\t\tif (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {\n\t\t\tindentSize = clampedInt(config.editor.indentSize, 'tabSize', 1, 100);\n\t\t}\n\n\t\tlet insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;\n\t\tif (config.editor && typeof config.editor.insertSpaces !== 'undefined') {\n\t\t\tinsertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));\n\t\t}\n\n\t\tlet newDefaultEOL = DEFAULT_EOL;\n\t\tconst eol = config.eol;\n\t\tif (eol === '\\r\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.CRLF;\n\t\t} else if (eol === '\\n') {\n\t\t\tnewDefaultEOL = DefaultEndOfLine.LF;\n\t\t}\n\n\t\tlet trimAutoWhitespace = EDITOR_MODEL_DEFAULTS.trimAutoWhitespace;\n\t\tif (config.editor && typeof config.editor.trimAutoWhitespace !== 'undefined') {\n\t\t\ttrimAutoWhitespace = (config.editor.trimAutoWhitespace === 'false' ? false : Boolean(config.editor.trimAutoWhitespace));\n\t\t}\n\n\t\tlet detectIndentation = EDITOR_MODEL_DEFAULTS.detectIndentation;\n\t\tif (config.editor && typeof config.editor.detectIndentation !== 'undefined') {\n\t\t\tdetectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));\n\t\t}\n\n\t\tlet largeFileOptimizations = EDITOR_MODEL_DEFAULTS.largeFileOptimizations;\n\t\tif (config.editor && typeof config.editor.largeFileOptimizations !== 'undefined') {\n\t\t\tlargeFileOptimizations = (config.editor.largeFileOptimizations === 'false' ? false : Boolean(config.editor.largeFileOptimizations));\n\t\t}\n\t\tlet bracketPairColorizationOptions = EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions;\n\t\tif (config.editor?.bracketPairColorization && typeof config.editor.bracketPairColorization === 'object') {\n\t\t\tconst bpConfig = config.editor.bracketPairColorization as { enabled?: unknown; independentColorPoolPerBracketType?: unknown };\n\t\t\tbracketPairColorizationOptions = {\n\t\t\t\tenabled: !!bpConfig.enabled,\n\t\t\t\tindependentColorPoolPerBracketType: !!bpConfig.independentColorPoolPerBracketType\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tisForSimpleWidget: isForSimpleWidget,\n\t\t\ttabSize: tabSize,\n\t\t\tindentSize: indentSize,\n\t\t\tinsertSpaces: insertSpaces,\n\t\t\tdetectIndentation: detectIndentation,\n\t\t\tdefaultEOL: newDefaultEOL,\n\t\t\ttrimAutoWhitespace: trimAutoWhitespace,\n\t\t\tlargeFileOptimizations: largeFileOptimizations,\n\t\t\tbracketPairColorizationOptions\n\t\t};\n\t}\n\n\tprivate _getEOL(resource: URI | undefined, language: string): string {\n\t\tif (resource) {\n\t\t\treturn this._resourcePropertiesService.getEOL(resource, language);\n\t\t}\n\t\tconst eol = this._configurationService.getValue('files.eol', { overrideIdentifier: language });\n\t\tif (eol && typeof eol === 'string' && eol !== 'auto') {\n\t\t\treturn eol;\n\t\t}\n\t\treturn platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\\n' : '\\r\\n';\n\t}\n\n\tprivate _shouldRestoreUndoStack(): boolean {\n\t\tconst result = this._configurationService.getValue('files.restoreUndoStack');\n\t\tif (typeof result === 'boolean') {\n\t\t\treturn result;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic getCreationOptions(languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {\n\t\tconst language = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId);\n\t\tlet creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];\n\t\tif (!creationOptions) {\n\t\t\tconst editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });\n\t\t\tconst eol = this._getEOL(resource, language);\n\t\t\tcreationOptions = ModelService._readModelOptions({ editor, eol }, isForSimpleWidget);\n\t\t\tthis._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;\n\t\t}\n\t\treturn creationOptions;\n\t}\n\n\tprivate _updateModelOptions(e: IConfigurationChangeEvent | undefined): void {\n\t\tconst oldOptionsByLanguageAndResource = this._modelCreationOptionsByLanguageAndResource;\n\t\tthis._modelCreationOptionsByLanguageAndResource = Object.create(null);\n\n\t\t// Update options on all models\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tconst modelData = this._models[modelId];\n\t\t\tconst language = modelData.model.getLanguageId();\n\t\t\tconst uri = modelData.model.uri;\n\n\t\t\tif (e && !e.affectsConfiguration('editor', { overrideIdentifier: language, resource: uri }) && !e.affectsConfiguration('files.eol', { overrideIdentifier: language, resource: uri })) {\n\t\t\t\tcontinue; // perf: skip if this model is not affected by configuration change\n\t\t\t}\n\n\t\t\tconst oldOptions = oldOptionsByLanguageAndResource[language + uri];\n\t\t\tconst newOptions = this.getCreationOptions(language, uri, modelData.model.isForSimpleWidget);\n\t\t\tModelService._setModelOptionsForModel(modelData.model, newOptions, oldOptions);\n\t\t}\n\t}\n\n\tprivate static _setModelOptionsForModel(model: ITextModel, newOptions: ITextModelCreationOptions, currentOptions: ITextModelCreationOptions): void {\n\t\tif (currentOptions && currentOptions.defaultEOL !== newOptions.defaultEOL && model.getLineCount() === 1) {\n\t\t\tmodel.setEOL(newOptions.defaultEOL === DefaultEndOfLine.LF ? EndOfLineSequence.LF : EndOfLineSequence.CRLF);\n\t\t}\n\n\t\tif (currentOptions\n\t\t\t&& (currentOptions.detectIndentation === newOptions.detectIndentation)\n\t\t\t&& (currentOptions.insertSpaces === newOptions.insertSpaces)\n\t\t\t&& (currentOptions.tabSize === newOptions.tabSize)\n\t\t\t&& (currentOptions.indentSize === newOptions.indentSize)\n\t\t\t&& (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)\n\t\t\t&& equals(currentOptions.bracketPairColorizationOptions, newOptions.bracketPairColorizationOptions)\n\t\t) {\n\t\t\t// Same indent opts, no need to touch the model\n\t\t\treturn;\n\t\t}\n\n\t\tif (newOptions.detectIndentation) {\n\t\t\tmodel.detectIndentation(newOptions.insertSpaces, newOptions.tabSize);\n\t\t\tmodel.updateOptions({\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t} else {\n\t\t\tmodel.updateOptions({\n\t\t\t\tinsertSpaces: newOptions.insertSpaces,\n\t\t\t\ttabSize: newOptions.tabSize,\n\t\t\t\tindentSize: newOptions.indentSize,\n\t\t\t\ttrimAutoWhitespace: newOptions.trimAutoWhitespace,\n\t\t\t\tbracketColorizationOptions: newOptions.bracketPairColorizationOptions\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- begin IModelService\n\n\tprivate _insertDisposedModel(disposedModelData: DisposedModelInfo): void {\n\t\tthis._disposedModels.set(MODEL_ID(disposedModelData.uri), disposedModelData);\n\t\tthis._disposedModelsHeapSize += disposedModelData.heapSize;\n\t}\n\n\tprivate _removeDisposedModel(resource: URI): DisposedModelInfo | undefined {\n\t\tconst disposedModelData = this._disposedModels.get(MODEL_ID(resource));\n\t\tif (disposedModelData) {\n\t\t\tthis._disposedModelsHeapSize -= disposedModelData.heapSize;\n\t\t}\n\t\tthis._disposedModels.delete(MODEL_ID(resource));\n\t\treturn disposedModelData;\n\t}\n\n\tprivate _ensureDisposedModelsHeapSize(maxModelsHeapSize: number): void {\n\t\tif (this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t// we must remove some old undo stack elements to free up some memory\n\t\t\tconst disposedModels: DisposedModelInfo[] = [];\n\t\t\tthis._disposedModels.forEach(entry => {\n\t\t\t\tif (!entry.sharesUndoRedoStack) {\n\t\t\t\t\tdisposedModels.push(entry);\n\t\t\t\t}\n\t\t\t});\n\t\t\tdisposedModels.sort((a, b) => a.time - b.time);\n\t\t\twhile (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {\n\t\t\t\tconst disposedModel = disposedModels.shift()!;\n\t\t\t\tthis._removeDisposedModel(disposedModel.uri);\n\t\t\t\tif (disposedModel.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModel.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _createModelData(value: string | ITextBufferFactory, languageIdOrSelection: string | ILanguageSelection, resource: URI | undefined, isForSimpleWidget: boolean): ModelData {\n\t\t// create & save the model\n\t\tconst options = this.getCreationOptions(languageIdOrSelection, resource, isForSimpleWidget);\n\t\tconst model: TextModel = this._instantiationService.createInstance(TextModel,\n\t\t\tvalue,\n\t\t\tlanguageIdOrSelection,\n\t\t\toptions,\n\t\t\tresource\n\t\t);\n\t\tif (resource && this._disposedModels.has(MODEL_ID(resource))) {\n\t\t\tconst disposedModelData = this._removeDisposedModel(resource)!;\n\t\t\tconst elements = this._undoRedoService.getElements(resource);\n\t\t\tconst sha1Computer = this._getSHA1Computer();\n\t\t\tconst sha1IsEqual = (\n\t\t\t\tsha1Computer.canComputeSHA1(model)\n\t\t\t\t\t? sha1Computer.computeSHA1(model) === disposedModelData.sha1\n\t\t\t\t\t: false\n\t\t\t);\n\t\t\tif (sha1IsEqual || disposedModelData.sharesUndoRedoStack) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(resource)) {\n\t\t\t\t\t\telement.setModel(model);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis._undoRedoService.setElementsValidFlag(resource, true, (element) => (isEditStackElement(element) && element.matchesResource(resource)));\n\t\t\t\tif (sha1IsEqual) {\n\t\t\t\t\tmodel._overwriteVersionId(disposedModelData.versionId);\n\t\t\t\t\tmodel._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);\n\t\t\t\t\tmodel._overwriteInitialUndoRedoSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (disposedModelData.initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(disposedModelData.initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst modelId = MODEL_ID(model.uri);\n\n\t\tif (this._models[modelId]) {\n\t\t\t// There already exists a model with this id => this is a programmer error\n\t\t\tthrow new Error('ModelService: Cannot add model because it already exists!');\n\t\t}\n\n\t\tconst modelData = new ModelData(\n\t\t\tmodel,\n\t\t\t(model) => this._onWillDispose(model),\n\t\t\t(model, e) => this._onDidChangeLanguage(model, e)\n\t\t);\n\t\tthis._models[modelId] = modelData;\n\n\t\treturn modelData;\n\t}\n\n\tpublic createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget: boolean = false): ITextModel {\n\t\tlet modelData: ModelData;\n\n\t\tif (languageSelection) {\n\t\t\tmodelData = this._createModelData(value, languageSelection, resource, isForSimpleWidget);\n\t\t} else {\n\t\t\tmodelData = this._createModelData(value, PLAINTEXT_LANGUAGE_ID, resource, isForSimpleWidget);\n\t\t}\n\n\t\tthis._onModelAdded.fire(modelData.model);\n\n\t\treturn modelData.model;\n\t}\n\n\tpublic getModels(): ITextModel[] {\n\t\tconst ret: ITextModel[] = [];\n\n\t\tconst keys = Object.keys(this._models);\n\t\tfor (let i = 0, len = keys.length; i < len; i++) {\n\t\t\tconst modelId = keys[i];\n\t\t\tret.push(this._models[modelId].model);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tpublic getModel(resource: URI): ITextModel | null {\n\t\tconst modelId = MODEL_ID(resource);\n\t\tconst modelData = this._models[modelId];\n\t\tif (!modelData) {\n\t\t\treturn null;\n\t\t}\n\t\treturn modelData.model;\n\t}\n\n\t// --- end IModelService\n\n\tprotected _schemaShouldMaintainUndoRedoElements(resource: URI) {\n\t\treturn (\n\t\t\tresource.scheme === Schemas.file\n\t\t\t|| resource.scheme === Schemas.vscodeRemote\n\t\t\t|| resource.scheme === Schemas.vscodeUserData\n\t\t\t|| resource.scheme === Schemas.vscodeNotebookCell\n\t\t\t|| resource.scheme === 'fake-fs' // for tests\n\t\t);\n\t}\n\n\tprivate _onWillDispose(model: ITextModel): void {\n\t\tconst modelId = MODEL_ID(model.uri);\n\t\tconst modelData = this._models[modelId];\n\n\t\tconst sharesUndoRedoStack = (this._undoRedoService.getUriComparisonKey(model.uri) !== model.uri.toString());\n\t\tlet maintainUndoRedoStack = false;\n\t\tlet heapSize = 0;\n\t\tif (sharesUndoRedoStack || (this._shouldRestoreUndoStack() && this._schemaShouldMaintainUndoRedoElements(model.uri))) {\n\t\t\tconst elements = this._undoRedoService.getElements(model.uri);\n\t\t\tif (elements.past.length > 0 || elements.future.length > 0) {\n\t\t\t\tfor (const element of elements.past) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const element of elements.future) {\n\t\t\t\t\tif (isEditStackElement(element) && element.matchesResource(model.uri)) {\n\t\t\t\t\t\tmaintainUndoRedoStack = true;\n\t\t\t\t\t\theapSize += element.heapSize(model.uri);\n\t\t\t\t\t\telement.setModel(model.uri); // remove reference from text buffer instance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst maxMemory = ModelService.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;\n\t\tconst sha1Computer = this._getSHA1Computer();\n\t\tif (!maintainUndoRedoStack) {\n\t\t\tif (!sharesUndoRedoStack) {\n\t\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!sharesUndoRedoStack && (heapSize > maxMemory || !sha1Computer.canComputeSHA1(model))) {\n\t\t\t// the undo stack for this file would never fit in the configured memory or the file is very large, so don't bother with it.\n\t\t\tconst initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();\n\t\t\tif (initialUndoRedoSnapshot !== null) {\n\t\t\t\tthis._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);\n\t\t\t}\n\t\t} else {\n\t\t\tthis._ensureDisposedModelsHeapSize(maxMemory - heapSize);\n\t\t\t// We only invalidate the elements, but they remain in the undo-redo service.\n\t\t\tthis._undoRedoService.setElementsValidFlag(model.uri, false, (element) => (isEditStackElement(element) && element.matchesResource(model.uri)));\n\t\t\tthis._insertDisposedModel(new DisposedModelInfo(model.uri, modelData.model.getInitialUndoRedoSnapshot(), Date.now(), sharesUndoRedoStack, heapSize, sha1Computer.computeSHA1(model), model.getVersionId(), model.getAlternativeVersionId()));\n\t\t}\n\n\t\tdelete this._models[modelId];\n\t\tmodelData.dispose();\n\n\t\t// clean up cache\n\t\tdelete this._modelCreationOptionsByLanguageAndResource[model.getLanguageId() + model.uri];\n\n\t\tthis._onModelRemoved.fire(model);\n\t}\n\n\tprivate _onDidChangeLanguage(model: ITextModel, e: IModelLanguageChangedEvent): void {\n\t\tconst oldLanguageId = e.oldLanguage;\n\t\tconst newLanguageId = model.getLanguageId();\n\t\tconst oldOptions = this.getCreationOptions(oldLanguageId, model.uri, model.isForSimpleWidget);\n\t\tconst newOptions = this.getCreationOptions(newLanguageId, model.uri, model.isForSimpleWidget);\n\t\tModelService._setModelOptionsForModel(model, newOptions, oldOptions);\n\t\tthis._onModelModeChanged.fire({ model, oldLanguageId: oldLanguageId });\n\t}\n\n\tprotected _getSHA1Computer(): ITextModelSHA1Computer {\n\t\treturn new DefaultModelSHA1Computer();\n\t}\n}\n\nexport interface ITextModelSHA1Computer {\n\tcanComputeSHA1(model: ITextModel): boolean;\n\tcomputeSHA1(model: ITextModel): string;\n}\n\nexport class DefaultModelSHA1Computer implements ITextModelSHA1Computer {\n\n\tpublic static MAX_MODEL_SIZE = 10 * 1024 * 1024; // takes 200ms to compute a sha1 on a 10MB model on a new machine\n\n\tcanComputeSHA1(model: ITextModel): boolean {\n\t\treturn (model.getValueLength() <= DefaultModelSHA1Computer.MAX_MODEL_SIZE);\n\t}\n\n\tcomputeSHA1(model: ITextModel): string {\n\t\t// compute the sha1\n\t\tconst shaComputer = new StringSHA1();\n\t\tconst snapshot = model.createSnapshot();\n\t\tlet text: string | null;\n\t\twhile ((text = snapshot.read())) {\n\t\t\tshaComputer.update(text);\n\t\t}\n\t\treturn shaComputer.digest();\n\t}\n}\n"]}