monaco-editor-core 0.55.0-dev-20251021 → 0.55.0-dev-20251023

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 (226) hide show
  1. package/esm/nls.keys.json +1 -1
  2. package/esm/nls.messages.cs.js +2 -2
  3. package/esm/nls.messages.de.js +2 -2
  4. package/esm/nls.messages.es.js +2 -2
  5. package/esm/nls.messages.fr.js +2 -2
  6. package/esm/nls.messages.it.js +2 -2
  7. package/esm/nls.messages.ja.js +2 -2
  8. package/esm/nls.messages.js +1 -1
  9. package/esm/nls.messages.json +1 -1
  10. package/esm/nls.messages.ko.js +2 -2
  11. package/esm/nls.messages.pl.js +2 -2
  12. package/esm/nls.messages.pt-br.js +2 -2
  13. package/esm/nls.messages.ru.js +2 -2
  14. package/esm/nls.messages.tr.js +2 -2
  15. package/esm/nls.messages.zh-cn.js +2 -2
  16. package/esm/nls.messages.zh-tw.js +2 -2
  17. package/esm/nls.metadata.json +23 -5
  18. package/esm/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
  19. package/esm/vs/base/browser/ui/iconLabel/iconlabel.css +2 -3
  20. package/esm/vs/base/browser/ui/list/listPaging.js +5 -1
  21. package/esm/vs/base/browser/ui/list/listPaging.js.map +1 -1
  22. package/esm/vs/base/browser/ui/list/listView.js +4 -3
  23. package/esm/vs/base/browser/ui/list/listView.js.map +1 -1
  24. package/esm/vs/base/common/arrays.js +10 -0
  25. package/esm/vs/base/common/arrays.js.map +1 -1
  26. package/esm/vs/base/common/codiconsLibrary.js +1 -0
  27. package/esm/vs/base/common/codiconsLibrary.js.map +1 -1
  28. package/esm/vs/base/common/paging.js.map +1 -1
  29. package/esm/vs/base/common/platform.js +1 -0
  30. package/esm/vs/base/common/platform.js.map +1 -1
  31. package/esm/vs/base/common/policy.js +40 -1
  32. package/esm/vs/base/common/policy.js.map +1 -1
  33. package/esm/vs/base/common/validation.js +157 -0
  34. package/esm/vs/base/common/validation.js.map +1 -0
  35. package/esm/vs/editor/browser/controller/editContext/native/screenReaderSupport.js +1 -1
  36. package/esm/vs/editor/browser/controller/editContext/screenReaderUtils.js +4 -4
  37. package/esm/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.js +1 -1
  38. package/esm/vs/editor/browser/coreCommands.js +3 -3
  39. package/esm/vs/editor/browser/editorExtensions.js +9 -9
  40. package/esm/vs/editor/browser/gpu/viewGpuContext.js +1 -1
  41. package/esm/vs/editor/browser/services/hoverService/hoverWidget.js +1 -1
  42. package/esm/vs/editor/browser/services/hoverService/updatableHoverWidget.js +1 -1
  43. package/esm/vs/editor/browser/services/inlineCompletionsService.js +4 -4
  44. package/esm/vs/editor/browser/services/inlineCompletionsService.js.map +1 -1
  45. package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js +2 -2
  46. package/esm/vs/editor/browser/widget/diffEditor/commands.js +12 -12
  47. package/esm/vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer.js +14 -14
  48. package/esm/vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer.js.map +1 -1
  49. package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorEditors.js +1 -1
  50. package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/copySelection.js +1 -1
  51. package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/inlineDiffDeletedCodeMargin.js +7 -7
  52. package/esm/vs/editor/browser/widget/diffEditor/diffEditor.contribution.js +5 -5
  53. package/esm/vs/editor/browser/widget/diffEditor/features/hideUnchangedRegionsFeature.js +7 -7
  54. package/esm/vs/editor/browser/widget/diffEditor/features/movedBlocksLinesFeature.js +2 -2
  55. package/esm/vs/editor/browser/widget/diffEditor/features/revertButtonsFeature.js +2 -2
  56. package/esm/vs/editor/browser/widget/diffEditor/registrations.contribution.js +5 -5
  57. package/esm/vs/editor/browser/widget/multiDiffEditor/colors.js +3 -3
  58. package/esm/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.js +2 -2
  59. package/esm/vs/editor/common/config/editorConfigurationSchema.js +54 -54
  60. package/esm/vs/editor/common/config/editorOptions.js +406 -406
  61. package/esm/vs/editor/common/core/editorColorRegistry.js +68 -68
  62. package/esm/vs/editor/common/editorContextKeys.js +46 -46
  63. package/esm/vs/editor/common/languages/modesRegistry.js +1 -1
  64. package/esm/vs/editor/common/languages.js +66 -56
  65. package/esm/vs/editor/common/languages.js.map +1 -1
  66. package/esm/vs/editor/common/model/editStack.js +1 -1
  67. package/esm/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.js.map +1 -1
  68. package/esm/vs/editor/common/model/tokens/treeSitter/treeSitterSyntaxTokenBackend.js +1 -1
  69. package/esm/vs/editor/common/model/tokens/treeSitter/treeSitterSyntaxTokenBackend.js.map +1 -1
  70. package/esm/vs/editor/common/services/treeSitter/treeSitterLibraryService.js.map +1 -1
  71. package/esm/vs/editor/common/standaloneStrings.js +10 -10
  72. package/esm/vs/editor/common/viewLayout/viewLineRenderer.js +2 -2
  73. package/esm/vs/editor/common/viewModel/viewModelLines.js.map +1 -1
  74. package/esm/vs/editor/contrib/anchorSelect/browser/anchorSelect.js +6 -6
  75. package/esm/vs/editor/contrib/bracketMatching/browser/bracketMatching.js +6 -6
  76. package/esm/vs/editor/contrib/caretOperations/browser/caretOperations.js +2 -2
  77. package/esm/vs/editor/contrib/caretOperations/browser/transpose.js +1 -1
  78. package/esm/vs/editor/contrib/clipboard/browser/clipboard.js +17 -17
  79. package/esm/vs/editor/contrib/codeAction/browser/codeAction.js +1 -1
  80. package/esm/vs/editor/contrib/codeAction/browser/codeActionCommands.js +29 -29
  81. package/esm/vs/editor/contrib/codeAction/browser/codeActionContributions.js +3 -3
  82. package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js +3 -3
  83. package/esm/vs/editor/contrib/codeAction/browser/codeActionMenu.js +8 -8
  84. package/esm/vs/editor/contrib/codeAction/browser/lightBulbWidget.js +9 -9
  85. package/esm/vs/editor/contrib/codelens/browser/codelensController.js +2 -2
  86. package/esm/vs/editor/contrib/colorPicker/browser/colorPickerParts/colorPickerCloseButton.js +1 -1
  87. package/esm/vs/editor/contrib/colorPicker/browser/colorPickerParts/colorPickerHeader.js +1 -1
  88. package/esm/vs/editor/contrib/colorPicker/browser/standaloneColorPicker/standaloneColorPickerActions.js +7 -7
  89. package/esm/vs/editor/contrib/comment/browser/comment.js +6 -6
  90. package/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js +10 -10
  91. package/esm/vs/editor/contrib/cursorUndo/browser/cursorUndo.js +2 -2
  92. package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +4 -4
  93. package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +9 -9
  94. package/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +8 -8
  95. package/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +3 -3
  96. package/esm/vs/editor/contrib/dropOrPasteInto/browser/postEditWidget.js +2 -2
  97. package/esm/vs/editor/contrib/editorState/browser/keybindingCancellation.js +1 -1
  98. package/esm/vs/editor/contrib/find/browser/findController.js +16 -16
  99. package/esm/vs/editor/contrib/find/browser/findWidget.js +26 -26
  100. package/esm/vs/editor/contrib/folding/browser/folding.js +20 -20
  101. package/esm/vs/editor/contrib/folding/browser/folding.js.map +1 -1
  102. package/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +9 -9
  103. package/esm/vs/editor/contrib/folding/browser/foldingDecorations.js.map +1 -1
  104. package/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +3 -3
  105. package/esm/vs/editor/contrib/format/browser/formatActions.js +2 -2
  106. package/esm/vs/editor/contrib/gotoError/browser/gotoError.js +8 -8
  107. package/esm/vs/editor/contrib/gotoError/browser/gotoErrorWidget.js +14 -14
  108. package/esm/vs/editor/contrib/gotoSymbol/browser/goToCommands.js +39 -39
  109. package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js +1 -1
  110. package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesController.js +3 -3
  111. package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesTree.js +3 -3
  112. package/esm/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.js +3 -3
  113. package/esm/vs/editor/contrib/gotoSymbol/browser/referencesModel.js +8 -8
  114. package/esm/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.js +3 -3
  115. package/esm/vs/editor/contrib/gpu/browser/gpuActions.js +4 -4
  116. package/esm/vs/editor/contrib/hover/browser/hoverActionIds.js +2 -2
  117. package/esm/vs/editor/contrib/hover/browser/hoverActions.js +24 -24
  118. package/esm/vs/editor/contrib/hover/browser/markdownHoverParticipant.js +9 -9
  119. package/esm/vs/editor/contrib/hover/browser/markerHoverParticipant.js +5 -5
  120. package/esm/vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace.js +2 -2
  121. package/esm/vs/editor/contrib/indentation/browser/indentation.js +20 -20
  122. package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsHover.js +8 -8
  123. package/esm/vs/editor/contrib/inlineCompletions/browser/controller/commands.js +63 -52
  124. package/esm/vs/editor/contrib/inlineCompletions/browser/controller/commands.js.map +1 -1
  125. package/esm/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionContextKeys.js +12 -12
  126. package/esm/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.js +1 -1
  127. package/esm/vs/editor/contrib/inlineCompletions/browser/hintsWidget/hoverParticipant.js +1 -1
  128. package/esm/vs/editor/contrib/inlineCompletions/browser/hintsWidget/inlineCompletionsHintsWidget.js +5 -5
  129. package/esm/vs/editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js +2 -4
  130. package/esm/vs/editor/contrib/inlineCompletions/browser/inlineCompletions.contribution.js.map +1 -1
  131. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +11 -12
  132. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js.map +1 -1
  133. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.js +4 -4
  134. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.js.map +1 -1
  135. package/esm/vs/editor/contrib/inlineCompletions/browser/model/suggestWidgetAdapter.js.map +1 -1
  136. package/esm/vs/editor/contrib/inlineCompletions/browser/telemetry.js.map +1 -1
  137. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorMenu.js +6 -6
  138. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditWithChanges.js +3 -0
  139. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditWithChanges.js.map +1 -1
  140. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsModel.js +1 -1
  141. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js +5 -5
  142. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js.map +1 -1
  143. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/theme.js +20 -20
  144. package/esm/vs/editor/contrib/insertFinalNewLine/browser/insertFinalNewLine.js +1 -1
  145. package/esm/vs/editor/contrib/lineSelection/browser/lineSelection.js +1 -1
  146. package/esm/vs/editor/contrib/linesOperations/browser/linesOperations.js +31 -31
  147. package/esm/vs/editor/contrib/linkedEditing/browser/linkedEditing.js +2 -2
  148. package/esm/vs/editor/contrib/links/browser/links.js +10 -10
  149. package/esm/vs/editor/contrib/message/browser/messageController.js +1 -1
  150. package/esm/vs/editor/contrib/multicursor/browser/multicursor.js +22 -22
  151. package/esm/vs/editor/contrib/parameterHints/browser/parameterHints.js +1 -1
  152. package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js +4 -4
  153. package/esm/vs/editor/contrib/peekView/browser/peekView.js +18 -18
  154. package/esm/vs/editor/contrib/placeholderText/browser/placeholderText.contribution.js +1 -1
  155. package/esm/vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess.js +35 -28
  156. package/esm/vs/editor/contrib/quickAccess/browser/gotoLineQuickAccess.js.map +1 -1
  157. package/esm/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess.js +32 -32
  158. package/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +2 -2
  159. package/esm/vs/editor/contrib/rename/browser/rename.js +11 -11
  160. package/esm/vs/editor/contrib/rename/browser/renameWidget.js +7 -7
  161. package/esm/vs/editor/contrib/smartSelect/browser/smartSelect.js +4 -4
  162. package/esm/vs/editor/contrib/snippet/browser/snippetController2.js +4 -4
  163. package/esm/vs/editor/contrib/snippet/browser/snippetVariables.js +4 -4
  164. package/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollActions.js +11 -11
  165. package/esm/vs/editor/contrib/suggest/browser/suggest.js +8 -8
  166. package/esm/vs/editor/contrib/suggest/browser/suggestController.js +10 -10
  167. package/esm/vs/editor/contrib/suggest/browser/suggestWidget.js +17 -17
  168. package/esm/vs/editor/contrib/suggest/browser/suggestWidgetDetails.js +2 -2
  169. package/esm/vs/editor/contrib/suggest/browser/suggestWidgetRenderer.js +2 -2
  170. package/esm/vs/editor/contrib/suggest/browser/wordContextKey.js +1 -1
  171. package/esm/vs/editor/contrib/symbolIcons/browser/symbolIcons.js +33 -33
  172. package/esm/vs/editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode.js +4 -4
  173. package/esm/vs/editor/contrib/tokenization/browser/tokenization.js +1 -1
  174. package/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +1 -1
  175. package/esm/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.js +24 -24
  176. package/esm/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js +5 -5
  177. package/esm/vs/editor/contrib/wordHighlighter/browser/highlightDecorations.js +9 -9
  178. package/esm/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.js +3 -3
  179. package/esm/vs/editor/contrib/wordOperations/browser/wordOperations.js +1 -1
  180. package/esm/vs/editor/standalone/browser/standaloneTreeSitterLibraryService.js +2 -12
  181. package/esm/vs/editor/standalone/browser/standaloneTreeSitterLibraryService.js.map +1 -1
  182. package/esm/vs/platform/accessibilitySignal/browser/accessibilitySignalService.js +62 -62
  183. package/esm/vs/platform/action/common/actionCommonCategories.js +6 -6
  184. package/esm/vs/platform/actionWidget/browser/actionList.js +4 -4
  185. package/esm/vs/platform/actionWidget/browser/actionWidget.js +7 -7
  186. package/esm/vs/platform/actions/browser/menuEntryActionViewItem.js +5 -5
  187. package/esm/vs/platform/actions/browser/toolbar.js +2 -2
  188. package/esm/vs/platform/actions/common/actions.js +1 -0
  189. package/esm/vs/platform/actions/common/actions.js.map +1 -1
  190. package/esm/vs/platform/actions/common/menuService.js +2 -2
  191. package/esm/vs/platform/configuration/common/configurationRegistry.js +10 -10
  192. package/esm/vs/platform/contextkey/browser/contextKeyService.js +1 -1
  193. package/esm/vs/platform/contextkey/common/contextkey.js +9 -9
  194. package/esm/vs/platform/contextkey/common/contextkeys.js +9 -9
  195. package/esm/vs/platform/contextkey/common/scanner.js +5 -5
  196. package/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +1 -1
  197. package/esm/vs/platform/keybinding/common/abstractKeybindingService.js +4 -4
  198. package/esm/vs/platform/list/browser/listService.js +27 -27
  199. package/esm/vs/platform/markers/common/markerService.js +2 -2
  200. package/esm/vs/platform/markers/common/markers.js +6 -6
  201. package/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +19 -9
  202. package/esm/vs/platform/quickinput/browser/commandsQuickAccess.js.map +1 -1
  203. package/esm/vs/platform/quickinput/browser/helpQuickAccess.js +1 -1
  204. package/esm/vs/platform/quickinput/browser/quickInput.js +10 -10
  205. package/esm/vs/platform/quickinput/browser/quickInputActions.js +5 -5
  206. package/esm/vs/platform/quickinput/browser/quickInputController.js +6 -6
  207. package/esm/vs/platform/quickinput/browser/quickInputList.js +1 -1
  208. package/esm/vs/platform/quickinput/browser/quickInputUtils.js +1 -1
  209. package/esm/vs/platform/quickinput/browser/tree/quickInputTreeAccessibilityProvider.js +2 -2
  210. package/esm/vs/platform/quickinput/browser/tree/quickInputTreeAccessibilityProvider.js.map +1 -1
  211. package/esm/vs/platform/theme/common/colorUtils.js +2 -2
  212. package/esm/vs/platform/theme/common/colors/baseColors.js +17 -17
  213. package/esm/vs/platform/theme/common/colors/chartsColors.js +8 -8
  214. package/esm/vs/platform/theme/common/colors/editorColors.js +95 -95
  215. package/esm/vs/platform/theme/common/colors/inputColors.js +47 -47
  216. package/esm/vs/platform/theme/common/colors/listColors.js +36 -36
  217. package/esm/vs/platform/theme/common/colors/menuColors.js +7 -7
  218. package/esm/vs/platform/theme/common/colors/minimapColors.js +11 -11
  219. package/esm/vs/platform/theme/common/colors/miscColors.js +15 -15
  220. package/esm/vs/platform/theme/common/colors/quickpickColors.js +9 -9
  221. package/esm/vs/platform/theme/common/colors/searchColors.js +3 -3
  222. package/esm/vs/platform/theme/common/iconRegistry.js +6 -6
  223. package/esm/vs/platform/undoRedo/common/undoRedoService.js +20 -20
  224. package/esm/vs/platform/workspace/common/workspace.js +1 -1
  225. package/package.json +2 -2
  226. package/version.txt +1 -1
@@ -7,16 +7,16 @@ import { matchesSubString } from '../../../../../base/common/filters.js';
7
7
  import { observableSignal } from '../../../../../base/common/observable.js';
8
8
  import { commonPrefixLength, commonSuffixLength, splitLines } from '../../../../../base/common/strings.js';
9
9
  import { applyEditsToRanges, StringEdit, StringReplacement } from '../../../../common/core/edits/stringEdit.js';
10
- import { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';
10
+ import { TextEdit, TextReplacement } from '../../../../common/core/edits/textEdit.js';
11
11
  import { Range } from '../../../../common/core/range.js';
12
- import { TextEdit } from '../../../../common/core/edits/textEdit.js';
12
+ import { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';
13
13
  import { StringText } from '../../../../common/core/text/abstractText.js';
14
+ import { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';
14
15
  import { TextLength } from '../../../../common/core/text/textLength.js';
15
16
  import { linesDiffComputers } from '../../../../common/diff/linesDiffComputers.js';
16
17
  import { InlineCompletionTriggerKind } from '../../../../common/languages.js';
17
18
  import { TextModelText } from '../../../../common/model/textModelText.js';
18
19
  import { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';
19
- import { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';
20
20
  export var InlineSuggestionItem;
21
21
  (function (InlineSuggestionItem) {
22
22
  function create(data, textModel) {
@@ -233,7 +233,7 @@ export class InlineEditItem extends InlineSuggestionItemBase {
233
233
  const offsetEdit = getStringEdit(textModel, data.range, data.insertText);
234
234
  const text = new TextModelText(textModel);
235
235
  const textEdit = TextEdit.fromStringEdit(offsetEdit, text);
236
- const singleTextEdit = textEdit.toReplacement(text);
236
+ const singleTextEdit = offsetEdit.isEmpty() ? new TextReplacement(new Range(1, 1, 1, 1), '') : textEdit.toReplacement(text); // FIXME: .toReplacement() can throw because offsetEdit is empty because we get an empty diff in getStringEdit after diffing
237
237
  const identity = new InlineSuggestionIdentity();
238
238
  const edits = offsetEdit.replacements.map(edit => {
239
239
  const replacedRange = Range.fromPositions(textModel.getPositionAt(edit.replaceRange.start), textModel.getPositionAt(edit.replaceRange.endExclusive));
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts","vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E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,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QACtG,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAuB,EAAE,SAAqB;IAChF,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,IAAI,kBAAkB,CAAC,2BAA2B,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC;IACzC,MAAM,eAAe,GAAG,aAAa,CAAC,UAAU,CAAC;IAEjD,+FAA+F;IAC/F,oEAAoE;IACpE,IAAI,WAAW,KAAK,CAAC,IAAI,eAAe,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","file":"inlineSuggestionItem.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 { BugIndicatingError } from '../../../../../base/common/errors.js';\nimport { matchesSubString } from '../../../../../base/common/filters.js';\nimport { observableSignal } from '../../../../../base/common/observable.js';\nimport { commonPrefixLength, commonSuffixLength, splitLines } from '../../../../../base/common/strings.js';\nimport { ICommandService } from '../../../../../platform/commands/common/commands.js';\nimport { ISingleEditOperation } from '../../../../common/core/editOperation.js';\nimport { applyEditsToRanges, StringEdit, StringReplacement } from '../../../../common/core/edits/stringEdit.js';\nimport { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { PositionOffsetTransformerBase } from '../../../../common/core/text/positionToOffset.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement, TextEdit } from '../../../../common/core/edits/textEdit.js';\nimport { StringText } from '../../../../common/core/text/abstractText.js';\nimport { TextLength } from '../../../../common/core/text/textLength.js';\nimport { linesDiffComputers } from '../../../../common/diff/linesDiffComputers.js';\nimport { InlineCompletion, InlineCompletionTriggerKind, Command, InlineCompletionWarning, PartialAcceptInfo, InlineCompletionEndOfLifeReason, InlineCompletionDisplayLocationKind } from '../../../../common/languages.js';\nimport { ITextModel, EndOfLinePreference } from '../../../../common/model.js';\nimport { TextModelText } from '../../../../common/model/textModelText.js';\nimport { IDisplayLocation, InlineSuggestData, InlineSuggestionList, PartialAcceptance, SnippetInfo } from './provideInlineCompletions.js';\nimport { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';\nimport { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';\n\nexport type InlineSuggestionItem = InlineEditItem | InlineCompletionItem;\n\nexport namespace InlineSuggestionItem {\n\texport function create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineSuggestionItem {\n\t\tif (!data.isInlineEdit) {\n\t\t\treturn InlineCompletionItem.create(data, textModel);\n\t\t} else {\n\t\t\treturn InlineEditItem.create(data, textModel);\n\t\t}\n\t}\n}\n\nabstract class InlineSuggestionItemBase {\n\tconstructor(\n\t\tprotected readonly _data: InlineSuggestData,\n\t\tpublic readonly identity: InlineSuggestionIdentity,\n\t\tpublic readonly displayLocation: InlineSuggestDisplayLocation | undefined\n\t) { }\n\n\t/**\n\t * A reference to the original inline completion list this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tpublic get source(): InlineSuggestionList { return this._data.source; }\n\n\tpublic get isFromExplicitRequest(): boolean { return this._data.context.triggerKind === InlineCompletionTriggerKind.Explicit; }\n\tpublic get forwardStable(): boolean { return this.source.inlineSuggestions.enableForwardStability ?? false; }\n\tpublic get editRange(): Range { return this.getSingleTextEdit().range; }\n\tpublic get targetRange(): Range { return this.displayLocation?.range ?? this.editRange; }\n\tpublic get insertText(): string { return this.getSingleTextEdit().text; }\n\tpublic get semanticId(): string { return this.hash; }\n\tpublic get action(): Command | undefined { return this._sourceInlineCompletion.action; }\n\tpublic get command(): Command | undefined { return this._sourceInlineCompletion.command; }\n\tpublic get warning(): InlineCompletionWarning | undefined { return this._sourceInlineCompletion.warning; }\n\tpublic get showInlineEditMenu(): boolean { return !!this._sourceInlineCompletion.showInlineEditMenu; }\n\tpublic get hash() {\n\t\treturn JSON.stringify([\n\t\t\tthis.getSingleTextEdit().text,\n\t\t\tthis.getSingleTextEdit().range.getStartPosition().toString()\n\t\t]);\n\t}\n\n\tpublic get requestUuid(): string { return this._data.context.requestUuid; }\n\n\tpublic get partialAccepts(): PartialAcceptance { return this._data.partialAccepts; }\n\n\t/**\n\t * A reference to the original inline completion this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tprivate get _sourceInlineCompletion(): InlineCompletion { return this._data.sourceInlineCompletion; }\n\n\n\tpublic abstract getSingleTextEdit(): TextReplacement;\n\n\tpublic abstract withEdit(userEdit: StringEdit, textModel: ITextModel): InlineSuggestionItem | undefined;\n\n\tpublic abstract withIdentity(identity: InlineSuggestionIdentity): InlineSuggestionItem;\n\tpublic abstract canBeReused(model: ITextModel, position: Position): boolean;\n\n\n\tpublic addRef(): void {\n\t\tthis.identity.addRef();\n\t\tthis.source.addRef();\n\t}\n\n\tpublic removeRef(): void {\n\t\tthis.identity.removeRef();\n\t\tthis.source.removeRef();\n\t}\n\n\tpublic reportInlineEditShown(commandService: ICommandService, viewKind: InlineCompletionViewKind, viewData: InlineCompletionViewData) {\n\t\tthis._data.reportInlineEditShown(commandService, this.insertText, viewKind, viewData);\n\t}\n\n\tpublic reportPartialAccept(acceptedCharacters: number, info: PartialAcceptInfo, partialAcceptance: PartialAcceptance) {\n\t\tthis._data.reportPartialAccept(acceptedCharacters, info, partialAcceptance);\n\t}\n\n\tpublic reportEndOfLife(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.reportEndOfLife(reason);\n\t}\n\n\tpublic setEndOfLifeReason(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.setEndOfLifeReason(reason);\n\t}\n\n\tpublic reportInlineEditError(reason: string): void {\n\t\tthis._data.reportInlineEditError(reason);\n\t}\n\n\tpublic setIsPreceeded(item: InlineSuggestionItem): void {\n\t\tthis._data.setIsPreceeded(item.partialAccepts);\n\t}\n\n\tpublic setNotShownReasonIfNotSet(reason: string): void {\n\t\tthis._data.setNotShownReason(reason);\n\t}\n\n\t/**\n\t * Avoid using this method. Instead introduce getters for the needed properties.\n\t*/\n\tpublic getSourceCompletion(): InlineCompletion {\n\t\treturn this._sourceInlineCompletion;\n\t}\n}\n\nexport class InlineSuggestionIdentity {\n\tprivate static idCounter = 0;\n\tprivate readonly _onDispose = observableSignal(this);\n\n\tprivate _refCount = 1;\n\tpublic readonly id = 'InlineCompletionIdentity' + InlineSuggestionIdentity.idCounter++;\n\n\taddRef() {\n\t\tthis._refCount++;\n\t}\n\n\tremoveRef() {\n\t\tthis._refCount--;\n\t\tif (this._refCount === 0) {\n\t\t\tthis._onDispose.trigger(undefined);\n\t\t}\n\t}\n}\n\nclass InlineSuggestDisplayLocation implements IDisplayLocation {\n\n\tpublic static create(displayLocation: IDisplayLocation) {\n\t\treturn new InlineSuggestDisplayLocation(\n\t\t\tdisplayLocation.range,\n\t\t\tdisplayLocation.label,\n\t\t\tdisplayLocation.kind\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly label: string,\n\t\tpublic readonly kind: InlineCompletionDisplayLocationKind\n\t) { }\n\n\tpublic withEdit(edit: StringEdit, positionOffsetTransformer: PositionOffsetTransformerBase): InlineSuggestDisplayLocation | undefined {\n\t\tconst offsetRange = new OffsetRange(\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getStartPosition()),\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getEndPosition())\n\t\t);\n\n\t\tconst newOffsetRange = applyEditsToRanges([offsetRange], edit)[0];\n\t\tif (!newOffsetRange) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst newRange = positionOffsetTransformer.getRange(newOffsetRange);\n\n\t\treturn new InlineSuggestDisplayLocation(newRange, this.label, this.kind);\n\t}\n}\n\nexport class InlineCompletionItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineCompletionItem {\n\t\tconst identity = new InlineSuggestionIdentity();\n\t\tconst transformer = getPositionOffsetTransformerFromTextModel(textModel);\n\n\t\tconst insertText = data.insertText.replace(/\\r\\n|\\r|\\n/g, textModel.getEOL());\n\n\t\tconst edit = reshapeInlineCompletion(new StringReplacement(transformer.getOffsetRange(data.range), insertText), textModel);\n\t\tconst trimmedEdit = edit.removeCommonSuffixAndPrefix(textModel.getValue());\n\t\tconst textEdit = transformer.getTextReplacement(edit);\n\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\n\t\treturn new InlineCompletionItem(edit, trimmedEdit, textEdit, textEdit.range, data.snippetInfo, data.additionalTextEdits, data, identity, displayLocation);\n\t}\n\n\tpublic readonly isInlineEdit = false;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringReplacement,\n\t\tprivate readonly _trimmedEdit: StringReplacement,\n\t\tprivate readonly _textEdit: TextReplacement,\n\t\tprivate readonly _originalRange: Range,\n\t\tpublic readonly snippetInfo: SnippetInfo | undefined,\n\t\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[],\n\n\t\tdata: InlineSuggestData,\n\t\tidentity: InlineSuggestionIdentity,\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\toverride get hash(): string {\n\t\treturn JSON.stringify(this._trimmedEdit.toJson());\n\t}\n\n\toverride getSingleTextEdit(): TextReplacement { return this._textEdit; }\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineCompletionItem {\n\t\treturn new InlineCompletionItem(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedEdit,\n\t\t\tthis._textEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis.displayLocation\n\t\t);\n\t}\n\n\toverride withEdit(textModelEdit: StringEdit, textModel: ITextModel): InlineCompletionItem | undefined {\n\t\tconst newEditRange = applyEditsToRanges([this._edit.replaceRange], textModelEdit);\n\t\tif (newEditRange.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst newEdit = new StringReplacement(newEditRange[0], this._textEdit.text);\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextReplacement(newEdit);\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelEdit, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst trimmedEdit = newEdit.removeCommonSuffixAndPrefix(textModel.getValue());\n\n\t\treturn new InlineCompletionItem(\n\t\t\tnewEdit,\n\t\t\ttrimmedEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tnewDisplayLocation\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\tconst updatedRange = this._textEdit.range;\n\t\tconst result = !!updatedRange\n\t\t\t&& updatedRange.containsPosition(position)\n\t\t\t&& this.isVisible(model, position)\n\t\t\t&& TextLength.ofRange(updatedRange).isGreaterThanOrEqualTo(TextLength.ofRange(this._originalRange));\n\t\treturn result;\n\t}\n\n\tpublic isVisible(model: ITextModel, cursorPosition: Position): boolean {\n\t\tconst singleTextEdit = this.getSingleTextEdit();\n\t\treturn inlineCompletionIsVisible(singleTextEdit, this._originalRange, model, cursorPosition);\n\t}\n}\n\nexport function inlineCompletionIsVisible(singleTextEdit: TextReplacement, originalRange: Range | undefined, model: ITextModel, cursorPosition: Position): boolean {\n\tconst minimizedReplacement = singleTextRemoveCommonPrefix(singleTextEdit, model);\n\tconst editRange = singleTextEdit.range;\n\tif (!editRange\n\t\t|| (originalRange && !originalRange.getStartPosition().equals(editRange.getStartPosition()))\n\t\t|| cursorPosition.lineNumber !== minimizedReplacement.range.startLineNumber\n\t\t|| minimizedReplacement.isEmpty // if the completion is empty after removing the common prefix of the completion and the model, the completion item would not be visible\n\t) {\n\t\treturn false;\n\t}\n\n\t// We might consider comparing by .toLowerText, but this requires GhostTextReplacement\n\tconst originalValue = model.getValueInRange(minimizedReplacement.range, EndOfLinePreference.LF);\n\tconst filterText = minimizedReplacement.text;\n\n\tconst cursorPosIndex = Math.max(0, cursorPosition.column - minimizedReplacement.range.startColumn);\n\n\tlet filterTextBefore = filterText.substring(0, cursorPosIndex);\n\tlet filterTextAfter = filterText.substring(cursorPosIndex);\n\n\tlet originalValueBefore = originalValue.substring(0, cursorPosIndex);\n\tlet originalValueAfter = originalValue.substring(cursorPosIndex);\n\n\tconst originalValueIndent = model.getLineIndentColumn(minimizedReplacement.range.startLineNumber);\n\tif (minimizedReplacement.range.startColumn <= originalValueIndent) {\n\t\t// Remove indentation\n\t\toriginalValueBefore = originalValueBefore.trimStart();\n\t\tif (originalValueBefore.length === 0) {\n\t\t\toriginalValueAfter = originalValueAfter.trimStart();\n\t\t}\n\t\tfilterTextBefore = filterTextBefore.trimStart();\n\t\tif (filterTextBefore.length === 0) {\n\t\t\tfilterTextAfter = filterTextAfter.trimStart();\n\t\t}\n\t}\n\n\treturn filterTextBefore.startsWith(originalValueBefore)\n\t\t&& !!matchesSubString(originalValueAfter, filterTextAfter);\n}\n\nexport class InlineEditItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineEditItem {\n\t\tconst offsetEdit = getStringEdit(textModel, data.range, data.insertText);\n\t\tconst text = new TextModelText(textModel);\n\t\tconst textEdit = TextEdit.fromStringEdit(offsetEdit, text);\n\t\tconst singleTextEdit = textEdit.toReplacement(text);\n\t\tconst identity = new InlineSuggestionIdentity();\n\n\t\tconst edits = offsetEdit.replacements.map(edit => {\n\t\t\tconst replacedRange = Range.fromPositions(textModel.getPositionAt(edit.replaceRange.start), textModel.getPositionAt(edit.replaceRange.endExclusive));\n\t\t\tconst replacedText = textModel.getValueInRange(replacedRange);\n\t\t\treturn SingleUpdatedNextEdit.create(edit, replacedText);\n\t\t});\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\t\treturn new InlineEditItem(offsetEdit, singleTextEdit, data, identity, edits, displayLocation, false, textModel.getVersionId());\n\t}\n\n\tpublic readonly snippetInfo: SnippetInfo | undefined = undefined;\n\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[] = [];\n\tpublic readonly isInlineEdit = true;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringEdit,\n\t\tprivate readonly _textEdit: TextReplacement,\n\n\t\tdata: InlineSuggestData,\n\n\t\tidentity: InlineSuggestionIdentity,\n\t\tprivate readonly _edits: readonly SingleUpdatedNextEdit[],\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t\tprivate readonly _lastChangePartOfInlineEdit = false,\n\t\tprivate readonly _inlineEditModelVersion: number,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\tpublic get updatedEditModelVersion(): number { return this._inlineEditModelVersion; }\n\tpublic get updatedEdit(): StringEdit { return this._edit; }\n\n\toverride getSingleTextEdit(): TextReplacement {\n\t\treturn this._textEdit;\n\t}\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineEditItem {\n\t\treturn new InlineEditItem(\n\t\t\tthis._edit,\n\t\t\tthis._textEdit,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis._edits,\n\t\t\tthis.displayLocation,\n\t\t\tthis._lastChangePartOfInlineEdit,\n\t\t\tthis._inlineEditModelVersion,\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\treturn this._lastChangePartOfInlineEdit && this.updatedEditModelVersion === model.getVersionId();\n\t}\n\n\toverride withEdit(textModelChanges: StringEdit, textModel: ITextModel): InlineEditItem | undefined {\n\t\tconst edit = this._applyTextModelChanges(textModelChanges, this._edits, textModel);\n\t\treturn edit;\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit, edits: readonly SingleUpdatedNextEdit[], textModel: ITextModel): InlineEditItem | undefined {\n\t\tedits = edits.map(innerEdit => innerEdit.applyTextModelChanges(textModelChanges));\n\n\t\tif (edits.some(edit => edit.edit === undefined)) {\n\t\t\treturn undefined; // change is invalid, so we will have to drop the completion\n\t\t}\n\n\t\tconst newTextModelVersion = textModel.getVersionId();\n\n\t\tlet inlineEditModelVersion = this._inlineEditModelVersion;\n\t\tconst lastChangePartOfInlineEdit = edits.some(edit => edit.lastChangeUpdatedEdit);\n\t\tif (lastChangePartOfInlineEdit) {\n\t\t\tinlineEditModelVersion = newTextModelVersion ?? -1;\n\t\t}\n\n\t\tif (newTextModelVersion === null || inlineEditModelVersion + 20 < newTextModelVersion) {\n\t\t\treturn undefined; // the completion has been ignored for a while, remove it\n\t\t}\n\n\t\tedits = edits.filter(innerEdit => !innerEdit.edit!.isEmpty);\n\t\tif (edits.length === 0) {\n\t\t\treturn undefined; // the completion has been typed by the user\n\t\t}\n\n\t\tconst newEdit = new StringEdit(edits.map(edit => edit.edit!));\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextEdit(newEdit).toReplacement(new TextModelText(textModel));\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelChanges, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn new InlineEditItem(\n\t\t\tnewEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tedits,\n\t\t\tnewDisplayLocation,\n\t\t\tlastChangePartOfInlineEdit,\n\t\t\tinlineEditModelVersion,\n\t\t);\n\t}\n}\n\nfunction getStringEdit(textModel: ITextModel, editRange: Range, replaceText: string): StringEdit {\n\tconst eol = textModel.getEOL();\n\tconst editOriginalText = textModel.getValueInRange(editRange);\n\tconst editReplaceText = replaceText.replace(/\\r\\n|\\r|\\n/g, eol);\n\n\tconst diffAlgorithm = linesDiffComputers.getDefault();\n\tconst lineDiffs = diffAlgorithm.computeDiff(\n\t\tsplitLines(editOriginalText),\n\t\tsplitLines(editReplaceText),\n\t\t{\n\t\t\tignoreTrimWhitespace: false,\n\t\t\tcomputeMoves: false,\n\t\t\textendToSubwords: true,\n\t\t\tmaxComputationTimeMs: 500,\n\t\t}\n\t);\n\n\tconst innerChanges = lineDiffs.changes.flatMap(c => c.innerChanges ?? []);\n\n\tfunction addRangeToPos(pos: Position, range: Range): Range {\n\t\tconst start = TextLength.fromPosition(range.getStartPosition());\n\t\treturn TextLength.ofRange(range).createRange(start.addToPosition(pos));\n\t}\n\n\tconst modifiedText = new StringText(editReplaceText);\n\n\tconst offsetEdit = new StringEdit(\n\t\tinnerChanges.map(c => {\n\t\t\tconst rangeInModel = addRangeToPos(editRange.getStartPosition(), c.originalRange);\n\t\t\tconst originalRange = getPositionOffsetTransformerFromTextModel(textModel).getOffsetRange(rangeInModel);\n\n\t\t\tconst replaceText = modifiedText.getValueOfRange(c.modifiedRange);\n\t\t\tconst edit = new StringReplacement(originalRange, replaceText);\n\n\t\t\tconst originalText = textModel.getValueInRange(rangeInModel);\n\t\t\treturn reshapeInlineEdit(edit, originalText, innerChanges.length, textModel);\n\t\t})\n\t);\n\n\treturn offsetEdit;\n}\n\nclass SingleUpdatedNextEdit {\n\tpublic static create(\n\t\tedit: StringReplacement,\n\t\treplacedText: string,\n\t): SingleUpdatedNextEdit {\n\t\tconst prefixLength = commonPrefixLength(edit.newText, replacedText);\n\t\tconst suffixLength = commonSuffixLength(edit.newText, replacedText);\n\t\tconst trimmedNewText = edit.newText.substring(prefixLength, edit.newText.length - suffixLength);\n\t\treturn new SingleUpdatedNextEdit(edit, trimmedNewText, prefixLength, suffixLength);\n\t}\n\n\tpublic get edit() { return this._edit; }\n\tpublic get lastChangeUpdatedEdit() { return this._lastChangeUpdatedEdit; }\n\n\tconstructor(\n\t\tprivate _edit: StringReplacement | undefined,\n\t\tprivate _trimmedNewText: string,\n\t\tprivate _prefixLength: number,\n\t\tprivate _suffixLength: number,\n\t\tprivate _lastChangeUpdatedEdit: boolean = false,\n\t) {\n\t}\n\n\tpublic applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tconst c = this._clone();\n\t\tc._applyTextModelChanges(textModelChanges);\n\t\treturn c;\n\t}\n\n\tprivate _clone(): SingleUpdatedNextEdit {\n\t\treturn new SingleUpdatedNextEdit(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedNewText,\n\t\t\tthis._prefixLength,\n\t\t\tthis._suffixLength,\n\t\t\tthis._lastChangeUpdatedEdit,\n\t\t);\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tthis._lastChangeUpdatedEdit = false;\n\n\t\tif (!this._edit) {\n\t\t\tthrow new BugIndicatingError('UpdatedInnerEdits: No edit to apply changes to');\n\t\t}\n\n\t\tconst result = this._applyChanges(this._edit, textModelChanges);\n\t\tif (!result) {\n\t\t\tthis._edit = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._edit = result.edit;\n\t\tthis._lastChangeUpdatedEdit = result.editHasChanged;\n\t}\n\n\tprivate _applyChanges(edit: StringReplacement, textModelChanges: StringEdit): { edit: StringReplacement; editHasChanged: boolean } | undefined {\n\t\tlet editStart = edit.replaceRange.start;\n\t\tlet editEnd = edit.replaceRange.endExclusive;\n\t\tlet editReplaceText = edit.newText;\n\t\tlet editHasChanged = false;\n\n\t\tconst shouldPreserveEditShape = this._prefixLength > 0 || this._suffixLength > 0;\n\n\t\tfor (let i = textModelChanges.replacements.length - 1; i >= 0; i--) {\n\t\t\tconst change = textModelChanges.replacements[i];\n\n\t\t\t// INSERTIONS (only support inserting at start of edit)\n\t\t\tconst isInsertion = change.newText.length > 0 && change.replaceRange.isEmpty;\n\n\t\t\tif (isInsertion && !shouldPreserveEditShape && change.replaceRange.start === editStart && editReplaceText.startsWith(change.newText)) {\n\t\t\t\teditStart += change.newText.length;\n\t\t\t\teditReplaceText = editReplaceText.substring(change.newText.length);\n\t\t\t\teditEnd = Math.max(editStart, editEnd);\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isInsertion && shouldPreserveEditShape && change.replaceRange.start === editStart + this._prefixLength && this._trimmedNewText.startsWith(change.newText)) {\n\t\t\t\teditEnd += change.newText.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tthis._prefixLength += change.newText.length;\n\t\t\t\tthis._trimmedNewText = this._trimmedNewText.substring(change.newText.length);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// DELETIONS\n\t\t\tconst isDeletion = change.newText.length === 0 && change.replaceRange.length > 0;\n\t\t\tif (isDeletion && change.replaceRange.start >= editStart + this._prefixLength && change.replaceRange.endExclusive <= editEnd - this._suffixLength) {\n\t\t\t\t// user deleted text IN-BETWEEN the deletion range\n\t\t\t\teditEnd -= change.replaceRange.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// user did exactly the edit\n\t\t\tif (change.equals(edit)) {\n\t\t\t\teditHasChanged = true;\n\t\t\t\teditStart = change.replaceRange.endExclusive;\n\t\t\t\teditReplaceText = '';\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// MOVE EDIT\n\t\t\tif (change.replaceRange.start > editEnd) {\n\t\t\t\t// the change happens after the completion range\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (change.replaceRange.endExclusive < editStart) {\n\t\t\t\t// the change happens before the completion range\n\t\t\t\teditStart += change.newText.length - change.replaceRange.length;\n\t\t\t\teditEnd += change.newText.length - change.replaceRange.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// The change intersects the completion, so we will have to drop the completion\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// the resulting edit is a noop as the original and new text are the same\n\t\tif (this._trimmedNewText.length === 0 && editStart + this._prefixLength === editEnd - this._suffixLength) {\n\t\t\treturn { edit: new StringReplacement(new OffsetRange(editStart + this._prefixLength, editStart + this._prefixLength), ''), editHasChanged: true };\n\t\t}\n\n\t\treturn { edit: new StringReplacement(new OffsetRange(editStart, editEnd), editReplaceText), editHasChanged };\n\t}\n}\n\nfunction reshapeInlineCompletion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\t// If the insertion is a multi line insertion starting on the next line\n\t// Move it forwards so that the multi line insertion starts on the current line\n\tconst eol = textModel.getEOL();\n\tif (edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeInlineEdit(edit: StringReplacement, originalText: string, totalInnerEdits: number, textModel: ITextModel): StringReplacement {\n\t// TODO: EOL are not properly trimmed by the diffAlgorithm #12680\n\tconst eol = textModel.getEOL();\n\tif (edit.newText.endsWith(eol) && originalText.endsWith(eol)) {\n\t\tedit = new StringReplacement(edit.replaceRange.deltaEnd(-eol.length), edit.newText.slice(0, -eol.length));\n\t}\n\n\t// INSERTION\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (totalInnerEdits === 1 && edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\t\tconst hasTextOnInsertionLine = textModel.getLineLength(startPosition.lineNumber) !== 0;\n\t\tif (hasTextOnInsertionLine) {\n\t\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t\t}\n\t}\n\n\t// The diff algorithm extended a simple edit to the entire word\n\t// shrink it back to a simple edit if it is deletion/insertion only\n\tif (totalInnerEdits === 1) {\n\t\tconst prefixLength = commonPrefixLength(originalText, edit.newText);\n\t\tconst suffixLength = commonSuffixLength(originalText.slice(prefixLength), edit.newText.slice(prefixLength));\n\n\t\t// reshape it back to an insertion\n\t\tif (prefixLength + suffixLength === originalText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), edit.newText.substring(prefixLength, edit.newText.length - suffixLength));\n\t\t}\n\n\t\t// reshape it back to a deletion\n\t\tif (prefixLength + suffixLength === edit.newText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), '');\n\t\t}\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeMultiLineInsertion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\tif (!edit.replaceRange.isEmpty) {\n\t\tthrow new BugIndicatingError('Unexpected original range');\n\t}\n\n\tif (edit.replaceRange.start === 0) {\n\t\treturn edit;\n\t}\n\n\tconst eol = textModel.getEOL();\n\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\tconst startColumn = startPosition.column;\n\tconst startLineNumber = startPosition.lineNumber;\n\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (startColumn === 1 && startLineNumber > 1 && edit.newText.endsWith(eol) && !edit.newText.startsWith(eol)) {\n\t\treturn new StringReplacement(edit.replaceRange.delta(-1), eol + edit.newText.slice(0, -eol.length));\n\t}\n\n\treturn edit;\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 { BugIndicatingError } from '../../../../../base/common/errors.js';\nimport { matchesSubString } from '../../../../../base/common/filters.js';\nimport { observableSignal } from '../../../../../base/common/observable.js';\nimport { commonPrefixLength, commonSuffixLength, splitLines } from '../../../../../base/common/strings.js';\nimport { ICommandService } from '../../../../../platform/commands/common/commands.js';\nimport { ISingleEditOperation } from '../../../../common/core/editOperation.js';\nimport { applyEditsToRanges, StringEdit, StringReplacement } from '../../../../common/core/edits/stringEdit.js';\nimport { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { PositionOffsetTransformerBase } from '../../../../common/core/text/positionToOffset.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement, TextEdit } from '../../../../common/core/edits/textEdit.js';\nimport { StringText } from '../../../../common/core/text/abstractText.js';\nimport { TextLength } from '../../../../common/core/text/textLength.js';\nimport { linesDiffComputers } from '../../../../common/diff/linesDiffComputers.js';\nimport { InlineCompletion, InlineCompletionTriggerKind, Command, InlineCompletionWarning, PartialAcceptInfo, InlineCompletionEndOfLifeReason, InlineCompletionDisplayLocationKind } from '../../../../common/languages.js';\nimport { ITextModel, EndOfLinePreference } from '../../../../common/model.js';\nimport { TextModelText } from '../../../../common/model/textModelText.js';\nimport { IDisplayLocation, InlineSuggestData, InlineSuggestionList, PartialAcceptance, SnippetInfo } from './provideInlineCompletions.js';\nimport { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';\nimport { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';\n\nexport type InlineSuggestionItem = InlineEditItem | InlineCompletionItem;\n\nexport namespace InlineSuggestionItem {\n\texport function create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineSuggestionItem {\n\t\tif (!data.isInlineEdit) {\n\t\t\treturn InlineCompletionItem.create(data, textModel);\n\t\t} else {\n\t\t\treturn InlineEditItem.create(data, textModel);\n\t\t}\n\t}\n}\n\nabstract class InlineSuggestionItemBase {\n\tconstructor(\n\t\tprotected readonly _data: InlineSuggestData,\n\t\tpublic readonly identity: InlineSuggestionIdentity,\n\t\tpublic readonly displayLocation: InlineSuggestDisplayLocation | undefined\n\t) { }\n\n\t/**\n\t * A reference to the original inline completion list this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tpublic get source(): InlineSuggestionList { return this._data.source; }\n\n\tpublic get isFromExplicitRequest(): boolean { return this._data.context.triggerKind === InlineCompletionTriggerKind.Explicit; }\n\tpublic get forwardStable(): boolean { return this.source.inlineSuggestions.enableForwardStability ?? false; }\n\tpublic get editRange(): Range { return this.getSingleTextEdit().range; }\n\tpublic get targetRange(): Range { return this.displayLocation?.range ?? this.editRange; }\n\tpublic get insertText(): string { return this.getSingleTextEdit().text; }\n\tpublic get semanticId(): string { return this.hash; }\n\tpublic get action(): Command | undefined { return this._sourceInlineCompletion.action; }\n\tpublic get command(): Command | undefined { return this._sourceInlineCompletion.command; }\n\tpublic get warning(): InlineCompletionWarning | undefined { return this._sourceInlineCompletion.warning; }\n\tpublic get showInlineEditMenu(): boolean { return !!this._sourceInlineCompletion.showInlineEditMenu; }\n\tpublic get hash() {\n\t\treturn JSON.stringify([\n\t\t\tthis.getSingleTextEdit().text,\n\t\t\tthis.getSingleTextEdit().range.getStartPosition().toString()\n\t\t]);\n\t}\n\n\tpublic get requestUuid(): string { return this._data.context.requestUuid; }\n\n\tpublic get partialAccepts(): PartialAcceptance { return this._data.partialAccepts; }\n\n\t/**\n\t * A reference to the original inline completion this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tprivate get _sourceInlineCompletion(): InlineCompletion { return this._data.sourceInlineCompletion; }\n\n\n\tpublic abstract getSingleTextEdit(): TextReplacement;\n\n\tpublic abstract withEdit(userEdit: StringEdit, textModel: ITextModel): InlineSuggestionItem | undefined;\n\n\tpublic abstract withIdentity(identity: InlineSuggestionIdentity): InlineSuggestionItem;\n\tpublic abstract canBeReused(model: ITextModel, position: Position): boolean;\n\n\n\tpublic addRef(): void {\n\t\tthis.identity.addRef();\n\t\tthis.source.addRef();\n\t}\n\n\tpublic removeRef(): void {\n\t\tthis.identity.removeRef();\n\t\tthis.source.removeRef();\n\t}\n\n\tpublic reportInlineEditShown(commandService: ICommandService, viewKind: InlineCompletionViewKind, viewData: InlineCompletionViewData) {\n\t\tthis._data.reportInlineEditShown(commandService, this.insertText, viewKind, viewData);\n\t}\n\n\tpublic reportPartialAccept(acceptedCharacters: number, info: PartialAcceptInfo, partialAcceptance: PartialAcceptance) {\n\t\tthis._data.reportPartialAccept(acceptedCharacters, info, partialAcceptance);\n\t}\n\n\tpublic reportEndOfLife(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.reportEndOfLife(reason);\n\t}\n\n\tpublic setEndOfLifeReason(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.setEndOfLifeReason(reason);\n\t}\n\n\tpublic reportInlineEditError(reason: string): void {\n\t\tthis._data.reportInlineEditError(reason);\n\t}\n\n\tpublic setIsPreceeded(item: InlineSuggestionItem): void {\n\t\tthis._data.setIsPreceeded(item.partialAccepts);\n\t}\n\n\tpublic setNotShownReasonIfNotSet(reason: string): void {\n\t\tthis._data.setNotShownReason(reason);\n\t}\n\n\t/**\n\t * Avoid using this method. Instead introduce getters for the needed properties.\n\t*/\n\tpublic getSourceCompletion(): InlineCompletion {\n\t\treturn this._sourceInlineCompletion;\n\t}\n}\n\nexport class InlineSuggestionIdentity {\n\tprivate static idCounter = 0;\n\tprivate readonly _onDispose = observableSignal(this);\n\n\tprivate _refCount = 1;\n\tpublic readonly id = 'InlineCompletionIdentity' + InlineSuggestionIdentity.idCounter++;\n\n\taddRef() {\n\t\tthis._refCount++;\n\t}\n\n\tremoveRef() {\n\t\tthis._refCount--;\n\t\tif (this._refCount === 0) {\n\t\t\tthis._onDispose.trigger(undefined);\n\t\t}\n\t}\n}\n\nclass InlineSuggestDisplayLocation implements IDisplayLocation {\n\n\tpublic static create(displayLocation: IDisplayLocation) {\n\t\treturn new InlineSuggestDisplayLocation(\n\t\t\tdisplayLocation.range,\n\t\t\tdisplayLocation.label,\n\t\t\tdisplayLocation.kind\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly label: string,\n\t\tpublic readonly kind: InlineCompletionDisplayLocationKind\n\t) { }\n\n\tpublic withEdit(edit: StringEdit, positionOffsetTransformer: PositionOffsetTransformerBase): InlineSuggestDisplayLocation | undefined {\n\t\tconst offsetRange = new OffsetRange(\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getStartPosition()),\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getEndPosition())\n\t\t);\n\n\t\tconst newOffsetRange = applyEditsToRanges([offsetRange], edit)[0];\n\t\tif (!newOffsetRange) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst newRange = positionOffsetTransformer.getRange(newOffsetRange);\n\n\t\treturn new InlineSuggestDisplayLocation(newRange, this.label, this.kind);\n\t}\n}\n\nexport class InlineCompletionItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineCompletionItem {\n\t\tconst identity = new InlineSuggestionIdentity();\n\t\tconst transformer = getPositionOffsetTransformerFromTextModel(textModel);\n\n\t\tconst insertText = data.insertText.replace(/\\r\\n|\\r|\\n/g, textModel.getEOL());\n\n\t\tconst edit = reshapeInlineCompletion(new StringReplacement(transformer.getOffsetRange(data.range), insertText), textModel);\n\t\tconst trimmedEdit = edit.removeCommonSuffixAndPrefix(textModel.getValue());\n\t\tconst textEdit = transformer.getTextReplacement(edit);\n\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\n\t\treturn new InlineCompletionItem(edit, trimmedEdit, textEdit, textEdit.range, data.snippetInfo, data.additionalTextEdits, data, identity, displayLocation);\n\t}\n\n\tpublic readonly isInlineEdit = false;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringReplacement,\n\t\tprivate readonly _trimmedEdit: StringReplacement,\n\t\tprivate readonly _textEdit: TextReplacement,\n\t\tprivate readonly _originalRange: Range,\n\t\tpublic readonly snippetInfo: SnippetInfo | undefined,\n\t\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[],\n\n\t\tdata: InlineSuggestData,\n\t\tidentity: InlineSuggestionIdentity,\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\toverride get hash(): string {\n\t\treturn JSON.stringify(this._trimmedEdit.toJson());\n\t}\n\n\toverride getSingleTextEdit(): TextReplacement { return this._textEdit; }\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineCompletionItem {\n\t\treturn new InlineCompletionItem(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedEdit,\n\t\t\tthis._textEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis.displayLocation\n\t\t);\n\t}\n\n\toverride withEdit(textModelEdit: StringEdit, textModel: ITextModel): InlineCompletionItem | undefined {\n\t\tconst newEditRange = applyEditsToRanges([this._edit.replaceRange], textModelEdit);\n\t\tif (newEditRange.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst newEdit = new StringReplacement(newEditRange[0], this._textEdit.text);\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextReplacement(newEdit);\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelEdit, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst trimmedEdit = newEdit.removeCommonSuffixAndPrefix(textModel.getValue());\n\n\t\treturn new InlineCompletionItem(\n\t\t\tnewEdit,\n\t\t\ttrimmedEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tnewDisplayLocation\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\tconst updatedRange = this._textEdit.range;\n\t\tconst result = !!updatedRange\n\t\t\t&& updatedRange.containsPosition(position)\n\t\t\t&& this.isVisible(model, position)\n\t\t\t&& TextLength.ofRange(updatedRange).isGreaterThanOrEqualTo(TextLength.ofRange(this._originalRange));\n\t\treturn result;\n\t}\n\n\tpublic isVisible(model: ITextModel, cursorPosition: Position): boolean {\n\t\tconst singleTextEdit = this.getSingleTextEdit();\n\t\treturn inlineCompletionIsVisible(singleTextEdit, this._originalRange, model, cursorPosition);\n\t}\n}\n\nexport function inlineCompletionIsVisible(singleTextEdit: TextReplacement, originalRange: Range | undefined, model: ITextModel, cursorPosition: Position): boolean {\n\tconst minimizedReplacement = singleTextRemoveCommonPrefix(singleTextEdit, model);\n\tconst editRange = singleTextEdit.range;\n\tif (!editRange\n\t\t|| (originalRange && !originalRange.getStartPosition().equals(editRange.getStartPosition()))\n\t\t|| cursorPosition.lineNumber !== minimizedReplacement.range.startLineNumber\n\t\t|| minimizedReplacement.isEmpty // if the completion is empty after removing the common prefix of the completion and the model, the completion item would not be visible\n\t) {\n\t\treturn false;\n\t}\n\n\t// We might consider comparing by .toLowerText, but this requires GhostTextReplacement\n\tconst originalValue = model.getValueInRange(minimizedReplacement.range, EndOfLinePreference.LF);\n\tconst filterText = minimizedReplacement.text;\n\n\tconst cursorPosIndex = Math.max(0, cursorPosition.column - minimizedReplacement.range.startColumn);\n\n\tlet filterTextBefore = filterText.substring(0, cursorPosIndex);\n\tlet filterTextAfter = filterText.substring(cursorPosIndex);\n\n\tlet originalValueBefore = originalValue.substring(0, cursorPosIndex);\n\tlet originalValueAfter = originalValue.substring(cursorPosIndex);\n\n\tconst originalValueIndent = model.getLineIndentColumn(minimizedReplacement.range.startLineNumber);\n\tif (minimizedReplacement.range.startColumn <= originalValueIndent) {\n\t\t// Remove indentation\n\t\toriginalValueBefore = originalValueBefore.trimStart();\n\t\tif (originalValueBefore.length === 0) {\n\t\t\toriginalValueAfter = originalValueAfter.trimStart();\n\t\t}\n\t\tfilterTextBefore = filterTextBefore.trimStart();\n\t\tif (filterTextBefore.length === 0) {\n\t\t\tfilterTextAfter = filterTextAfter.trimStart();\n\t\t}\n\t}\n\n\treturn filterTextBefore.startsWith(originalValueBefore)\n\t\t&& !!matchesSubString(originalValueAfter, filterTextAfter);\n}\n\nexport class InlineEditItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineEditItem {\n\t\tconst offsetEdit = getStringEdit(textModel, data.range, data.insertText);\n\t\tconst text = new TextModelText(textModel);\n\t\tconst textEdit = TextEdit.fromStringEdit(offsetEdit, text);\n\t\tconst singleTextEdit = textEdit.toReplacement(text);\n\t\tconst identity = new InlineSuggestionIdentity();\n\n\t\tconst edits = offsetEdit.replacements.map(edit => {\n\t\t\tconst replacedRange = Range.fromPositions(textModel.getPositionAt(edit.replaceRange.start), textModel.getPositionAt(edit.replaceRange.endExclusive));\n\t\t\tconst replacedText = textModel.getValueInRange(replacedRange);\n\t\t\treturn SingleUpdatedNextEdit.create(edit, replacedText);\n\t\t});\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\t\treturn new InlineEditItem(offsetEdit, singleTextEdit, data, identity, edits, displayLocation, false, textModel.getVersionId());\n\t}\n\n\tpublic readonly snippetInfo: SnippetInfo | undefined = undefined;\n\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[] = [];\n\tpublic readonly isInlineEdit = true;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringEdit,\n\t\tprivate readonly _textEdit: TextReplacement,\n\n\t\tdata: InlineSuggestData,\n\n\t\tidentity: InlineSuggestionIdentity,\n\t\tprivate readonly _edits: readonly SingleUpdatedNextEdit[],\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t\tprivate readonly _lastChangePartOfInlineEdit = false,\n\t\tprivate readonly _inlineEditModelVersion: number,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\tpublic get updatedEditModelVersion(): number { return this._inlineEditModelVersion; }\n\tpublic get updatedEdit(): StringEdit { return this._edit; }\n\n\toverride getSingleTextEdit(): TextReplacement {\n\t\treturn this._textEdit;\n\t}\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineEditItem {\n\t\treturn new InlineEditItem(\n\t\t\tthis._edit,\n\t\t\tthis._textEdit,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis._edits,\n\t\t\tthis.displayLocation,\n\t\t\tthis._lastChangePartOfInlineEdit,\n\t\t\tthis._inlineEditModelVersion,\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\treturn this._lastChangePartOfInlineEdit && this.updatedEditModelVersion === model.getVersionId();\n\t}\n\n\toverride withEdit(textModelChanges: StringEdit, textModel: ITextModel): InlineEditItem | undefined {\n\t\tconst edit = this._applyTextModelChanges(textModelChanges, this._edits, textModel);\n\t\treturn edit;\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit, edits: readonly SingleUpdatedNextEdit[], textModel: ITextModel): InlineEditItem | undefined {\n\t\tedits = edits.map(innerEdit => innerEdit.applyTextModelChanges(textModelChanges));\n\n\t\tif (edits.some(edit => edit.edit === undefined)) {\n\t\t\treturn undefined; // change is invalid, so we will have to drop the completion\n\t\t}\n\n\t\tconst newTextModelVersion = textModel.getVersionId();\n\n\t\tlet inlineEditModelVersion = this._inlineEditModelVersion;\n\t\tconst lastChangePartOfInlineEdit = edits.some(edit => edit.lastChangeUpdatedEdit);\n\t\tif (lastChangePartOfInlineEdit) {\n\t\t\tinlineEditModelVersion = newTextModelVersion ?? -1;\n\t\t}\n\n\t\tif (newTextModelVersion === null || inlineEditModelVersion + 20 < newTextModelVersion) {\n\t\t\treturn undefined; // the completion has been ignored for a while, remove it\n\t\t}\n\n\t\tedits = edits.filter(innerEdit => !innerEdit.edit!.isEmpty);\n\t\tif (edits.length === 0) {\n\t\t\treturn undefined; // the completion has been typed by the user\n\t\t}\n\n\t\tconst newEdit = new StringEdit(edits.map(edit => edit.edit!));\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextEdit(newEdit).toReplacement(new TextModelText(textModel));\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelChanges, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn new InlineEditItem(\n\t\t\tnewEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tedits,\n\t\t\tnewDisplayLocation,\n\t\t\tlastChangePartOfInlineEdit,\n\t\t\tinlineEditModelVersion,\n\t\t);\n\t}\n}\n\nfunction getStringEdit(textModel: ITextModel, editRange: Range, replaceText: string): StringEdit {\n\tconst eol = textModel.getEOL();\n\tconst editOriginalText = textModel.getValueInRange(editRange);\n\tconst editReplaceText = replaceText.replace(/\\r\\n|\\r|\\n/g, eol);\n\n\tconst diffAlgorithm = linesDiffComputers.getDefault();\n\tconst lineDiffs = diffAlgorithm.computeDiff(\n\t\tsplitLines(editOriginalText),\n\t\tsplitLines(editReplaceText),\n\t\t{\n\t\t\tignoreTrimWhitespace: false,\n\t\t\tcomputeMoves: false,\n\t\t\textendToSubwords: true,\n\t\t\tmaxComputationTimeMs: 500,\n\t\t}\n\t);\n\n\tconst innerChanges = lineDiffs.changes.flatMap(c => c.innerChanges ?? []);\n\n\tfunction addRangeToPos(pos: Position, range: Range): Range {\n\t\tconst start = TextLength.fromPosition(range.getStartPosition());\n\t\treturn TextLength.ofRange(range).createRange(start.addToPosition(pos));\n\t}\n\n\tconst modifiedText = new StringText(editReplaceText);\n\n\tconst offsetEdit = new StringEdit(\n\t\tinnerChanges.map(c => {\n\t\t\tconst rangeInModel = addRangeToPos(editRange.getStartPosition(), c.originalRange);\n\t\t\tconst originalRange = getPositionOffsetTransformerFromTextModel(textModel).getOffsetRange(rangeInModel);\n\n\t\t\tconst replaceText = modifiedText.getValueOfRange(c.modifiedRange);\n\t\t\tconst edit = new StringReplacement(originalRange, replaceText);\n\n\t\t\tconst originalText = textModel.getValueInRange(rangeInModel);\n\t\t\treturn reshapeInlineEdit(edit, originalText, innerChanges.length, textModel);\n\t\t})\n\t);\n\n\treturn offsetEdit;\n}\n\nclass SingleUpdatedNextEdit {\n\tpublic static create(\n\t\tedit: StringReplacement,\n\t\treplacedText: string,\n\t): SingleUpdatedNextEdit {\n\t\tconst prefixLength = commonPrefixLength(edit.newText, replacedText);\n\t\tconst suffixLength = commonSuffixLength(edit.newText, replacedText);\n\t\tconst trimmedNewText = edit.newText.substring(prefixLength, edit.newText.length - suffixLength);\n\t\treturn new SingleUpdatedNextEdit(edit, trimmedNewText, prefixLength, suffixLength);\n\t}\n\n\tpublic get edit() { return this._edit; }\n\tpublic get lastChangeUpdatedEdit() { return this._lastChangeUpdatedEdit; }\n\n\tconstructor(\n\t\tprivate _edit: StringReplacement | undefined,\n\t\tprivate _trimmedNewText: string,\n\t\tprivate _prefixLength: number,\n\t\tprivate _suffixLength: number,\n\t\tprivate _lastChangeUpdatedEdit: boolean = false,\n\t) {\n\t}\n\n\tpublic applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tconst c = this._clone();\n\t\tc._applyTextModelChanges(textModelChanges);\n\t\treturn c;\n\t}\n\n\tprivate _clone(): SingleUpdatedNextEdit {\n\t\treturn new SingleUpdatedNextEdit(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedNewText,\n\t\t\tthis._prefixLength,\n\t\t\tthis._suffixLength,\n\t\t\tthis._lastChangeUpdatedEdit,\n\t\t);\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tthis._lastChangeUpdatedEdit = false;\n\n\t\tif (!this._edit) {\n\t\t\tthrow new BugIndicatingError('UpdatedInnerEdits: No edit to apply changes to');\n\t\t}\n\n\t\tconst result = this._applyChanges(this._edit, textModelChanges);\n\t\tif (!result) {\n\t\t\tthis._edit = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._edit = result.edit;\n\t\tthis._lastChangeUpdatedEdit = result.editHasChanged;\n\t}\n\n\tprivate _applyChanges(edit: StringReplacement, textModelChanges: StringEdit): { edit: StringReplacement; editHasChanged: boolean } | undefined {\n\t\tlet editStart = edit.replaceRange.start;\n\t\tlet editEnd = edit.replaceRange.endExclusive;\n\t\tlet editReplaceText = edit.newText;\n\t\tlet editHasChanged = false;\n\n\t\tconst shouldPreserveEditShape = this._prefixLength > 0 || this._suffixLength > 0;\n\n\t\tfor (let i = textModelChanges.replacements.length - 1; i >= 0; i--) {\n\t\t\tconst change = textModelChanges.replacements[i];\n\n\t\t\t// INSERTIONS (only support inserting at start of edit)\n\t\t\tconst isInsertion = change.newText.length > 0 && change.replaceRange.isEmpty;\n\n\t\t\tif (isInsertion && !shouldPreserveEditShape && change.replaceRange.start === editStart && editReplaceText.startsWith(change.newText)) {\n\t\t\t\teditStart += change.newText.length;\n\t\t\t\teditReplaceText = editReplaceText.substring(change.newText.length);\n\t\t\t\teditEnd = Math.max(editStart, editEnd);\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isInsertion && shouldPreserveEditShape && change.replaceRange.start === editStart + this._prefixLength && this._trimmedNewText.startsWith(change.newText)) {\n\t\t\t\teditEnd += change.newText.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tthis._prefixLength += change.newText.length;\n\t\t\t\tthis._trimmedNewText = this._trimmedNewText.substring(change.newText.length);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// DELETIONS\n\t\t\tconst isDeletion = change.newText.length === 0 && change.replaceRange.length > 0;\n\t\t\tif (isDeletion && change.replaceRange.start >= editStart + this._prefixLength && change.replaceRange.endExclusive <= editEnd - this._suffixLength) {\n\t\t\t\t// user deleted text IN-BETWEEN the deletion range\n\t\t\t\teditEnd -= change.replaceRange.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// user did exactly the edit\n\t\t\tif (change.equals(edit)) {\n\t\t\t\teditHasChanged = true;\n\t\t\t\teditStart = change.replaceRange.endExclusive;\n\t\t\t\teditReplaceText = '';\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// MOVE EDIT\n\t\t\tif (change.replaceRange.start > editEnd) {\n\t\t\t\t// the change happens after the completion range\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (change.replaceRange.endExclusive < editStart) {\n\t\t\t\t// the change happens before the completion range\n\t\t\t\teditStart += change.newText.length - change.replaceRange.length;\n\t\t\t\teditEnd += change.newText.length - change.replaceRange.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// The change intersects the completion, so we will have to drop the completion\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// the resulting edit is a noop as the original and new text are the same\n\t\tif (this._trimmedNewText.length === 0 && editStart + this._prefixLength === editEnd - this._suffixLength) {\n\t\t\treturn { edit: new StringReplacement(new OffsetRange(editStart + this._prefixLength, editStart + this._prefixLength), ''), editHasChanged: true };\n\t\t}\n\n\t\treturn { edit: new StringReplacement(new OffsetRange(editStart, editEnd), editReplaceText), editHasChanged };\n\t}\n}\n\nfunction reshapeInlineCompletion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\t// If the insertion is a multi line insertion starting on the next line\n\t// Move it forwards so that the multi line insertion starts on the current line\n\tconst eol = textModel.getEOL();\n\tif (edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeInlineEdit(edit: StringReplacement, originalText: string, totalInnerEdits: number, textModel: ITextModel): StringReplacement {\n\t// TODO: EOL are not properly trimmed by the diffAlgorithm #12680\n\tconst eol = textModel.getEOL();\n\tif (edit.newText.endsWith(eol) && originalText.endsWith(eol)) {\n\t\tedit = new StringReplacement(edit.replaceRange.deltaEnd(-eol.length), edit.newText.slice(0, -eol.length));\n\t}\n\n\t// INSERTION\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (totalInnerEdits === 1 && edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\t\tconst hasTextOnInsertionLine = textModel.getLineLength(startPosition.lineNumber) !== 0;\n\t\tif (hasTextOnInsertionLine) {\n\t\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t\t}\n\t}\n\n\t// The diff algorithm extended a simple edit to the entire word\n\t// shrink it back to a simple edit if it is deletion/insertion only\n\tif (totalInnerEdits === 1) {\n\t\tconst prefixLength = commonPrefixLength(originalText, edit.newText);\n\t\tconst suffixLength = commonSuffixLength(originalText.slice(prefixLength), edit.newText.slice(prefixLength));\n\n\t\t// reshape it back to an insertion\n\t\tif (prefixLength + suffixLength === originalText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), edit.newText.substring(prefixLength, edit.newText.length - suffixLength));\n\t\t}\n\n\t\t// reshape it back to a deletion\n\t\tif (prefixLength + suffixLength === edit.newText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), '');\n\t\t}\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeMultiLineInsertion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\tif (!edit.replaceRange.isEmpty) {\n\t\tthrow new BugIndicatingError('Unexpected original range');\n\t}\n\n\tif (edit.replaceRange.start === 0) {\n\t\treturn edit;\n\t}\n\n\tconst eol = textModel.getEOL();\n\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\tconst startColumn = startPosition.column;\n\tconst startLineNumber = startPosition.lineNumber;\n\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (startColumn === 1 && startLineNumber > 1 && edit.newText.endsWith(eol) && !edit.newText.startsWith(eol)) {\n\t\treturn new StringReplacement(edit.replaceRange.delta(-1), eol + edit.newText.slice(0, -eol.length));\n\t}\n\n\treturn edit;\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts","vs/editor/contrib/inlineCompletions/browser/model/inlineSuggestionItem.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAG3G,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,yCAAyC,EAAE,MAAM,2EAA2E,CAAC;AAEtI,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAmG,2BAA2B,EAA8C,MAAM,iCAAiC,CAAC;AAE3N,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAA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M,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC;IACzC,MAAM,eAAe,GAAG,aAAa,CAAC,UAAU,CAAC;IAEjD,+FAA+F;IAC/F,oEAAoE;IACpE,IAAI,WAAW,KAAK,CAAC,IAAI,eAAe,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","file":"inlineSuggestionItem.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 { BugIndicatingError } from '../../../../../base/common/errors.js';\nimport { matchesSubString } from '../../../../../base/common/filters.js';\nimport { observableSignal } from '../../../../../base/common/observable.js';\nimport { commonPrefixLength, commonSuffixLength, splitLines } from '../../../../../base/common/strings.js';\nimport { ICommandService } from '../../../../../platform/commands/common/commands.js';\nimport { ISingleEditOperation } from '../../../../common/core/editOperation.js';\nimport { applyEditsToRanges, StringEdit, StringReplacement } from '../../../../common/core/edits/stringEdit.js';\nimport { TextEdit, TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';\nimport { StringText } from '../../../../common/core/text/abstractText.js';\nimport { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';\nimport { PositionOffsetTransformerBase } from '../../../../common/core/text/positionToOffset.js';\nimport { TextLength } from '../../../../common/core/text/textLength.js';\nimport { linesDiffComputers } from '../../../../common/diff/linesDiffComputers.js';\nimport { Command, InlineCompletion, InlineCompletionDisplayLocationKind, InlineCompletionEndOfLifeReason, InlineCompletionTriggerKind, InlineCompletionWarning, PartialAcceptInfo } from '../../../../common/languages.js';\nimport { EndOfLinePreference, ITextModel } from '../../../../common/model.js';\nimport { TextModelText } from '../../../../common/model/textModelText.js';\nimport { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';\nimport { IDisplayLocation, InlineSuggestData, InlineSuggestionList, PartialAcceptance, SnippetInfo } from './provideInlineCompletions.js';\nimport { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\n\nexport type InlineSuggestionItem = InlineEditItem | InlineCompletionItem;\n\nexport namespace InlineSuggestionItem {\n\texport function create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineSuggestionItem {\n\t\tif (!data.isInlineEdit) {\n\t\t\treturn InlineCompletionItem.create(data, textModel);\n\t\t} else {\n\t\t\treturn InlineEditItem.create(data, textModel);\n\t\t}\n\t}\n}\n\nabstract class InlineSuggestionItemBase {\n\tconstructor(\n\t\tprotected readonly _data: InlineSuggestData,\n\t\tpublic readonly identity: InlineSuggestionIdentity,\n\t\tpublic readonly displayLocation: InlineSuggestDisplayLocation | undefined\n\t) { }\n\n\t/**\n\t * A reference to the original inline completion list this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tpublic get source(): InlineSuggestionList { return this._data.source; }\n\n\tpublic get isFromExplicitRequest(): boolean { return this._data.context.triggerKind === InlineCompletionTriggerKind.Explicit; }\n\tpublic get forwardStable(): boolean { return this.source.inlineSuggestions.enableForwardStability ?? false; }\n\tpublic get editRange(): Range { return this.getSingleTextEdit().range; }\n\tpublic get targetRange(): Range { return this.displayLocation?.range ?? this.editRange; }\n\tpublic get insertText(): string { return this.getSingleTextEdit().text; }\n\tpublic get semanticId(): string { return this.hash; }\n\tpublic get action(): Command | undefined { return this._sourceInlineCompletion.action; }\n\tpublic get command(): Command | undefined { return this._sourceInlineCompletion.command; }\n\tpublic get warning(): InlineCompletionWarning | undefined { return this._sourceInlineCompletion.warning; }\n\tpublic get showInlineEditMenu(): boolean { return !!this._sourceInlineCompletion.showInlineEditMenu; }\n\tpublic get hash() {\n\t\treturn JSON.stringify([\n\t\t\tthis.getSingleTextEdit().text,\n\t\t\tthis.getSingleTextEdit().range.getStartPosition().toString()\n\t\t]);\n\t}\n\n\tpublic get requestUuid(): string { return this._data.context.requestUuid; }\n\n\tpublic get partialAccepts(): PartialAcceptance { return this._data.partialAccepts; }\n\n\t/**\n\t * A reference to the original inline completion this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tprivate get _sourceInlineCompletion(): InlineCompletion { return this._data.sourceInlineCompletion; }\n\n\n\tpublic abstract getSingleTextEdit(): TextReplacement;\n\n\tpublic abstract withEdit(userEdit: StringEdit, textModel: ITextModel): InlineSuggestionItem | undefined;\n\n\tpublic abstract withIdentity(identity: InlineSuggestionIdentity): InlineSuggestionItem;\n\tpublic abstract canBeReused(model: ITextModel, position: Position): boolean;\n\n\n\tpublic addRef(): void {\n\t\tthis.identity.addRef();\n\t\tthis.source.addRef();\n\t}\n\n\tpublic removeRef(): void {\n\t\tthis.identity.removeRef();\n\t\tthis.source.removeRef();\n\t}\n\n\tpublic reportInlineEditShown(commandService: ICommandService, viewKind: InlineCompletionViewKind, viewData: InlineCompletionViewData) {\n\t\tthis._data.reportInlineEditShown(commandService, this.insertText, viewKind, viewData);\n\t}\n\n\tpublic reportPartialAccept(acceptedCharacters: number, info: PartialAcceptInfo, partialAcceptance: PartialAcceptance) {\n\t\tthis._data.reportPartialAccept(acceptedCharacters, info, partialAcceptance);\n\t}\n\n\tpublic reportEndOfLife(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.reportEndOfLife(reason);\n\t}\n\n\tpublic setEndOfLifeReason(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.setEndOfLifeReason(reason);\n\t}\n\n\tpublic reportInlineEditError(reason: string): void {\n\t\tthis._data.reportInlineEditError(reason);\n\t}\n\n\tpublic setIsPreceeded(item: InlineSuggestionItem): void {\n\t\tthis._data.setIsPreceeded(item.partialAccepts);\n\t}\n\n\tpublic setNotShownReasonIfNotSet(reason: string): void {\n\t\tthis._data.setNotShownReason(reason);\n\t}\n\n\t/**\n\t * Avoid using this method. Instead introduce getters for the needed properties.\n\t*/\n\tpublic getSourceCompletion(): InlineCompletion {\n\t\treturn this._sourceInlineCompletion;\n\t}\n}\n\nexport class InlineSuggestionIdentity {\n\tprivate static idCounter = 0;\n\tprivate readonly _onDispose = observableSignal(this);\n\n\tprivate _refCount = 1;\n\tpublic readonly id = 'InlineCompletionIdentity' + InlineSuggestionIdentity.idCounter++;\n\n\taddRef() {\n\t\tthis._refCount++;\n\t}\n\n\tremoveRef() {\n\t\tthis._refCount--;\n\t\tif (this._refCount === 0) {\n\t\t\tthis._onDispose.trigger(undefined);\n\t\t}\n\t}\n}\n\nclass InlineSuggestDisplayLocation implements IDisplayLocation {\n\n\tpublic static create(displayLocation: IDisplayLocation) {\n\t\treturn new InlineSuggestDisplayLocation(\n\t\t\tdisplayLocation.range,\n\t\t\tdisplayLocation.label,\n\t\t\tdisplayLocation.kind\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly label: string,\n\t\tpublic readonly kind: InlineCompletionDisplayLocationKind\n\t) { }\n\n\tpublic withEdit(edit: StringEdit, positionOffsetTransformer: PositionOffsetTransformerBase): InlineSuggestDisplayLocation | undefined {\n\t\tconst offsetRange = new OffsetRange(\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getStartPosition()),\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getEndPosition())\n\t\t);\n\n\t\tconst newOffsetRange = applyEditsToRanges([offsetRange], edit)[0];\n\t\tif (!newOffsetRange) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst newRange = positionOffsetTransformer.getRange(newOffsetRange);\n\n\t\treturn new InlineSuggestDisplayLocation(newRange, this.label, this.kind);\n\t}\n}\n\nexport class InlineCompletionItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineCompletionItem {\n\t\tconst identity = new InlineSuggestionIdentity();\n\t\tconst transformer = getPositionOffsetTransformerFromTextModel(textModel);\n\n\t\tconst insertText = data.insertText.replace(/\\r\\n|\\r|\\n/g, textModel.getEOL());\n\n\t\tconst edit = reshapeInlineCompletion(new StringReplacement(transformer.getOffsetRange(data.range), insertText), textModel);\n\t\tconst trimmedEdit = edit.removeCommonSuffixAndPrefix(textModel.getValue());\n\t\tconst textEdit = transformer.getTextReplacement(edit);\n\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\n\t\treturn new InlineCompletionItem(edit, trimmedEdit, textEdit, textEdit.range, data.snippetInfo, data.additionalTextEdits, data, identity, displayLocation);\n\t}\n\n\tpublic readonly isInlineEdit = false;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringReplacement,\n\t\tprivate readonly _trimmedEdit: StringReplacement,\n\t\tprivate readonly _textEdit: TextReplacement,\n\t\tprivate readonly _originalRange: Range,\n\t\tpublic readonly snippetInfo: SnippetInfo | undefined,\n\t\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[],\n\n\t\tdata: InlineSuggestData,\n\t\tidentity: InlineSuggestionIdentity,\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\toverride get hash(): string {\n\t\treturn JSON.stringify(this._trimmedEdit.toJson());\n\t}\n\n\toverride getSingleTextEdit(): TextReplacement { return this._textEdit; }\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineCompletionItem {\n\t\treturn new InlineCompletionItem(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedEdit,\n\t\t\tthis._textEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis.displayLocation\n\t\t);\n\t}\n\n\toverride withEdit(textModelEdit: StringEdit, textModel: ITextModel): InlineCompletionItem | undefined {\n\t\tconst newEditRange = applyEditsToRanges([this._edit.replaceRange], textModelEdit);\n\t\tif (newEditRange.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst newEdit = new StringReplacement(newEditRange[0], this._textEdit.text);\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextReplacement(newEdit);\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelEdit, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst trimmedEdit = newEdit.removeCommonSuffixAndPrefix(textModel.getValue());\n\n\t\treturn new InlineCompletionItem(\n\t\t\tnewEdit,\n\t\t\ttrimmedEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tnewDisplayLocation\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\tconst updatedRange = this._textEdit.range;\n\t\tconst result = !!updatedRange\n\t\t\t&& updatedRange.containsPosition(position)\n\t\t\t&& this.isVisible(model, position)\n\t\t\t&& TextLength.ofRange(updatedRange).isGreaterThanOrEqualTo(TextLength.ofRange(this._originalRange));\n\t\treturn result;\n\t}\n\n\tpublic isVisible(model: ITextModel, cursorPosition: Position): boolean {\n\t\tconst singleTextEdit = this.getSingleTextEdit();\n\t\treturn inlineCompletionIsVisible(singleTextEdit, this._originalRange, model, cursorPosition);\n\t}\n}\n\nexport function inlineCompletionIsVisible(singleTextEdit: TextReplacement, originalRange: Range | undefined, model: ITextModel, cursorPosition: Position): boolean {\n\tconst minimizedReplacement = singleTextRemoveCommonPrefix(singleTextEdit, model);\n\tconst editRange = singleTextEdit.range;\n\tif (!editRange\n\t\t|| (originalRange && !originalRange.getStartPosition().equals(editRange.getStartPosition()))\n\t\t|| cursorPosition.lineNumber !== minimizedReplacement.range.startLineNumber\n\t\t|| minimizedReplacement.isEmpty // if the completion is empty after removing the common prefix of the completion and the model, the completion item would not be visible\n\t) {\n\t\treturn false;\n\t}\n\n\t// We might consider comparing by .toLowerText, but this requires GhostTextReplacement\n\tconst originalValue = model.getValueInRange(minimizedReplacement.range, EndOfLinePreference.LF);\n\tconst filterText = minimizedReplacement.text;\n\n\tconst cursorPosIndex = Math.max(0, cursorPosition.column - minimizedReplacement.range.startColumn);\n\n\tlet filterTextBefore = filterText.substring(0, cursorPosIndex);\n\tlet filterTextAfter = filterText.substring(cursorPosIndex);\n\n\tlet originalValueBefore = originalValue.substring(0, cursorPosIndex);\n\tlet originalValueAfter = originalValue.substring(cursorPosIndex);\n\n\tconst originalValueIndent = model.getLineIndentColumn(minimizedReplacement.range.startLineNumber);\n\tif (minimizedReplacement.range.startColumn <= originalValueIndent) {\n\t\t// Remove indentation\n\t\toriginalValueBefore = originalValueBefore.trimStart();\n\t\tif (originalValueBefore.length === 0) {\n\t\t\toriginalValueAfter = originalValueAfter.trimStart();\n\t\t}\n\t\tfilterTextBefore = filterTextBefore.trimStart();\n\t\tif (filterTextBefore.length === 0) {\n\t\t\tfilterTextAfter = filterTextAfter.trimStart();\n\t\t}\n\t}\n\n\treturn filterTextBefore.startsWith(originalValueBefore)\n\t\t&& !!matchesSubString(originalValueAfter, filterTextAfter);\n}\n\nexport class InlineEditItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineEditItem {\n\t\tconst offsetEdit = getStringEdit(textModel, data.range, data.insertText);\n\t\tconst text = new TextModelText(textModel);\n\t\tconst textEdit = TextEdit.fromStringEdit(offsetEdit, text);\n\t\tconst singleTextEdit = offsetEdit.isEmpty() ? new TextReplacement(new Range(1, 1, 1, 1), '') : textEdit.toReplacement(text); // FIXME: .toReplacement() can throw because offsetEdit is empty because we get an empty diff in getStringEdit after diffing\n\t\tconst identity = new InlineSuggestionIdentity();\n\n\t\tconst edits = offsetEdit.replacements.map(edit => {\n\t\t\tconst replacedRange = Range.fromPositions(textModel.getPositionAt(edit.replaceRange.start), textModel.getPositionAt(edit.replaceRange.endExclusive));\n\t\t\tconst replacedText = textModel.getValueInRange(replacedRange);\n\t\t\treturn SingleUpdatedNextEdit.create(edit, replacedText);\n\t\t});\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\t\treturn new InlineEditItem(offsetEdit, singleTextEdit, data, identity, edits, displayLocation, false, textModel.getVersionId());\n\t}\n\n\tpublic readonly snippetInfo: SnippetInfo | undefined = undefined;\n\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[] = [];\n\tpublic readonly isInlineEdit = true;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringEdit,\n\t\tprivate readonly _textEdit: TextReplacement,\n\n\t\tdata: InlineSuggestData,\n\n\t\tidentity: InlineSuggestionIdentity,\n\t\tprivate readonly _edits: readonly SingleUpdatedNextEdit[],\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t\tprivate readonly _lastChangePartOfInlineEdit = false,\n\t\tprivate readonly _inlineEditModelVersion: number,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\tpublic get updatedEditModelVersion(): number { return this._inlineEditModelVersion; }\n\tpublic get updatedEdit(): StringEdit { return this._edit; }\n\n\toverride getSingleTextEdit(): TextReplacement {\n\t\treturn this._textEdit;\n\t}\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineEditItem {\n\t\treturn new InlineEditItem(\n\t\t\tthis._edit,\n\t\t\tthis._textEdit,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis._edits,\n\t\t\tthis.displayLocation,\n\t\t\tthis._lastChangePartOfInlineEdit,\n\t\t\tthis._inlineEditModelVersion,\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\treturn this._lastChangePartOfInlineEdit && this.updatedEditModelVersion === model.getVersionId();\n\t}\n\n\toverride withEdit(textModelChanges: StringEdit, textModel: ITextModel): InlineEditItem | undefined {\n\t\tconst edit = this._applyTextModelChanges(textModelChanges, this._edits, textModel);\n\t\treturn edit;\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit, edits: readonly SingleUpdatedNextEdit[], textModel: ITextModel): InlineEditItem | undefined {\n\t\tedits = edits.map(innerEdit => innerEdit.applyTextModelChanges(textModelChanges));\n\n\t\tif (edits.some(edit => edit.edit === undefined)) {\n\t\t\treturn undefined; // change is invalid, so we will have to drop the completion\n\t\t}\n\n\t\tconst newTextModelVersion = textModel.getVersionId();\n\n\t\tlet inlineEditModelVersion = this._inlineEditModelVersion;\n\t\tconst lastChangePartOfInlineEdit = edits.some(edit => edit.lastChangeUpdatedEdit);\n\t\tif (lastChangePartOfInlineEdit) {\n\t\t\tinlineEditModelVersion = newTextModelVersion ?? -1;\n\t\t}\n\n\t\tif (newTextModelVersion === null || inlineEditModelVersion + 20 < newTextModelVersion) {\n\t\t\treturn undefined; // the completion has been ignored for a while, remove it\n\t\t}\n\n\t\tedits = edits.filter(innerEdit => !innerEdit.edit!.isEmpty);\n\t\tif (edits.length === 0) {\n\t\t\treturn undefined; // the completion has been typed by the user\n\t\t}\n\n\t\tconst newEdit = new StringEdit(edits.map(edit => edit.edit!));\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextEdit(newEdit).toReplacement(new TextModelText(textModel));\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelChanges, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn new InlineEditItem(\n\t\t\tnewEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tedits,\n\t\t\tnewDisplayLocation,\n\t\t\tlastChangePartOfInlineEdit,\n\t\t\tinlineEditModelVersion,\n\t\t);\n\t}\n}\n\nfunction getStringEdit(textModel: ITextModel, editRange: Range, replaceText: string): StringEdit {\n\tconst eol = textModel.getEOL();\n\tconst editOriginalText = textModel.getValueInRange(editRange);\n\tconst editReplaceText = replaceText.replace(/\\r\\n|\\r|\\n/g, eol);\n\n\tconst diffAlgorithm = linesDiffComputers.getDefault();\n\tconst lineDiffs = diffAlgorithm.computeDiff(\n\t\tsplitLines(editOriginalText),\n\t\tsplitLines(editReplaceText),\n\t\t{\n\t\t\tignoreTrimWhitespace: false,\n\t\t\tcomputeMoves: false,\n\t\t\textendToSubwords: true,\n\t\t\tmaxComputationTimeMs: 500,\n\t\t}\n\t);\n\n\tconst innerChanges = lineDiffs.changes.flatMap(c => c.innerChanges ?? []);\n\n\tfunction addRangeToPos(pos: Position, range: Range): Range {\n\t\tconst start = TextLength.fromPosition(range.getStartPosition());\n\t\treturn TextLength.ofRange(range).createRange(start.addToPosition(pos));\n\t}\n\n\tconst modifiedText = new StringText(editReplaceText);\n\n\tconst offsetEdit = new StringEdit(\n\t\tinnerChanges.map(c => {\n\t\t\tconst rangeInModel = addRangeToPos(editRange.getStartPosition(), c.originalRange);\n\t\t\tconst originalRange = getPositionOffsetTransformerFromTextModel(textModel).getOffsetRange(rangeInModel);\n\n\t\t\tconst replaceText = modifiedText.getValueOfRange(c.modifiedRange);\n\t\t\tconst edit = new StringReplacement(originalRange, replaceText);\n\n\t\t\tconst originalText = textModel.getValueInRange(rangeInModel);\n\t\t\treturn reshapeInlineEdit(edit, originalText, innerChanges.length, textModel);\n\t\t})\n\t);\n\n\treturn offsetEdit;\n}\n\nclass SingleUpdatedNextEdit {\n\tpublic static create(\n\t\tedit: StringReplacement,\n\t\treplacedText: string,\n\t): SingleUpdatedNextEdit {\n\t\tconst prefixLength = commonPrefixLength(edit.newText, replacedText);\n\t\tconst suffixLength = commonSuffixLength(edit.newText, replacedText);\n\t\tconst trimmedNewText = edit.newText.substring(prefixLength, edit.newText.length - suffixLength);\n\t\treturn new SingleUpdatedNextEdit(edit, trimmedNewText, prefixLength, suffixLength);\n\t}\n\n\tpublic get edit() { return this._edit; }\n\tpublic get lastChangeUpdatedEdit() { return this._lastChangeUpdatedEdit; }\n\n\tconstructor(\n\t\tprivate _edit: StringReplacement | undefined,\n\t\tprivate _trimmedNewText: string,\n\t\tprivate _prefixLength: number,\n\t\tprivate _suffixLength: number,\n\t\tprivate _lastChangeUpdatedEdit: boolean = false,\n\t) {\n\t}\n\n\tpublic applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tconst c = this._clone();\n\t\tc._applyTextModelChanges(textModelChanges);\n\t\treturn c;\n\t}\n\n\tprivate _clone(): SingleUpdatedNextEdit {\n\t\treturn new SingleUpdatedNextEdit(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedNewText,\n\t\t\tthis._prefixLength,\n\t\t\tthis._suffixLength,\n\t\t\tthis._lastChangeUpdatedEdit,\n\t\t);\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tthis._lastChangeUpdatedEdit = false;\n\n\t\tif (!this._edit) {\n\t\t\tthrow new BugIndicatingError('UpdatedInnerEdits: No edit to apply changes to');\n\t\t}\n\n\t\tconst result = this._applyChanges(this._edit, textModelChanges);\n\t\tif (!result) {\n\t\t\tthis._edit = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._edit = result.edit;\n\t\tthis._lastChangeUpdatedEdit = result.editHasChanged;\n\t}\n\n\tprivate _applyChanges(edit: StringReplacement, textModelChanges: StringEdit): { edit: StringReplacement; editHasChanged: boolean } | undefined {\n\t\tlet editStart = edit.replaceRange.start;\n\t\tlet editEnd = edit.replaceRange.endExclusive;\n\t\tlet editReplaceText = edit.newText;\n\t\tlet editHasChanged = false;\n\n\t\tconst shouldPreserveEditShape = this._prefixLength > 0 || this._suffixLength > 0;\n\n\t\tfor (let i = textModelChanges.replacements.length - 1; i >= 0; i--) {\n\t\t\tconst change = textModelChanges.replacements[i];\n\n\t\t\t// INSERTIONS (only support inserting at start of edit)\n\t\t\tconst isInsertion = change.newText.length > 0 && change.replaceRange.isEmpty;\n\n\t\t\tif (isInsertion && !shouldPreserveEditShape && change.replaceRange.start === editStart && editReplaceText.startsWith(change.newText)) {\n\t\t\t\teditStart += change.newText.length;\n\t\t\t\teditReplaceText = editReplaceText.substring(change.newText.length);\n\t\t\t\teditEnd = Math.max(editStart, editEnd);\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isInsertion && shouldPreserveEditShape && change.replaceRange.start === editStart + this._prefixLength && this._trimmedNewText.startsWith(change.newText)) {\n\t\t\t\teditEnd += change.newText.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tthis._prefixLength += change.newText.length;\n\t\t\t\tthis._trimmedNewText = this._trimmedNewText.substring(change.newText.length);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// DELETIONS\n\t\t\tconst isDeletion = change.newText.length === 0 && change.replaceRange.length > 0;\n\t\t\tif (isDeletion && change.replaceRange.start >= editStart + this._prefixLength && change.replaceRange.endExclusive <= editEnd - this._suffixLength) {\n\t\t\t\t// user deleted text IN-BETWEEN the deletion range\n\t\t\t\teditEnd -= change.replaceRange.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// user did exactly the edit\n\t\t\tif (change.equals(edit)) {\n\t\t\t\teditHasChanged = true;\n\t\t\t\teditStart = change.replaceRange.endExclusive;\n\t\t\t\teditReplaceText = '';\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// MOVE EDIT\n\t\t\tif (change.replaceRange.start > editEnd) {\n\t\t\t\t// the change happens after the completion range\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (change.replaceRange.endExclusive < editStart) {\n\t\t\t\t// the change happens before the completion range\n\t\t\t\teditStart += change.newText.length - change.replaceRange.length;\n\t\t\t\teditEnd += change.newText.length - change.replaceRange.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// The change intersects the completion, so we will have to drop the completion\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// the resulting edit is a noop as the original and new text are the same\n\t\tif (this._trimmedNewText.length === 0 && editStart + this._prefixLength === editEnd - this._suffixLength) {\n\t\t\treturn { edit: new StringReplacement(new OffsetRange(editStart + this._prefixLength, editStart + this._prefixLength), ''), editHasChanged: true };\n\t\t}\n\n\t\treturn { edit: new StringReplacement(new OffsetRange(editStart, editEnd), editReplaceText), editHasChanged };\n\t}\n}\n\nfunction reshapeInlineCompletion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\t// If the insertion is a multi line insertion starting on the next line\n\t// Move it forwards so that the multi line insertion starts on the current line\n\tconst eol = textModel.getEOL();\n\tif (edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeInlineEdit(edit: StringReplacement, originalText: string, totalInnerEdits: number, textModel: ITextModel): StringReplacement {\n\t// TODO: EOL are not properly trimmed by the diffAlgorithm #12680\n\tconst eol = textModel.getEOL();\n\tif (edit.newText.endsWith(eol) && originalText.endsWith(eol)) {\n\t\tedit = new StringReplacement(edit.replaceRange.deltaEnd(-eol.length), edit.newText.slice(0, -eol.length));\n\t}\n\n\t// INSERTION\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (totalInnerEdits === 1 && edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\t\tconst hasTextOnInsertionLine = textModel.getLineLength(startPosition.lineNumber) !== 0;\n\t\tif (hasTextOnInsertionLine) {\n\t\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t\t}\n\t}\n\n\t// The diff algorithm extended a simple edit to the entire word\n\t// shrink it back to a simple edit if it is deletion/insertion only\n\tif (totalInnerEdits === 1) {\n\t\tconst prefixLength = commonPrefixLength(originalText, edit.newText);\n\t\tconst suffixLength = commonSuffixLength(originalText.slice(prefixLength), edit.newText.slice(prefixLength));\n\n\t\t// reshape it back to an insertion\n\t\tif (prefixLength + suffixLength === originalText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), edit.newText.substring(prefixLength, edit.newText.length - suffixLength));\n\t\t}\n\n\t\t// reshape it back to a deletion\n\t\tif (prefixLength + suffixLength === edit.newText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), '');\n\t\t}\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeMultiLineInsertion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\tif (!edit.replaceRange.isEmpty) {\n\t\tthrow new BugIndicatingError('Unexpected original range');\n\t}\n\n\tif (edit.replaceRange.start === 0) {\n\t\treturn edit;\n\t}\n\n\tconst eol = textModel.getEOL();\n\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\tconst startColumn = startPosition.column;\n\tconst startLineNumber = startPosition.lineNumber;\n\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (startColumn === 1 && startLineNumber > 1 && edit.newText.endsWith(eol) && !edit.newText.startsWith(eol)) {\n\t\treturn new StringReplacement(edit.replaceRange.delta(-1), eol + edit.newText.slice(0, -eol.length));\n\t}\n\n\treturn edit;\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 { BugIndicatingError } from '../../../../../base/common/errors.js';\nimport { matchesSubString } from '../../../../../base/common/filters.js';\nimport { observableSignal } from '../../../../../base/common/observable.js';\nimport { commonPrefixLength, commonSuffixLength, splitLines } from '../../../../../base/common/strings.js';\nimport { ICommandService } from '../../../../../platform/commands/common/commands.js';\nimport { ISingleEditOperation } from '../../../../common/core/editOperation.js';\nimport { applyEditsToRanges, StringEdit, StringReplacement } from '../../../../common/core/edits/stringEdit.js';\nimport { TextEdit, TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { OffsetRange } from '../../../../common/core/ranges/offsetRange.js';\nimport { StringText } from '../../../../common/core/text/abstractText.js';\nimport { getPositionOffsetTransformerFromTextModel } from '../../../../common/core/text/getPositionOffsetTransformerFromTextModel.js';\nimport { PositionOffsetTransformerBase } from '../../../../common/core/text/positionToOffset.js';\nimport { TextLength } from '../../../../common/core/text/textLength.js';\nimport { linesDiffComputers } from '../../../../common/diff/linesDiffComputers.js';\nimport { Command, InlineCompletion, InlineCompletionDisplayLocationKind, InlineCompletionEndOfLifeReason, InlineCompletionTriggerKind, InlineCompletionWarning, PartialAcceptInfo } from '../../../../common/languages.js';\nimport { EndOfLinePreference, ITextModel } from '../../../../common/model.js';\nimport { TextModelText } from '../../../../common/model/textModelText.js';\nimport { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';\nimport { IDisplayLocation, InlineSuggestData, InlineSuggestionList, PartialAcceptance, SnippetInfo } from './provideInlineCompletions.js';\nimport { singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\n\nexport type InlineSuggestionItem = InlineEditItem | InlineCompletionItem;\n\nexport namespace InlineSuggestionItem {\n\texport function create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineSuggestionItem {\n\t\tif (!data.isInlineEdit) {\n\t\t\treturn InlineCompletionItem.create(data, textModel);\n\t\t} else {\n\t\t\treturn InlineEditItem.create(data, textModel);\n\t\t}\n\t}\n}\n\nabstract class InlineSuggestionItemBase {\n\tconstructor(\n\t\tprotected readonly _data: InlineSuggestData,\n\t\tpublic readonly identity: InlineSuggestionIdentity,\n\t\tpublic readonly displayLocation: InlineSuggestDisplayLocation | undefined\n\t) { }\n\n\t/**\n\t * A reference to the original inline completion list this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tpublic get source(): InlineSuggestionList { return this._data.source; }\n\n\tpublic get isFromExplicitRequest(): boolean { return this._data.context.triggerKind === InlineCompletionTriggerKind.Explicit; }\n\tpublic get forwardStable(): boolean { return this.source.inlineSuggestions.enableForwardStability ?? false; }\n\tpublic get editRange(): Range { return this.getSingleTextEdit().range; }\n\tpublic get targetRange(): Range { return this.displayLocation?.range ?? this.editRange; }\n\tpublic get insertText(): string { return this.getSingleTextEdit().text; }\n\tpublic get semanticId(): string { return this.hash; }\n\tpublic get action(): Command | undefined { return this._sourceInlineCompletion.action; }\n\tpublic get command(): Command | undefined { return this._sourceInlineCompletion.command; }\n\tpublic get warning(): InlineCompletionWarning | undefined { return this._sourceInlineCompletion.warning; }\n\tpublic get showInlineEditMenu(): boolean { return !!this._sourceInlineCompletion.showInlineEditMenu; }\n\tpublic get hash() {\n\t\treturn JSON.stringify([\n\t\t\tthis.getSingleTextEdit().text,\n\t\t\tthis.getSingleTextEdit().range.getStartPosition().toString()\n\t\t]);\n\t}\n\n\tpublic get requestUuid(): string { return this._data.context.requestUuid; }\n\n\tpublic get partialAccepts(): PartialAcceptance { return this._data.partialAccepts; }\n\n\t/**\n\t * A reference to the original inline completion this inline completion has been constructed from.\n\t * Used for event data to ensure referential equality.\n\t*/\n\tprivate get _sourceInlineCompletion(): InlineCompletion { return this._data.sourceInlineCompletion; }\n\n\n\tpublic abstract getSingleTextEdit(): TextReplacement;\n\n\tpublic abstract withEdit(userEdit: StringEdit, textModel: ITextModel): InlineSuggestionItem | undefined;\n\n\tpublic abstract withIdentity(identity: InlineSuggestionIdentity): InlineSuggestionItem;\n\tpublic abstract canBeReused(model: ITextModel, position: Position): boolean;\n\n\n\tpublic addRef(): void {\n\t\tthis.identity.addRef();\n\t\tthis.source.addRef();\n\t}\n\n\tpublic removeRef(): void {\n\t\tthis.identity.removeRef();\n\t\tthis.source.removeRef();\n\t}\n\n\tpublic reportInlineEditShown(commandService: ICommandService, viewKind: InlineCompletionViewKind, viewData: InlineCompletionViewData) {\n\t\tthis._data.reportInlineEditShown(commandService, this.insertText, viewKind, viewData);\n\t}\n\n\tpublic reportPartialAccept(acceptedCharacters: number, info: PartialAcceptInfo, partialAcceptance: PartialAcceptance) {\n\t\tthis._data.reportPartialAccept(acceptedCharacters, info, partialAcceptance);\n\t}\n\n\tpublic reportEndOfLife(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.reportEndOfLife(reason);\n\t}\n\n\tpublic setEndOfLifeReason(reason: InlineCompletionEndOfLifeReason): void {\n\t\tthis._data.setEndOfLifeReason(reason);\n\t}\n\n\tpublic reportInlineEditError(reason: string): void {\n\t\tthis._data.reportInlineEditError(reason);\n\t}\n\n\tpublic setIsPreceeded(item: InlineSuggestionItem): void {\n\t\tthis._data.setIsPreceeded(item.partialAccepts);\n\t}\n\n\tpublic setNotShownReasonIfNotSet(reason: string): void {\n\t\tthis._data.setNotShownReason(reason);\n\t}\n\n\t/**\n\t * Avoid using this method. Instead introduce getters for the needed properties.\n\t*/\n\tpublic getSourceCompletion(): InlineCompletion {\n\t\treturn this._sourceInlineCompletion;\n\t}\n}\n\nexport class InlineSuggestionIdentity {\n\tprivate static idCounter = 0;\n\tprivate readonly _onDispose = observableSignal(this);\n\n\tprivate _refCount = 1;\n\tpublic readonly id = 'InlineCompletionIdentity' + InlineSuggestionIdentity.idCounter++;\n\n\taddRef() {\n\t\tthis._refCount++;\n\t}\n\n\tremoveRef() {\n\t\tthis._refCount--;\n\t\tif (this._refCount === 0) {\n\t\t\tthis._onDispose.trigger(undefined);\n\t\t}\n\t}\n}\n\nclass InlineSuggestDisplayLocation implements IDisplayLocation {\n\n\tpublic static create(displayLocation: IDisplayLocation) {\n\t\treturn new InlineSuggestDisplayLocation(\n\t\t\tdisplayLocation.range,\n\t\t\tdisplayLocation.label,\n\t\t\tdisplayLocation.kind\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly label: string,\n\t\tpublic readonly kind: InlineCompletionDisplayLocationKind\n\t) { }\n\n\tpublic withEdit(edit: StringEdit, positionOffsetTransformer: PositionOffsetTransformerBase): InlineSuggestDisplayLocation | undefined {\n\t\tconst offsetRange = new OffsetRange(\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getStartPosition()),\n\t\t\tpositionOffsetTransformer.getOffset(this.range.getEndPosition())\n\t\t);\n\n\t\tconst newOffsetRange = applyEditsToRanges([offsetRange], edit)[0];\n\t\tif (!newOffsetRange) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst newRange = positionOffsetTransformer.getRange(newOffsetRange);\n\n\t\treturn new InlineSuggestDisplayLocation(newRange, this.label, this.kind);\n\t}\n}\n\nexport class InlineCompletionItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineCompletionItem {\n\t\tconst identity = new InlineSuggestionIdentity();\n\t\tconst transformer = getPositionOffsetTransformerFromTextModel(textModel);\n\n\t\tconst insertText = data.insertText.replace(/\\r\\n|\\r|\\n/g, textModel.getEOL());\n\n\t\tconst edit = reshapeInlineCompletion(new StringReplacement(transformer.getOffsetRange(data.range), insertText), textModel);\n\t\tconst trimmedEdit = edit.removeCommonSuffixAndPrefix(textModel.getValue());\n\t\tconst textEdit = transformer.getTextReplacement(edit);\n\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\n\t\treturn new InlineCompletionItem(edit, trimmedEdit, textEdit, textEdit.range, data.snippetInfo, data.additionalTextEdits, data, identity, displayLocation);\n\t}\n\n\tpublic readonly isInlineEdit = false;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringReplacement,\n\t\tprivate readonly _trimmedEdit: StringReplacement,\n\t\tprivate readonly _textEdit: TextReplacement,\n\t\tprivate readonly _originalRange: Range,\n\t\tpublic readonly snippetInfo: SnippetInfo | undefined,\n\t\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[],\n\n\t\tdata: InlineSuggestData,\n\t\tidentity: InlineSuggestionIdentity,\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\toverride get hash(): string {\n\t\treturn JSON.stringify(this._trimmedEdit.toJson());\n\t}\n\n\toverride getSingleTextEdit(): TextReplacement { return this._textEdit; }\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineCompletionItem {\n\t\treturn new InlineCompletionItem(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedEdit,\n\t\t\tthis._textEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis.displayLocation\n\t\t);\n\t}\n\n\toverride withEdit(textModelEdit: StringEdit, textModel: ITextModel): InlineCompletionItem | undefined {\n\t\tconst newEditRange = applyEditsToRanges([this._edit.replaceRange], textModelEdit);\n\t\tif (newEditRange.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst newEdit = new StringReplacement(newEditRange[0], this._textEdit.text);\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextReplacement(newEdit);\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelEdit, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst trimmedEdit = newEdit.removeCommonSuffixAndPrefix(textModel.getValue());\n\n\t\treturn new InlineCompletionItem(\n\t\t\tnewEdit,\n\t\t\ttrimmedEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._originalRange,\n\t\t\tthis.snippetInfo,\n\t\t\tthis.additionalTextEdits,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tnewDisplayLocation\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\tconst updatedRange = this._textEdit.range;\n\t\tconst result = !!updatedRange\n\t\t\t&& updatedRange.containsPosition(position)\n\t\t\t&& this.isVisible(model, position)\n\t\t\t&& TextLength.ofRange(updatedRange).isGreaterThanOrEqualTo(TextLength.ofRange(this._originalRange));\n\t\treturn result;\n\t}\n\n\tpublic isVisible(model: ITextModel, cursorPosition: Position): boolean {\n\t\tconst singleTextEdit = this.getSingleTextEdit();\n\t\treturn inlineCompletionIsVisible(singleTextEdit, this._originalRange, model, cursorPosition);\n\t}\n}\n\nexport function inlineCompletionIsVisible(singleTextEdit: TextReplacement, originalRange: Range | undefined, model: ITextModel, cursorPosition: Position): boolean {\n\tconst minimizedReplacement = singleTextRemoveCommonPrefix(singleTextEdit, model);\n\tconst editRange = singleTextEdit.range;\n\tif (!editRange\n\t\t|| (originalRange && !originalRange.getStartPosition().equals(editRange.getStartPosition()))\n\t\t|| cursorPosition.lineNumber !== minimizedReplacement.range.startLineNumber\n\t\t|| minimizedReplacement.isEmpty // if the completion is empty after removing the common prefix of the completion and the model, the completion item would not be visible\n\t) {\n\t\treturn false;\n\t}\n\n\t// We might consider comparing by .toLowerText, but this requires GhostTextReplacement\n\tconst originalValue = model.getValueInRange(minimizedReplacement.range, EndOfLinePreference.LF);\n\tconst filterText = minimizedReplacement.text;\n\n\tconst cursorPosIndex = Math.max(0, cursorPosition.column - minimizedReplacement.range.startColumn);\n\n\tlet filterTextBefore = filterText.substring(0, cursorPosIndex);\n\tlet filterTextAfter = filterText.substring(cursorPosIndex);\n\n\tlet originalValueBefore = originalValue.substring(0, cursorPosIndex);\n\tlet originalValueAfter = originalValue.substring(cursorPosIndex);\n\n\tconst originalValueIndent = model.getLineIndentColumn(minimizedReplacement.range.startLineNumber);\n\tif (minimizedReplacement.range.startColumn <= originalValueIndent) {\n\t\t// Remove indentation\n\t\toriginalValueBefore = originalValueBefore.trimStart();\n\t\tif (originalValueBefore.length === 0) {\n\t\t\toriginalValueAfter = originalValueAfter.trimStart();\n\t\t}\n\t\tfilterTextBefore = filterTextBefore.trimStart();\n\t\tif (filterTextBefore.length === 0) {\n\t\t\tfilterTextAfter = filterTextAfter.trimStart();\n\t\t}\n\t}\n\n\treturn filterTextBefore.startsWith(originalValueBefore)\n\t\t&& !!matchesSubString(originalValueAfter, filterTextAfter);\n}\n\nexport class InlineEditItem extends InlineSuggestionItemBase {\n\tpublic static create(\n\t\tdata: InlineSuggestData,\n\t\ttextModel: ITextModel,\n\t): InlineEditItem {\n\t\tconst offsetEdit = getStringEdit(textModel, data.range, data.insertText);\n\t\tconst text = new TextModelText(textModel);\n\t\tconst textEdit = TextEdit.fromStringEdit(offsetEdit, text);\n\t\tconst singleTextEdit = offsetEdit.isEmpty() ? new TextReplacement(new Range(1, 1, 1, 1), '') : textEdit.toReplacement(text); // FIXME: .toReplacement() can throw because offsetEdit is empty because we get an empty diff in getStringEdit after diffing\n\t\tconst identity = new InlineSuggestionIdentity();\n\n\t\tconst edits = offsetEdit.replacements.map(edit => {\n\t\t\tconst replacedRange = Range.fromPositions(textModel.getPositionAt(edit.replaceRange.start), textModel.getPositionAt(edit.replaceRange.endExclusive));\n\t\t\tconst replacedText = textModel.getValueInRange(replacedRange);\n\t\t\treturn SingleUpdatedNextEdit.create(edit, replacedText);\n\t\t});\n\t\tconst displayLocation = data.displayLocation ? InlineSuggestDisplayLocation.create(data.displayLocation) : undefined;\n\t\treturn new InlineEditItem(offsetEdit, singleTextEdit, data, identity, edits, displayLocation, false, textModel.getVersionId());\n\t}\n\n\tpublic readonly snippetInfo: SnippetInfo | undefined = undefined;\n\tpublic readonly additionalTextEdits: readonly ISingleEditOperation[] = [];\n\tpublic readonly isInlineEdit = true;\n\n\tprivate constructor(\n\t\tprivate readonly _edit: StringEdit,\n\t\tprivate readonly _textEdit: TextReplacement,\n\n\t\tdata: InlineSuggestData,\n\n\t\tidentity: InlineSuggestionIdentity,\n\t\tprivate readonly _edits: readonly SingleUpdatedNextEdit[],\n\t\tdisplayLocation: InlineSuggestDisplayLocation | undefined,\n\t\tprivate readonly _lastChangePartOfInlineEdit = false,\n\t\tprivate readonly _inlineEditModelVersion: number,\n\t) {\n\t\tsuper(data, identity, displayLocation);\n\t}\n\n\tpublic get updatedEditModelVersion(): number { return this._inlineEditModelVersion; }\n\tpublic get updatedEdit(): StringEdit { return this._edit; }\n\n\toverride getSingleTextEdit(): TextReplacement {\n\t\treturn this._textEdit;\n\t}\n\n\toverride withIdentity(identity: InlineSuggestionIdentity): InlineEditItem {\n\t\treturn new InlineEditItem(\n\t\t\tthis._edit,\n\t\t\tthis._textEdit,\n\t\t\tthis._data,\n\t\t\tidentity,\n\t\t\tthis._edits,\n\t\t\tthis.displayLocation,\n\t\t\tthis._lastChangePartOfInlineEdit,\n\t\t\tthis._inlineEditModelVersion,\n\t\t);\n\t}\n\n\toverride canBeReused(model: ITextModel, position: Position): boolean {\n\t\t// TODO@hediet I believe this can be simplified to `return true;`, as applying an edit should kick out this suggestion.\n\t\treturn this._lastChangePartOfInlineEdit && this.updatedEditModelVersion === model.getVersionId();\n\t}\n\n\toverride withEdit(textModelChanges: StringEdit, textModel: ITextModel): InlineEditItem | undefined {\n\t\tconst edit = this._applyTextModelChanges(textModelChanges, this._edits, textModel);\n\t\treturn edit;\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit, edits: readonly SingleUpdatedNextEdit[], textModel: ITextModel): InlineEditItem | undefined {\n\t\tedits = edits.map(innerEdit => innerEdit.applyTextModelChanges(textModelChanges));\n\n\t\tif (edits.some(edit => edit.edit === undefined)) {\n\t\t\treturn undefined; // change is invalid, so we will have to drop the completion\n\t\t}\n\n\t\tconst newTextModelVersion = textModel.getVersionId();\n\n\t\tlet inlineEditModelVersion = this._inlineEditModelVersion;\n\t\tconst lastChangePartOfInlineEdit = edits.some(edit => edit.lastChangeUpdatedEdit);\n\t\tif (lastChangePartOfInlineEdit) {\n\t\t\tinlineEditModelVersion = newTextModelVersion ?? -1;\n\t\t}\n\n\t\tif (newTextModelVersion === null || inlineEditModelVersion + 20 < newTextModelVersion) {\n\t\t\treturn undefined; // the completion has been ignored for a while, remove it\n\t\t}\n\n\t\tedits = edits.filter(innerEdit => !innerEdit.edit!.isEmpty);\n\t\tif (edits.length === 0) {\n\t\t\treturn undefined; // the completion has been typed by the user\n\t\t}\n\n\t\tconst newEdit = new StringEdit(edits.map(edit => edit.edit!));\n\t\tconst positionOffsetTransformer = getPositionOffsetTransformerFromTextModel(textModel);\n\t\tconst newTextEdit = positionOffsetTransformer.getTextEdit(newEdit).toReplacement(new TextModelText(textModel));\n\n\t\tlet newDisplayLocation = this.displayLocation;\n\t\tif (newDisplayLocation) {\n\t\t\tnewDisplayLocation = newDisplayLocation.withEdit(textModelChanges, positionOffsetTransformer);\n\t\t\tif (!newDisplayLocation) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn new InlineEditItem(\n\t\t\tnewEdit,\n\t\t\tnewTextEdit,\n\t\t\tthis._data,\n\t\t\tthis.identity,\n\t\t\tedits,\n\t\t\tnewDisplayLocation,\n\t\t\tlastChangePartOfInlineEdit,\n\t\t\tinlineEditModelVersion,\n\t\t);\n\t}\n}\n\nfunction getStringEdit(textModel: ITextModel, editRange: Range, replaceText: string): StringEdit {\n\tconst eol = textModel.getEOL();\n\tconst editOriginalText = textModel.getValueInRange(editRange);\n\tconst editReplaceText = replaceText.replace(/\\r\\n|\\r|\\n/g, eol);\n\n\tconst diffAlgorithm = linesDiffComputers.getDefault();\n\tconst lineDiffs = diffAlgorithm.computeDiff(\n\t\tsplitLines(editOriginalText),\n\t\tsplitLines(editReplaceText),\n\t\t{\n\t\t\tignoreTrimWhitespace: false,\n\t\t\tcomputeMoves: false,\n\t\t\textendToSubwords: true,\n\t\t\tmaxComputationTimeMs: 500,\n\t\t}\n\t);\n\n\tconst innerChanges = lineDiffs.changes.flatMap(c => c.innerChanges ?? []);\n\n\tfunction addRangeToPos(pos: Position, range: Range): Range {\n\t\tconst start = TextLength.fromPosition(range.getStartPosition());\n\t\treturn TextLength.ofRange(range).createRange(start.addToPosition(pos));\n\t}\n\n\tconst modifiedText = new StringText(editReplaceText);\n\n\tconst offsetEdit = new StringEdit(\n\t\tinnerChanges.map(c => {\n\t\t\tconst rangeInModel = addRangeToPos(editRange.getStartPosition(), c.originalRange);\n\t\t\tconst originalRange = getPositionOffsetTransformerFromTextModel(textModel).getOffsetRange(rangeInModel);\n\n\t\t\tconst replaceText = modifiedText.getValueOfRange(c.modifiedRange);\n\t\t\tconst edit = new StringReplacement(originalRange, replaceText);\n\n\t\t\tconst originalText = textModel.getValueInRange(rangeInModel);\n\t\t\treturn reshapeInlineEdit(edit, originalText, innerChanges.length, textModel);\n\t\t})\n\t);\n\n\treturn offsetEdit;\n}\n\nclass SingleUpdatedNextEdit {\n\tpublic static create(\n\t\tedit: StringReplacement,\n\t\treplacedText: string,\n\t): SingleUpdatedNextEdit {\n\t\tconst prefixLength = commonPrefixLength(edit.newText, replacedText);\n\t\tconst suffixLength = commonSuffixLength(edit.newText, replacedText);\n\t\tconst trimmedNewText = edit.newText.substring(prefixLength, edit.newText.length - suffixLength);\n\t\treturn new SingleUpdatedNextEdit(edit, trimmedNewText, prefixLength, suffixLength);\n\t}\n\n\tpublic get edit() { return this._edit; }\n\tpublic get lastChangeUpdatedEdit() { return this._lastChangeUpdatedEdit; }\n\n\tconstructor(\n\t\tprivate _edit: StringReplacement | undefined,\n\t\tprivate _trimmedNewText: string,\n\t\tprivate _prefixLength: number,\n\t\tprivate _suffixLength: number,\n\t\tprivate _lastChangeUpdatedEdit: boolean = false,\n\t) {\n\t}\n\n\tpublic applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tconst c = this._clone();\n\t\tc._applyTextModelChanges(textModelChanges);\n\t\treturn c;\n\t}\n\n\tprivate _clone(): SingleUpdatedNextEdit {\n\t\treturn new SingleUpdatedNextEdit(\n\t\t\tthis._edit,\n\t\t\tthis._trimmedNewText,\n\t\t\tthis._prefixLength,\n\t\t\tthis._suffixLength,\n\t\t\tthis._lastChangeUpdatedEdit,\n\t\t);\n\t}\n\n\tprivate _applyTextModelChanges(textModelChanges: StringEdit) {\n\t\tthis._lastChangeUpdatedEdit = false;\n\n\t\tif (!this._edit) {\n\t\t\tthrow new BugIndicatingError('UpdatedInnerEdits: No edit to apply changes to');\n\t\t}\n\n\t\tconst result = this._applyChanges(this._edit, textModelChanges);\n\t\tif (!result) {\n\t\t\tthis._edit = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._edit = result.edit;\n\t\tthis._lastChangeUpdatedEdit = result.editHasChanged;\n\t}\n\n\tprivate _applyChanges(edit: StringReplacement, textModelChanges: StringEdit): { edit: StringReplacement; editHasChanged: boolean } | undefined {\n\t\tlet editStart = edit.replaceRange.start;\n\t\tlet editEnd = edit.replaceRange.endExclusive;\n\t\tlet editReplaceText = edit.newText;\n\t\tlet editHasChanged = false;\n\n\t\tconst shouldPreserveEditShape = this._prefixLength > 0 || this._suffixLength > 0;\n\n\t\tfor (let i = textModelChanges.replacements.length - 1; i >= 0; i--) {\n\t\t\tconst change = textModelChanges.replacements[i];\n\n\t\t\t// INSERTIONS (only support inserting at start of edit)\n\t\t\tconst isInsertion = change.newText.length > 0 && change.replaceRange.isEmpty;\n\n\t\t\tif (isInsertion && !shouldPreserveEditShape && change.replaceRange.start === editStart && editReplaceText.startsWith(change.newText)) {\n\t\t\t\teditStart += change.newText.length;\n\t\t\t\teditReplaceText = editReplaceText.substring(change.newText.length);\n\t\t\t\teditEnd = Math.max(editStart, editEnd);\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isInsertion && shouldPreserveEditShape && change.replaceRange.start === editStart + this._prefixLength && this._trimmedNewText.startsWith(change.newText)) {\n\t\t\t\teditEnd += change.newText.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tthis._prefixLength += change.newText.length;\n\t\t\t\tthis._trimmedNewText = this._trimmedNewText.substring(change.newText.length);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// DELETIONS\n\t\t\tconst isDeletion = change.newText.length === 0 && change.replaceRange.length > 0;\n\t\t\tif (isDeletion && change.replaceRange.start >= editStart + this._prefixLength && change.replaceRange.endExclusive <= editEnd - this._suffixLength) {\n\t\t\t\t// user deleted text IN-BETWEEN the deletion range\n\t\t\t\teditEnd -= change.replaceRange.length;\n\t\t\t\teditHasChanged = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// user did exactly the edit\n\t\t\tif (change.equals(edit)) {\n\t\t\t\teditHasChanged = true;\n\t\t\t\teditStart = change.replaceRange.endExclusive;\n\t\t\t\teditReplaceText = '';\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// MOVE EDIT\n\t\t\tif (change.replaceRange.start > editEnd) {\n\t\t\t\t// the change happens after the completion range\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (change.replaceRange.endExclusive < editStart) {\n\t\t\t\t// the change happens before the completion range\n\t\t\t\teditStart += change.newText.length - change.replaceRange.length;\n\t\t\t\teditEnd += change.newText.length - change.replaceRange.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// The change intersects the completion, so we will have to drop the completion\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// the resulting edit is a noop as the original and new text are the same\n\t\tif (this._trimmedNewText.length === 0 && editStart + this._prefixLength === editEnd - this._suffixLength) {\n\t\t\treturn { edit: new StringReplacement(new OffsetRange(editStart + this._prefixLength, editStart + this._prefixLength), ''), editHasChanged: true };\n\t\t}\n\n\t\treturn { edit: new StringReplacement(new OffsetRange(editStart, editEnd), editReplaceText), editHasChanged };\n\t}\n}\n\nfunction reshapeInlineCompletion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\t// If the insertion is a multi line insertion starting on the next line\n\t// Move it forwards so that the multi line insertion starts on the current line\n\tconst eol = textModel.getEOL();\n\tif (edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeInlineEdit(edit: StringReplacement, originalText: string, totalInnerEdits: number, textModel: ITextModel): StringReplacement {\n\t// TODO: EOL are not properly trimmed by the diffAlgorithm #12680\n\tconst eol = textModel.getEOL();\n\tif (edit.newText.endsWith(eol) && originalText.endsWith(eol)) {\n\t\tedit = new StringReplacement(edit.replaceRange.deltaEnd(-eol.length), edit.newText.slice(0, -eol.length));\n\t}\n\n\t// INSERTION\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (totalInnerEdits === 1 && edit.replaceRange.isEmpty && edit.newText.includes(eol)) {\n\t\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\t\tconst hasTextOnInsertionLine = textModel.getLineLength(startPosition.lineNumber) !== 0;\n\t\tif (hasTextOnInsertionLine) {\n\t\t\tedit = reshapeMultiLineInsertion(edit, textModel);\n\t\t}\n\t}\n\n\t// The diff algorithm extended a simple edit to the entire word\n\t// shrink it back to a simple edit if it is deletion/insertion only\n\tif (totalInnerEdits === 1) {\n\t\tconst prefixLength = commonPrefixLength(originalText, edit.newText);\n\t\tconst suffixLength = commonSuffixLength(originalText.slice(prefixLength), edit.newText.slice(prefixLength));\n\n\t\t// reshape it back to an insertion\n\t\tif (prefixLength + suffixLength === originalText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), edit.newText.substring(prefixLength, edit.newText.length - suffixLength));\n\t\t}\n\n\t\t// reshape it back to a deletion\n\t\tif (prefixLength + suffixLength === edit.newText.length) {\n\t\t\treturn new StringReplacement(edit.replaceRange.deltaStart(prefixLength).deltaEnd(-suffixLength), '');\n\t\t}\n\t}\n\n\treturn edit;\n}\n\nfunction reshapeMultiLineInsertion(edit: StringReplacement, textModel: ITextModel): StringReplacement {\n\tif (!edit.replaceRange.isEmpty) {\n\t\tthrow new BugIndicatingError('Unexpected original range');\n\t}\n\n\tif (edit.replaceRange.start === 0) {\n\t\treturn edit;\n\t}\n\n\tconst eol = textModel.getEOL();\n\tconst startPosition = textModel.getPositionAt(edit.replaceRange.start);\n\tconst startColumn = startPosition.column;\n\tconst startLineNumber = startPosition.lineNumber;\n\n\t// If the insertion ends with a new line and is inserted at the start of a line which has text,\n\t// we move the insertion to the end of the previous line if possible\n\tif (startColumn === 1 && startLineNumber > 1 && edit.newText.endsWith(eol) && !edit.newText.startsWith(eol)) {\n\t\treturn new StringReplacement(edit.replaceRange.delta(-1), eol + edit.newText.slice(0, -eol.length));\n\t}\n\n\treturn edit;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/suggestWidgetAdapter.ts","vs/editor/contrib/inlineCompletions/browser/model/suggestWidgetAdapter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAoD,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE3H,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAKnD,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACrC,CAAC;IAID,YACkB,MAAmB,EACnB,4BAA+D,EAC/D,YAA6C;QAE9D,KAAK,EAAE,CAAC;QAJS,WAAM,GAAN,MAAM,CAAa;QACnB,iCAA4B,GAA5B,4BAA4B,CAAmC;QAC/D,iBAAY,GAAZ,YAAY,CAAiC;QAbvD,2BAAsB,GAAY,KAAK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IACpD,CAAC;IAEM,uBAAuB;QAC7B,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,EAAE,CAAC;IACtD,CAAC;IAEM,mBAAmB;QACzB,IAAI,CAAC,qBAAqB,CAAC,mBAAmB,EAAE,CAAC;IAClD,CAAC;CACD","file":"suggestWidgetAdapter.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 { compareBy, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findFirstMax } from '../../../../../base/common/arraysFind.js';\nimport { Emitter, Event } from '../../../../../base/common/event.js';\nimport { Disposable } from '../../../../../base/common/lifecycle.js';\nimport { ICodeEditor } from '../../../../browser/editorBrowser.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { CompletionItemInsertTextRule, CompletionItemKind, SelectedSuggestionInfo } from '../../../../common/languages.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { singleTextEditAugments, singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { SnippetParser } from '../../../snippet/browser/snippetParser.js';\nimport { SnippetSession } from '../../../snippet/browser/snippetSession.js';\nimport { CompletionItem } from '../../../suggest/browser/suggest.js';\nimport { SuggestController } from '../../../suggest/browser/suggestController.js';\nimport { ObservableCodeEditor } from '../../../../browser/observableCodeEditor.js';\nimport { observableFromEvent } from '../../../../../base/common/observable.js';\n\nexport class SuggestWidgetAdaptor extends Disposable {\n\tprivate isSuggestWidgetVisible: boolean = false;\n\tprivate isShiftKeyPressed = false;\n\tprivate _isActive = false;\n\tprivate _currentSuggestItemInfo: SuggestItemInfo | undefined = undefined;\n\tpublic get selectedItem(): SuggestItemInfo | undefined {\n\t\treturn this._currentSuggestItemInfo;\n\t}\n\tprivate _onDidSelectedItemChange = this._register(new Emitter<void>());\n\tpublic readonly onDidSelectedItemChange: Event<void> = this._onDidSelectedItemChange.event;\n\n\tconstructor(\n\t\tprivate readonly editor: ICodeEditor,\n\t\tprivate readonly suggestControllerPreselector: () => TextReplacement | undefined,\n\t\tprivate readonly onWillAccept: (item: SuggestItemInfo) => void,\n\t) {\n\t\tsuper();\n\n\t\t// See the command acceptAlternativeSelectedSuggestion that is bound to shift+tab\n\t\tthis._register(editor.onKeyDown(e => {\n\t\t\tif (e.shiftKey && !this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = true;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\t\tthis._register(editor.onKeyUp(e => {\n\t\t\tif (e.shiftKey && this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = false;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (suggestController) {\n\t\t\tthis._register(suggestController.registerSelector({\n\t\t\t\tpriority: 100,\n\t\t\t\tselect: (model, pos, suggestItems) => {\n\t\t\t\t\tconst textModel = this.editor.getModel();\n\t\t\t\t\tif (!textModel) {\n\t\t\t\t\t\t// Should not happen\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst i = this.suggestControllerPreselector();\n\t\t\t\t\tconst itemToPreselect = i ? singleTextRemoveCommonPrefix(i, textModel) : undefined;\n\t\t\t\t\tif (!itemToPreselect) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\t\t\t\t\tconst position = Position.lift(pos);\n\n\t\t\t\t\tconst candidates = suggestItems\n\t\t\t\t\t\t.map((suggestItem, index) => {\n\t\t\t\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(suggestController, textModel, position, suggestItem, this.isShiftKeyPressed);\n\t\t\t\t\t\t\tconst suggestItemTextEdit = singleTextRemoveCommonPrefix(suggestItemInfo.getSingleTextEdit(), textModel);\n\t\t\t\t\t\t\tconst valid = singleTextEditAugments(itemToPreselect, suggestItemTextEdit);\n\t\t\t\t\t\t\treturn { index, valid, prefixLength: suggestItemTextEdit.text.length, suggestItem };\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(item => item && item.valid && item.prefixLength > 0);\n\n\t\t\t\t\tconst result = findFirstMax(\n\t\t\t\t\t\tcandidates,\n\t\t\t\t\t\tcompareBy(s => s!.prefixLength, numberComparator)\n\t\t\t\t\t);\n\t\t\t\t\treturn result ? result.index : - 1;\n\t\t\t\t}\n\t\t\t}));\n\n\t\t\tlet isBoundToSuggestWidget = false;\n\t\t\tconst bindToSuggestWidget = () => {\n\t\t\t\tif (isBoundToSuggestWidget) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tisBoundToSuggestWidget = true;\n\n\t\t\t\tthis._register(suggestController.widget.value.onDidShow(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidHide(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = false;\n\t\t\t\t\tthis.update(false);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidFocus(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t};\n\n\t\t\tthis._register(Event.once(suggestController.model.onDidTrigger)(e => {\n\t\t\t\tbindToSuggestWidget();\n\t\t\t}));\n\n\t\t\tthis._register(suggestController.onWillInsertSuggestItem(e => {\n\t\t\t\tconst position = this.editor.getPosition();\n\t\t\t\tconst model = this.editor.getModel();\n\t\t\t\tif (!position || !model) { return undefined; }\n\n\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(\n\t\t\t\t\tsuggestController,\n\t\t\t\t\tmodel,\n\t\t\t\t\tposition,\n\t\t\t\t\te.item,\n\t\t\t\t\tthis.isShiftKeyPressed\n\t\t\t\t);\n\n\t\t\t\tthis.onWillAccept(suggestItemInfo);\n\t\t\t}));\n\t\t}\n\t\tthis.update(this._isActive);\n\t}\n\n\tprivate update(newActive: boolean): void {\n\t\tconst newInlineCompletion = this.getSuggestItemInfo();\n\n\t\tif (this._isActive !== newActive || !suggestItemInfoEquals(this._currentSuggestItemInfo, newInlineCompletion)) {\n\t\t\tthis._isActive = newActive;\n\t\t\tthis._currentSuggestItemInfo = newInlineCompletion;\n\n\t\t\tthis._onDidSelectedItemChange.fire();\n\t\t}\n\t}\n\n\tprivate getSuggestItemInfo(): SuggestItemInfo | undefined {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (!suggestController || !this.isSuggestWidgetVisible) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst focusedItem = suggestController.widget.value.getFocusedItem();\n\t\tconst position = this.editor.getPosition();\n\t\tconst model = this.editor.getModel();\n\n\t\tif (!focusedItem || !position || !model) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn SuggestItemInfo.fromSuggestion(\n\t\t\tsuggestController,\n\t\t\tmodel,\n\t\t\tposition,\n\t\t\tfocusedItem.item,\n\t\t\tthis.isShiftKeyPressed\n\t\t);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.forceRenderingAbove();\n\t}\n}\n\nexport class SuggestItemInfo {\n\tpublic static fromSuggestion(suggestController: SuggestController, model: ITextModel, position: Position, item: CompletionItem, toggleMode: boolean): SuggestItemInfo {\n\t\tlet { insertText } = item.completion;\n\t\tlet isSnippetText = false;\n\t\tif (item.completion.insertTextRules! & CompletionItemInsertTextRule.InsertAsSnippet) {\n\t\t\tconst snippet = new SnippetParser().parse(insertText);\n\n\t\t\tif (snippet.children.length < 100) {\n\t\t\t\t// Adjust whitespace is expensive.\n\t\t\t\tSnippetSession.adjustWhitespace(model, position, true, snippet);\n\t\t\t}\n\n\t\t\tinsertText = snippet.toString();\n\t\t\tisSnippetText = true;\n\t\t}\n\n\t\tconst info = suggestController.getOverwriteInfo(item, toggleMode);\n\n\t\treturn new SuggestItemInfo(\n\t\t\tRange.fromPositions(\n\t\t\t\tposition.delta(0, -info.overwriteBefore),\n\t\t\t\tposition.delta(0, Math.max(info.overwriteAfter, 0))\n\t\t\t),\n\t\t\tinsertText,\n\t\t\titem.completion.kind,\n\t\t\tisSnippetText,\n\t\t\titem.container.incomplete ?? false,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly insertText: string,\n\t\tpublic readonly completionItemKind: CompletionItemKind,\n\t\tpublic readonly isSnippetText: boolean,\n\t\tpublic readonly listIncomplete: boolean,\n\t) { }\n\n\tpublic equals(other: SuggestItemInfo): boolean {\n\t\treturn this.range.equalsRange(other.range)\n\t\t\t&& this.insertText === other.insertText\n\t\t\t&& this.completionItemKind === other.completionItemKind\n\t\t\t&& this.isSnippetText === other.isSnippetText;\n\t}\n\n\tpublic toSelectedSuggestionInfo(): SelectedSuggestionInfo {\n\t\treturn new SelectedSuggestionInfo(this.range, this.insertText, this.completionItemKind, this.isSnippetText);\n\t}\n\n\tpublic getSingleTextEdit(): TextReplacement {\n\t\treturn new TextReplacement(this.range, this.insertText);\n\t}\n}\n\nfunction suggestItemInfoEquals(a: SuggestItemInfo | undefined, b: SuggestItemInfo | undefined): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\treturn a.equals(b);\n}\n\nexport class ObservableSuggestWidgetAdapter extends Disposable {\n\tprivate readonly _suggestWidgetAdaptor;\n\n\tpublic readonly selectedItem;\n\n\tconstructor(\n\t\tprivate readonly _editorObs: ObservableCodeEditor,\n\n\t\tprivate readonly _handleSuggestAccepted: (item: SuggestItemInfo) => void,\n\t\tprivate readonly _suggestControllerPreselector: () => TextReplacement | undefined,\n\t) {\n\t\tsuper();\n\t\tthis._suggestWidgetAdaptor = this._register(new SuggestWidgetAdaptor(\n\t\t\tthis._editorObs.editor,\n\t\t\t() => {\n\t\t\t\tthis._editorObs.forceUpdate();\n\t\t\t\treturn this._suggestControllerPreselector();\n\t\t\t},\n\t\t\t(item) => this._editorObs.forceUpdate(_tx => {\n\t\t\t\t/** @description InlineCompletionsController.handleSuggestAccepted */\n\t\t\t\tthis._handleSuggestAccepted(item);\n\t\t\t})\n\t\t));\n\t\tthis.selectedItem = observableFromEvent(this, cb => this._suggestWidgetAdaptor.onDidSelectedItemChange(() => {\n\t\t\tthis._editorObs.forceUpdate(_tx => cb(undefined));\n\t\t}), () => this._suggestWidgetAdaptor.selectedItem);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.forceRenderingAbove();\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 { compareBy, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findFirstMax } from '../../../../../base/common/arraysFind.js';\nimport { Emitter, Event } from '../../../../../base/common/event.js';\nimport { Disposable } from '../../../../../base/common/lifecycle.js';\nimport { ICodeEditor } from '../../../../browser/editorBrowser.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { CompletionItemInsertTextRule, CompletionItemKind, SelectedSuggestionInfo } from '../../../../common/languages.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { singleTextEditAugments, singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { SnippetParser } from '../../../snippet/browser/snippetParser.js';\nimport { SnippetSession } from '../../../snippet/browser/snippetSession.js';\nimport { CompletionItem } from '../../../suggest/browser/suggest.js';\nimport { SuggestController } from '../../../suggest/browser/suggestController.js';\nimport { ObservableCodeEditor } from '../../../../browser/observableCodeEditor.js';\nimport { observableFromEvent } from '../../../../../base/common/observable.js';\n\nexport class SuggestWidgetAdaptor extends Disposable {\n\tprivate isSuggestWidgetVisible: boolean = false;\n\tprivate isShiftKeyPressed = false;\n\tprivate _isActive = false;\n\tprivate _currentSuggestItemInfo: SuggestItemInfo | undefined = undefined;\n\tpublic get selectedItem(): SuggestItemInfo | undefined {\n\t\treturn this._currentSuggestItemInfo;\n\t}\n\tprivate _onDidSelectedItemChange = this._register(new Emitter<void>());\n\tpublic readonly onDidSelectedItemChange: Event<void> = this._onDidSelectedItemChange.event;\n\n\tconstructor(\n\t\tprivate readonly editor: ICodeEditor,\n\t\tprivate readonly suggestControllerPreselector: () => TextReplacement | undefined,\n\t\tprivate readonly onWillAccept: (item: SuggestItemInfo) => void,\n\t) {\n\t\tsuper();\n\n\t\t// See the command acceptAlternativeSelectedSuggestion that is bound to shift+tab\n\t\tthis._register(editor.onKeyDown(e => {\n\t\t\tif (e.shiftKey && !this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = true;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\t\tthis._register(editor.onKeyUp(e => {\n\t\t\tif (e.shiftKey && this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = false;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (suggestController) {\n\t\t\tthis._register(suggestController.registerSelector({\n\t\t\t\tpriority: 100,\n\t\t\t\tselect: (model, pos, suggestItems) => {\n\t\t\t\t\tconst textModel = this.editor.getModel();\n\t\t\t\t\tif (!textModel) {\n\t\t\t\t\t\t// Should not happen\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst i = this.suggestControllerPreselector();\n\t\t\t\t\tconst itemToPreselect = i ? singleTextRemoveCommonPrefix(i, textModel) : undefined;\n\t\t\t\t\tif (!itemToPreselect) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\t\t\t\t\tconst position = Position.lift(pos);\n\n\t\t\t\t\tconst candidates = suggestItems\n\t\t\t\t\t\t.map((suggestItem, index) => {\n\t\t\t\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(suggestController, textModel, position, suggestItem, this.isShiftKeyPressed);\n\t\t\t\t\t\t\tconst suggestItemTextEdit = singleTextRemoveCommonPrefix(suggestItemInfo.getSingleTextEdit(), textModel);\n\t\t\t\t\t\t\tconst valid = singleTextEditAugments(itemToPreselect, suggestItemTextEdit);\n\t\t\t\t\t\t\treturn { index, valid, prefixLength: suggestItemTextEdit.text.length, suggestItem };\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(item => item && item.valid && item.prefixLength > 0);\n\n\t\t\t\t\tconst result = findFirstMax(\n\t\t\t\t\t\tcandidates,\n\t\t\t\t\t\tcompareBy(s => s!.prefixLength, numberComparator)\n\t\t\t\t\t);\n\t\t\t\t\treturn result ? result.index : - 1;\n\t\t\t\t}\n\t\t\t}));\n\n\t\t\tlet isBoundToSuggestWidget = false;\n\t\t\tconst bindToSuggestWidget = () => {\n\t\t\t\tif (isBoundToSuggestWidget) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tisBoundToSuggestWidget = true;\n\n\t\t\t\tthis._register(suggestController.widget.value.onDidShow(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidHide(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = false;\n\t\t\t\t\tthis.update(false);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidFocus(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t};\n\n\t\t\tthis._register(Event.once(suggestController.model.onDidTrigger)(e => {\n\t\t\t\tbindToSuggestWidget();\n\t\t\t}));\n\n\t\t\tthis._register(suggestController.onWillInsertSuggestItem(e => {\n\t\t\t\tconst position = this.editor.getPosition();\n\t\t\t\tconst model = this.editor.getModel();\n\t\t\t\tif (!position || !model) { return undefined; }\n\n\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(\n\t\t\t\t\tsuggestController,\n\t\t\t\t\tmodel,\n\t\t\t\t\tposition,\n\t\t\t\t\te.item,\n\t\t\t\t\tthis.isShiftKeyPressed\n\t\t\t\t);\n\n\t\t\t\tthis.onWillAccept(suggestItemInfo);\n\t\t\t}));\n\t\t}\n\t\tthis.update(this._isActive);\n\t}\n\n\tprivate update(newActive: boolean): void {\n\t\tconst newInlineCompletion = this.getSuggestItemInfo();\n\n\t\tif (this._isActive !== newActive || !suggestItemInfoEquals(this._currentSuggestItemInfo, newInlineCompletion)) {\n\t\t\tthis._isActive = newActive;\n\t\t\tthis._currentSuggestItemInfo = newInlineCompletion;\n\n\t\t\tthis._onDidSelectedItemChange.fire();\n\t\t}\n\t}\n\n\tprivate getSuggestItemInfo(): SuggestItemInfo | undefined {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (!suggestController || !this.isSuggestWidgetVisible) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst focusedItem = suggestController.widget.value.getFocusedItem();\n\t\tconst position = this.editor.getPosition();\n\t\tconst model = this.editor.getModel();\n\n\t\tif (!focusedItem || !position || !model) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn SuggestItemInfo.fromSuggestion(\n\t\t\tsuggestController,\n\t\t\tmodel,\n\t\t\tposition,\n\t\t\tfocusedItem.item,\n\t\t\tthis.isShiftKeyPressed\n\t\t);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.forceRenderingAbove();\n\t}\n}\n\nexport class SuggestItemInfo {\n\tpublic static fromSuggestion(suggestController: SuggestController, model: ITextModel, position: Position, item: CompletionItem, toggleMode: boolean): SuggestItemInfo {\n\t\tlet { insertText } = item.completion;\n\t\tlet isSnippetText = false;\n\t\tif (item.completion.insertTextRules! & CompletionItemInsertTextRule.InsertAsSnippet) {\n\t\t\tconst snippet = new SnippetParser().parse(insertText);\n\n\t\t\tif (snippet.children.length < 100) {\n\t\t\t\t// Adjust whitespace is expensive.\n\t\t\t\tSnippetSession.adjustWhitespace(model, position, true, snippet);\n\t\t\t}\n\n\t\t\tinsertText = snippet.toString();\n\t\t\tisSnippetText = true;\n\t\t}\n\n\t\tconst info = suggestController.getOverwriteInfo(item, toggleMode);\n\n\t\treturn new SuggestItemInfo(\n\t\t\tRange.fromPositions(\n\t\t\t\tposition.delta(0, -info.overwriteBefore),\n\t\t\t\tposition.delta(0, Math.max(info.overwriteAfter, 0))\n\t\t\t),\n\t\t\tinsertText,\n\t\t\titem.completion.kind,\n\t\t\tisSnippetText,\n\t\t\titem.container.incomplete ?? false,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly insertText: string,\n\t\tpublic readonly completionItemKind: CompletionItemKind,\n\t\tpublic readonly isSnippetText: boolean,\n\t\tpublic readonly listIncomplete: boolean,\n\t) { }\n\n\tpublic equals(other: SuggestItemInfo): boolean {\n\t\treturn this.range.equalsRange(other.range)\n\t\t\t&& this.insertText === other.insertText\n\t\t\t&& this.completionItemKind === other.completionItemKind\n\t\t\t&& this.isSnippetText === other.isSnippetText;\n\t}\n\n\tpublic toSelectedSuggestionInfo(): SelectedSuggestionInfo {\n\t\treturn new SelectedSuggestionInfo(this.range, this.insertText, this.completionItemKind, this.isSnippetText);\n\t}\n\n\tpublic getSingleTextEdit(): TextReplacement {\n\t\treturn new TextReplacement(this.range, this.insertText);\n\t}\n}\n\nfunction suggestItemInfoEquals(a: SuggestItemInfo | undefined, b: SuggestItemInfo | undefined): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\treturn a.equals(b);\n}\n\nexport class ObservableSuggestWidgetAdapter extends Disposable {\n\tprivate readonly _suggestWidgetAdaptor;\n\n\tpublic readonly selectedItem;\n\n\tconstructor(\n\t\tprivate readonly _editorObs: ObservableCodeEditor,\n\n\t\tprivate readonly _handleSuggestAccepted: (item: SuggestItemInfo) => void,\n\t\tprivate readonly _suggestControllerPreselector: () => TextReplacement | undefined,\n\t) {\n\t\tsuper();\n\t\tthis._suggestWidgetAdaptor = this._register(new SuggestWidgetAdaptor(\n\t\t\tthis._editorObs.editor,\n\t\t\t() => {\n\t\t\t\tthis._editorObs.forceUpdate();\n\t\t\t\treturn this._suggestControllerPreselector();\n\t\t\t},\n\t\t\t(item) => this._editorObs.forceUpdate(_tx => {\n\t\t\t\t/** @description InlineCompletionsController.handleSuggestAccepted */\n\t\t\t\tthis._handleSuggestAccepted(item);\n\t\t\t})\n\t\t));\n\t\tthis.selectedItem = observableFromEvent(this, cb => this._suggestWidgetAdaptor.onDidSelectedItemChange(() => {\n\t\t\tthis._editorObs.forceUpdate(_tx => cb(undefined));\n\t\t}), () => this._suggestWidgetAdaptor.selectedItem);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.forceRenderingAbove();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/contrib/inlineCompletions/browser/model/suggestWidgetAdapter.ts","vs/editor/contrib/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,mBAAmB,EAAE,CAAC;IAClD,CAAC;CACD","file":"suggestWidgetAdapter.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 { compareBy, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findFirstMax } from '../../../../../base/common/arraysFind.js';\nimport { Emitter, Event } from '../../../../../base/common/event.js';\nimport { Disposable } from '../../../../../base/common/lifecycle.js';\nimport { ICodeEditor } from '../../../../browser/editorBrowser.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { CompletionItemInsertTextRule, CompletionItemKind, SelectedSuggestionInfo } from '../../../../common/languages.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { singleTextEditAugments, singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { SnippetParser } from '../../../snippet/browser/snippetParser.js';\nimport { SnippetSession } from '../../../snippet/browser/snippetSession.js';\nimport { CompletionItem } from '../../../suggest/browser/suggest.js';\nimport { SuggestController } from '../../../suggest/browser/suggestController.js';\nimport { ObservableCodeEditor } from '../../../../browser/observableCodeEditor.js';\nimport { observableFromEvent } from '../../../../../base/common/observable.js';\n\nexport class SuggestWidgetAdaptor extends Disposable {\n\tprivate isSuggestWidgetVisible: boolean = false;\n\tprivate isShiftKeyPressed = false;\n\tprivate _isActive = false;\n\tprivate _currentSuggestItemInfo: SuggestItemInfo | undefined = undefined;\n\tpublic get selectedItem(): SuggestItemInfo | undefined {\n\t\treturn this._currentSuggestItemInfo;\n\t}\n\tprivate _onDidSelectedItemChange = this._register(new Emitter<void>());\n\tpublic readonly onDidSelectedItemChange: Event<void> = this._onDidSelectedItemChange.event;\n\n\tconstructor(\n\t\tprivate readonly editor: ICodeEditor,\n\t\tprivate readonly suggestControllerPreselector: () => TextReplacement | undefined,\n\t\tprivate readonly onWillAccept: (item: SuggestItemInfo) => void,\n\t) {\n\t\tsuper();\n\n\t\t// See the command acceptAlternativeSelectedSuggestion that is bound to shift+tab\n\t\tthis._register(editor.onKeyDown(e => {\n\t\t\tif (e.shiftKey && !this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = true;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\t\tthis._register(editor.onKeyUp(e => {\n\t\t\tif (e.shiftKey && this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = false;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (suggestController) {\n\t\t\tthis._register(suggestController.registerSelector({\n\t\t\t\tpriority: 100,\n\t\t\t\tselect: (model, pos, suggestItems) => {\n\t\t\t\t\tconst textModel = this.editor.getModel();\n\t\t\t\t\tif (!textModel) {\n\t\t\t\t\t\t// Should not happen\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst i = this.suggestControllerPreselector();\n\t\t\t\t\tconst itemToPreselect = i ? singleTextRemoveCommonPrefix(i, textModel) : undefined;\n\t\t\t\t\tif (!itemToPreselect) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\t\t\t\t\tconst position = Position.lift(pos);\n\n\t\t\t\t\tconst candidates = suggestItems\n\t\t\t\t\t\t.map((suggestItem, index) => {\n\t\t\t\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(suggestController, textModel, position, suggestItem, this.isShiftKeyPressed);\n\t\t\t\t\t\t\tconst suggestItemTextEdit = singleTextRemoveCommonPrefix(suggestItemInfo.getSingleTextEdit(), textModel);\n\t\t\t\t\t\t\tconst valid = singleTextEditAugments(itemToPreselect, suggestItemTextEdit);\n\t\t\t\t\t\t\treturn { index, valid, prefixLength: suggestItemTextEdit.text.length, suggestItem };\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(item => item && item.valid && item.prefixLength > 0);\n\n\t\t\t\t\tconst result = findFirstMax(\n\t\t\t\t\t\tcandidates,\n\t\t\t\t\t\tcompareBy(s => s!.prefixLength, numberComparator)\n\t\t\t\t\t);\n\t\t\t\t\treturn result ? result.index : -1;\n\t\t\t\t}\n\t\t\t}));\n\n\t\t\tlet isBoundToSuggestWidget = false;\n\t\t\tconst bindToSuggestWidget = () => {\n\t\t\t\tif (isBoundToSuggestWidget) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tisBoundToSuggestWidget = true;\n\n\t\t\t\tthis._register(suggestController.widget.value.onDidShow(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidHide(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = false;\n\t\t\t\t\tthis.update(false);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidFocus(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t};\n\n\t\t\tthis._register(Event.once(suggestController.model.onDidTrigger)(e => {\n\t\t\t\tbindToSuggestWidget();\n\t\t\t}));\n\n\t\t\tthis._register(suggestController.onWillInsertSuggestItem(e => {\n\t\t\t\tconst position = this.editor.getPosition();\n\t\t\t\tconst model = this.editor.getModel();\n\t\t\t\tif (!position || !model) { return undefined; }\n\n\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(\n\t\t\t\t\tsuggestController,\n\t\t\t\t\tmodel,\n\t\t\t\t\tposition,\n\t\t\t\t\te.item,\n\t\t\t\t\tthis.isShiftKeyPressed\n\t\t\t\t);\n\n\t\t\t\tthis.onWillAccept(suggestItemInfo);\n\t\t\t}));\n\t\t}\n\t\tthis.update(this._isActive);\n\t}\n\n\tprivate update(newActive: boolean): void {\n\t\tconst newInlineCompletion = this.getSuggestItemInfo();\n\n\t\tif (this._isActive !== newActive || !suggestItemInfoEquals(this._currentSuggestItemInfo, newInlineCompletion)) {\n\t\t\tthis._isActive = newActive;\n\t\t\tthis._currentSuggestItemInfo = newInlineCompletion;\n\n\t\t\tthis._onDidSelectedItemChange.fire();\n\t\t}\n\t}\n\n\tprivate getSuggestItemInfo(): SuggestItemInfo | undefined {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (!suggestController || !this.isSuggestWidgetVisible) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst focusedItem = suggestController.widget.value.getFocusedItem();\n\t\tconst position = this.editor.getPosition();\n\t\tconst model = this.editor.getModel();\n\n\t\tif (!focusedItem || !position || !model) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn SuggestItemInfo.fromSuggestion(\n\t\t\tsuggestController,\n\t\t\tmodel,\n\t\t\tposition,\n\t\t\tfocusedItem.item,\n\t\t\tthis.isShiftKeyPressed\n\t\t);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.forceRenderingAbove();\n\t}\n}\n\nexport class SuggestItemInfo {\n\tpublic static fromSuggestion(suggestController: SuggestController, model: ITextModel, position: Position, item: CompletionItem, toggleMode: boolean): SuggestItemInfo {\n\t\tlet { insertText } = item.completion;\n\t\tlet isSnippetText = false;\n\t\tif (item.completion.insertTextRules! & CompletionItemInsertTextRule.InsertAsSnippet) {\n\t\t\tconst snippet = new SnippetParser().parse(insertText);\n\n\t\t\tif (snippet.children.length < 100) {\n\t\t\t\t// Adjust whitespace is expensive.\n\t\t\t\tSnippetSession.adjustWhitespace(model, position, true, snippet);\n\t\t\t}\n\n\t\t\tinsertText = snippet.toString();\n\t\t\tisSnippetText = true;\n\t\t}\n\n\t\tconst info = suggestController.getOverwriteInfo(item, toggleMode);\n\n\t\treturn new SuggestItemInfo(\n\t\t\tRange.fromPositions(\n\t\t\t\tposition.delta(0, -info.overwriteBefore),\n\t\t\t\tposition.delta(0, Math.max(info.overwriteAfter, 0))\n\t\t\t),\n\t\t\tinsertText,\n\t\t\titem.completion.kind,\n\t\t\tisSnippetText,\n\t\t\titem.container.incomplete ?? false,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly insertText: string,\n\t\tpublic readonly completionItemKind: CompletionItemKind,\n\t\tpublic readonly isSnippetText: boolean,\n\t\tpublic readonly listIncomplete: boolean,\n\t) { }\n\n\tpublic equals(other: SuggestItemInfo): boolean {\n\t\treturn this.range.equalsRange(other.range)\n\t\t\t&& this.insertText === other.insertText\n\t\t\t&& this.completionItemKind === other.completionItemKind\n\t\t\t&& this.isSnippetText === other.isSnippetText;\n\t}\n\n\tpublic toSelectedSuggestionInfo(): SelectedSuggestionInfo {\n\t\treturn new SelectedSuggestionInfo(this.range, this.insertText, this.completionItemKind, this.isSnippetText);\n\t}\n\n\tpublic getSingleTextEdit(): TextReplacement {\n\t\treturn new TextReplacement(this.range, this.insertText);\n\t}\n}\n\nfunction suggestItemInfoEquals(a: SuggestItemInfo | undefined, b: SuggestItemInfo | undefined): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\treturn a.equals(b);\n}\n\nexport class ObservableSuggestWidgetAdapter extends Disposable {\n\tprivate readonly _suggestWidgetAdaptor;\n\n\tpublic readonly selectedItem;\n\n\tconstructor(\n\t\tprivate readonly _editorObs: ObservableCodeEditor,\n\n\t\tprivate readonly _handleSuggestAccepted: (item: SuggestItemInfo) => void,\n\t\tprivate readonly _suggestControllerPreselector: () => TextReplacement | undefined,\n\t) {\n\t\tsuper();\n\t\tthis._suggestWidgetAdaptor = this._register(new SuggestWidgetAdaptor(\n\t\t\tthis._editorObs.editor,\n\t\t\t() => {\n\t\t\t\tthis._editorObs.forceUpdate();\n\t\t\t\treturn this._suggestControllerPreselector();\n\t\t\t},\n\t\t\t(item) => this._editorObs.forceUpdate(_tx => {\n\t\t\t\t/** @description InlineCompletionsController.handleSuggestAccepted */\n\t\t\t\tthis._handleSuggestAccepted(item);\n\t\t\t})\n\t\t));\n\t\tthis.selectedItem = observableFromEvent(this, cb => this._suggestWidgetAdaptor.onDidSelectedItemChange(() => {\n\t\t\tthis._editorObs.forceUpdate(_tx => cb(undefined));\n\t\t}), () => this._suggestWidgetAdaptor.selectedItem);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.forceRenderingAbove();\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 { compareBy, numberComparator } from '../../../../../base/common/arrays.js';\nimport { findFirstMax } from '../../../../../base/common/arraysFind.js';\nimport { Emitter, Event } from '../../../../../base/common/event.js';\nimport { Disposable } from '../../../../../base/common/lifecycle.js';\nimport { ICodeEditor } from '../../../../browser/editorBrowser.js';\nimport { Position } from '../../../../common/core/position.js';\nimport { Range } from '../../../../common/core/range.js';\nimport { TextReplacement } from '../../../../common/core/edits/textEdit.js';\nimport { CompletionItemInsertTextRule, CompletionItemKind, SelectedSuggestionInfo } from '../../../../common/languages.js';\nimport { ITextModel } from '../../../../common/model.js';\nimport { singleTextEditAugments, singleTextRemoveCommonPrefix } from './singleTextEditHelpers.js';\nimport { SnippetParser } from '../../../snippet/browser/snippetParser.js';\nimport { SnippetSession } from '../../../snippet/browser/snippetSession.js';\nimport { CompletionItem } from '../../../suggest/browser/suggest.js';\nimport { SuggestController } from '../../../suggest/browser/suggestController.js';\nimport { ObservableCodeEditor } from '../../../../browser/observableCodeEditor.js';\nimport { observableFromEvent } from '../../../../../base/common/observable.js';\n\nexport class SuggestWidgetAdaptor extends Disposable {\n\tprivate isSuggestWidgetVisible: boolean = false;\n\tprivate isShiftKeyPressed = false;\n\tprivate _isActive = false;\n\tprivate _currentSuggestItemInfo: SuggestItemInfo | undefined = undefined;\n\tpublic get selectedItem(): SuggestItemInfo | undefined {\n\t\treturn this._currentSuggestItemInfo;\n\t}\n\tprivate _onDidSelectedItemChange = this._register(new Emitter<void>());\n\tpublic readonly onDidSelectedItemChange: Event<void> = this._onDidSelectedItemChange.event;\n\n\tconstructor(\n\t\tprivate readonly editor: ICodeEditor,\n\t\tprivate readonly suggestControllerPreselector: () => TextReplacement | undefined,\n\t\tprivate readonly onWillAccept: (item: SuggestItemInfo) => void,\n\t) {\n\t\tsuper();\n\n\t\t// See the command acceptAlternativeSelectedSuggestion that is bound to shift+tab\n\t\tthis._register(editor.onKeyDown(e => {\n\t\t\tif (e.shiftKey && !this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = true;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\t\tthis._register(editor.onKeyUp(e => {\n\t\t\tif (e.shiftKey && this.isShiftKeyPressed) {\n\t\t\t\tthis.isShiftKeyPressed = false;\n\t\t\t\tthis.update(this._isActive);\n\t\t\t}\n\t\t}));\n\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (suggestController) {\n\t\t\tthis._register(suggestController.registerSelector({\n\t\t\t\tpriority: 100,\n\t\t\t\tselect: (model, pos, suggestItems) => {\n\t\t\t\t\tconst textModel = this.editor.getModel();\n\t\t\t\t\tif (!textModel) {\n\t\t\t\t\t\t// Should not happen\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst i = this.suggestControllerPreselector();\n\t\t\t\t\tconst itemToPreselect = i ? singleTextRemoveCommonPrefix(i, textModel) : undefined;\n\t\t\t\t\tif (!itemToPreselect) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\t\t\t\t\tconst position = Position.lift(pos);\n\n\t\t\t\t\tconst candidates = suggestItems\n\t\t\t\t\t\t.map((suggestItem, index) => {\n\t\t\t\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(suggestController, textModel, position, suggestItem, this.isShiftKeyPressed);\n\t\t\t\t\t\t\tconst suggestItemTextEdit = singleTextRemoveCommonPrefix(suggestItemInfo.getSingleTextEdit(), textModel);\n\t\t\t\t\t\t\tconst valid = singleTextEditAugments(itemToPreselect, suggestItemTextEdit);\n\t\t\t\t\t\t\treturn { index, valid, prefixLength: suggestItemTextEdit.text.length, suggestItem };\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(item => item && item.valid && item.prefixLength > 0);\n\n\t\t\t\t\tconst result = findFirstMax(\n\t\t\t\t\t\tcandidates,\n\t\t\t\t\t\tcompareBy(s => s!.prefixLength, numberComparator)\n\t\t\t\t\t);\n\t\t\t\t\treturn result ? result.index : -1;\n\t\t\t\t}\n\t\t\t}));\n\n\t\t\tlet isBoundToSuggestWidget = false;\n\t\t\tconst bindToSuggestWidget = () => {\n\t\t\t\tif (isBoundToSuggestWidget) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tisBoundToSuggestWidget = true;\n\n\t\t\t\tthis._register(suggestController.widget.value.onDidShow(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidHide(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = false;\n\t\t\t\t\tthis.update(false);\n\t\t\t\t}));\n\t\t\t\tthis._register(suggestController.widget.value.onDidFocus(() => {\n\t\t\t\t\tthis.isSuggestWidgetVisible = true;\n\t\t\t\t\tthis.update(true);\n\t\t\t\t}));\n\t\t\t};\n\n\t\t\tthis._register(Event.once(suggestController.model.onDidTrigger)(e => {\n\t\t\t\tbindToSuggestWidget();\n\t\t\t}));\n\n\t\t\tthis._register(suggestController.onWillInsertSuggestItem(e => {\n\t\t\t\tconst position = this.editor.getPosition();\n\t\t\t\tconst model = this.editor.getModel();\n\t\t\t\tif (!position || !model) { return undefined; }\n\n\t\t\t\tconst suggestItemInfo = SuggestItemInfo.fromSuggestion(\n\t\t\t\t\tsuggestController,\n\t\t\t\t\tmodel,\n\t\t\t\t\tposition,\n\t\t\t\t\te.item,\n\t\t\t\t\tthis.isShiftKeyPressed\n\t\t\t\t);\n\n\t\t\t\tthis.onWillAccept(suggestItemInfo);\n\t\t\t}));\n\t\t}\n\t\tthis.update(this._isActive);\n\t}\n\n\tprivate update(newActive: boolean): void {\n\t\tconst newInlineCompletion = this.getSuggestItemInfo();\n\n\t\tif (this._isActive !== newActive || !suggestItemInfoEquals(this._currentSuggestItemInfo, newInlineCompletion)) {\n\t\t\tthis._isActive = newActive;\n\t\t\tthis._currentSuggestItemInfo = newInlineCompletion;\n\n\t\t\tthis._onDidSelectedItemChange.fire();\n\t\t}\n\t}\n\n\tprivate getSuggestItemInfo(): SuggestItemInfo | undefined {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tif (!suggestController || !this.isSuggestWidgetVisible) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst focusedItem = suggestController.widget.value.getFocusedItem();\n\t\tconst position = this.editor.getPosition();\n\t\tconst model = this.editor.getModel();\n\n\t\tif (!focusedItem || !position || !model) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn SuggestItemInfo.fromSuggestion(\n\t\t\tsuggestController,\n\t\t\tmodel,\n\t\t\tposition,\n\t\t\tfocusedItem.item,\n\t\t\tthis.isShiftKeyPressed\n\t\t);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tconst suggestController = SuggestController.get(this.editor);\n\t\tsuggestController?.forceRenderingAbove();\n\t}\n}\n\nexport class SuggestItemInfo {\n\tpublic static fromSuggestion(suggestController: SuggestController, model: ITextModel, position: Position, item: CompletionItem, toggleMode: boolean): SuggestItemInfo {\n\t\tlet { insertText } = item.completion;\n\t\tlet isSnippetText = false;\n\t\tif (item.completion.insertTextRules! & CompletionItemInsertTextRule.InsertAsSnippet) {\n\t\t\tconst snippet = new SnippetParser().parse(insertText);\n\n\t\t\tif (snippet.children.length < 100) {\n\t\t\t\t// Adjust whitespace is expensive.\n\t\t\t\tSnippetSession.adjustWhitespace(model, position, true, snippet);\n\t\t\t}\n\n\t\t\tinsertText = snippet.toString();\n\t\t\tisSnippetText = true;\n\t\t}\n\n\t\tconst info = suggestController.getOverwriteInfo(item, toggleMode);\n\n\t\treturn new SuggestItemInfo(\n\t\t\tRange.fromPositions(\n\t\t\t\tposition.delta(0, -info.overwriteBefore),\n\t\t\t\tposition.delta(0, Math.max(info.overwriteAfter, 0))\n\t\t\t),\n\t\t\tinsertText,\n\t\t\titem.completion.kind,\n\t\t\tisSnippetText,\n\t\t\titem.container.incomplete ?? false,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly range: Range,\n\t\tpublic readonly insertText: string,\n\t\tpublic readonly completionItemKind: CompletionItemKind,\n\t\tpublic readonly isSnippetText: boolean,\n\t\tpublic readonly listIncomplete: boolean,\n\t) { }\n\n\tpublic equals(other: SuggestItemInfo): boolean {\n\t\treturn this.range.equalsRange(other.range)\n\t\t\t&& this.insertText === other.insertText\n\t\t\t&& this.completionItemKind === other.completionItemKind\n\t\t\t&& this.isSnippetText === other.isSnippetText;\n\t}\n\n\tpublic toSelectedSuggestionInfo(): SelectedSuggestionInfo {\n\t\treturn new SelectedSuggestionInfo(this.range, this.insertText, this.completionItemKind, this.isSnippetText);\n\t}\n\n\tpublic getSingleTextEdit(): TextReplacement {\n\t\treturn new TextReplacement(this.range, this.insertText);\n\t}\n}\n\nfunction suggestItemInfoEquals(a: SuggestItemInfo | undefined, b: SuggestItemInfo | undefined): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\treturn a.equals(b);\n}\n\nexport class ObservableSuggestWidgetAdapter extends Disposable {\n\tprivate readonly _suggestWidgetAdaptor;\n\n\tpublic readonly selectedItem;\n\n\tconstructor(\n\t\tprivate readonly _editorObs: ObservableCodeEditor,\n\n\t\tprivate readonly _handleSuggestAccepted: (item: SuggestItemInfo) => void,\n\t\tprivate readonly _suggestControllerPreselector: () => TextReplacement | undefined,\n\t) {\n\t\tsuper();\n\t\tthis._suggestWidgetAdaptor = this._register(new SuggestWidgetAdaptor(\n\t\t\tthis._editorObs.editor,\n\t\t\t() => {\n\t\t\t\tthis._editorObs.forceUpdate();\n\t\t\t\treturn this._suggestControllerPreselector();\n\t\t\t},\n\t\t\t(item) => this._editorObs.forceUpdate(_tx => {\n\t\t\t\t/** @description InlineCompletionsController.handleSuggestAccepted */\n\t\t\t\tthis._handleSuggestAccepted(item);\n\t\t\t})\n\t\t));\n\t\tthis.selectedItem = observableFromEvent(this, cb => this._suggestWidgetAdaptor.onDidSelectedItemChange(() => {\n\t\t\tthis._editorObs.forceUpdate(_tx => cb(undefined));\n\t\t}), () => this._suggestWidgetAdaptor.selectedItem);\n\t}\n\n\tpublic stopForceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.stopForceRenderingAbove();\n\t}\n\n\tpublic forceRenderingAbove(): void {\n\t\tthis._suggestWidgetAdaptor.forceRenderingAbove();\n\t}\n}\n"]}