`);
+ for (let i2 = 0, len = lines.length; i2 < len; i2++) {
+ const lineData = lines[i2];
+ const lineTokens = lineData.content;
+ sb.appendString('
');
+ const line = lineTokens.getLineContent();
+ const isBasicASCII2 = isBasicASCII(line);
+ const containsRTL2 = containsRTL(line);
+ renderViewLine(new RenderLineInput(fontInfo.isMonospace && !disableMonospaceOptimizations, fontInfo.canUseHalfwidthRightwardsArrow, line, false, isBasicASCII2, containsRTL2, 0, lineTokens, lineData.decorations, tabSize, 0, fontInfo.spaceWidth, fontInfo.middotWidth, fontInfo.wsmiddotWidth, stopRenderingLineAfter, renderWhitespace, renderControlCharacters, fontLigatures !== EditorFontLigatures.OFF, null, null, 0), sb);
+ sb.appendString("
");
+ }
+ sb.appendString("
");
+ applyFontInfo(domNode, fontInfo);
+ const html3 = sb.build();
+ const trustedhtml = ttPolicy4 ? ttPolicy4.createHTML(html3) : html3;
+ domNode.innerHTML = trustedhtml;
+}
+var ttPolicy4 = createTrustedTypesPolicy("editorGhostText", { createHTML: (value) => value });
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViewProducer.js
+init_lifecycle();
+init_observable();
+init_instantiation();
+init_observableCodeEditor();
+init_lineRange();
+init_range();
+
+// node_modules/monaco-editor-core/esm/vs/editor/common/core/edits/lineEdit.js
+init_assert();
+init_strings();
+init_lineRange();
+init_position();
+init_range();
+var LineEdit = class _LineEdit {
+ static {
+ this.empty = new _LineEdit([]);
+ }
+ constructor(replacements) {
+ this.replacements = replacements;
+ assert(checkAdjacentItems(replacements, (i1, i2) => i1.lineRange.endLineNumberExclusive <= i2.lineRange.startLineNumber));
+ }
+ toString() {
+ return this.replacements.map((e) => e.toString()).join(",");
+ }
+ getNewLineRanges() {
+ const ranges = [];
+ let offset = 0;
+ for (const e of this.replacements) {
+ ranges.push(LineRange.ofLength(e.lineRange.startLineNumber + offset, e.newLines.length));
+ offset += e.newLines.length - e.lineRange.length;
+ }
+ return ranges;
+ }
+};
+var LineReplacement = class _LineReplacement {
+ static fromSingleTextEdit(edit2, initialValue) {
+ const newLines = splitLines(edit2.text);
+ let startLineNumber = edit2.range.startLineNumber;
+ const survivingFirstLineText = initialValue.getValueOfRange(Range.fromPositions(new Position(edit2.range.startLineNumber, 1), edit2.range.getStartPosition()));
+ newLines[0] = survivingFirstLineText + newLines[0];
+ let endLineNumberEx = edit2.range.endLineNumber + 1;
+ const editEndLineNumberMaxColumn = initialValue.getTransformer().getLineLength(edit2.range.endLineNumber) + 1;
+ const survivingEndLineText = initialValue.getValueOfRange(Range.fromPositions(edit2.range.getEndPosition(), new Position(edit2.range.endLineNumber, editEndLineNumberMaxColumn)));
+ newLines[newLines.length - 1] = newLines[newLines.length - 1] + survivingEndLineText;
+ const startBeforeNewLine = edit2.range.startColumn === initialValue.getTransformer().getLineLength(edit2.range.startLineNumber) + 1;
+ const endAfterNewLine = edit2.range.endColumn === 1;
+ if (startBeforeNewLine && newLines[0].length === survivingFirstLineText.length) {
+ startLineNumber++;
+ newLines.shift();
+ }
+ if (newLines.length > 0 && startLineNumber < endLineNumberEx && endAfterNewLine && newLines[newLines.length - 1].length === survivingEndLineText.length) {
+ endLineNumberEx--;
+ newLines.pop();
+ }
+ return new _LineReplacement(new LineRange(startLineNumber, endLineNumberEx), newLines);
+ }
+ constructor(lineRange, newLines) {
+ this.lineRange = lineRange;
+ this.newLines = newLines;
+ }
+ toString() {
+ return `${this.lineRange}->${JSON.stringify(this.newLines)}`;
+ }
+ toLineEdit() {
+ return new LineEdit([this]);
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditWithChanges.js
+init_lineRange();
+var InlineEditWithChanges = class {
+ get lineEdit() {
+ if (this.edit.replacements.length === 0) {
+ return new LineReplacement(new LineRange(1, 1), []);
+ }
+ return LineReplacement.fromSingleTextEdit(this.edit.toReplacement(this.originalText), this.originalText);
+ }
+ get originalLineRange() {
+ return this.lineEdit.lineRange;
+ }
+ get modifiedLineRange() {
+ return this.lineEdit.toLineEdit().getNewLineRanges()[0];
+ }
+ get displayRange() {
+ return this.originalText.lineRange.intersect(this.originalLineRange.join(LineRange.ofLength(this.originalLineRange.startLineNumber, this.lineEdit.newLines.length)));
+ }
+ constructor(originalText, edit2, cursorPosition, multiCursorPositions, commands, inlineCompletion) {
+ this.originalText = originalText;
+ this.edit = edit2;
+ this.cursorPosition = cursorPosition;
+ this.multiCursorPositions = multiCursorPositions;
+ this.commands = commands;
+ this.inlineCompletion = inlineCompletion;
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsModel.js
+init_observable();
+init_nls();
+init_observableCodeEditor();
+var InlineEditModel = class {
+ constructor(_model, inlineEdit, tabAction) {
+ this._model = _model;
+ this.inlineEdit = inlineEdit;
+ this.tabAction = tabAction;
+ this.action = this.inlineEdit.inlineCompletion.action;
+ this.displayName = this.inlineEdit.inlineCompletion.source.provider.displayName ?? localize(1219, "Inline Edit");
+ this.extensionCommands = this.inlineEdit.inlineCompletion.source.inlineSuggestions.commands ?? [];
+ this.isInDiffEditor = this._model.isInDiffEditor;
+ this.displayLocation = this.inlineEdit.inlineCompletion.hint;
+ this.showCollapsed = this._model.showCollapsed;
+ }
+ accept() {
+ this._model.accept();
+ }
+ jump() {
+ this._model.jump();
+ }
+ handleInlineEditShown(viewKind, viewData) {
+ this._model.handleInlineSuggestionShown(this.inlineEdit.inlineCompletion, viewKind, viewData);
+ }
+};
+var InlineEditHost = class {
+ constructor(_model) {
+ this._model = _model;
+ this.onDidAccept = this._model.onDidAccept;
+ this.inAcceptFlow = this._model.inAcceptFlow;
+ }
+};
+var GhostTextIndicator = class {
+ constructor(editor2, model, lineRange, inlineCompletion) {
+ this.lineRange = lineRange;
+ const editorObs = observableCodeEditor(editor2);
+ const tabAction = derived(this, (reader) => {
+ if (editorObs.isFocused.read(reader)) {
+ if (inlineCompletion.showInlineEditMenu) {
+ return InlineEditTabAction.Accept;
+ }
+ }
+ return InlineEditTabAction.Inactive;
+ });
+ this.model = new InlineEditModel(model, new InlineEditWithChanges(new StringText(""), new TextEdit([inlineCompletion.getSingleTextEdit()]), model.primaryPosition.get(), model.allPositions.get(), inlineCompletion.source.inlineSuggestions.commands ?? [], inlineCompletion), tabAction);
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js
+init_dom();
+init_equals();
+init_errors();
+init_event();
+init_lifecycle();
+init_observable();
+init_instantiation();
+init_observableCodeEditor();
+init_range();
+init_lineRange();
+init_textLength();
+init_textModel();
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js
+init_dom();
+init_iconLabels2();
+init_codicons();
+init_errors();
+init_lifecycle();
+init_observable();
+init_instantiation();
+init_colorUtils();
+init_themeService();
+init_point();
+
+// node_modules/monaco-editor-core/esm/vs/editor/common/core/2d/rect.js
+init_errors();
+init_point();
+var Rect = class _Rect {
+ static fromPoints(topLeft, bottomRight) {
+ return new _Rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+ }
+ static fromPointSize(point, size2) {
+ return new _Rect(point.x, point.y, point.x + size2.x, point.y + size2.y);
+ }
+ static fromLeftTopRightBottom(left, top, right, bottom) {
+ return new _Rect(left, top, right, bottom);
+ }
+ static fromLeftTopWidthHeight(left, top, width2, height) {
+ return new _Rect(left, top, left + width2, top + height);
+ }
+ static fromRanges(leftRight, topBottom) {
+ return new _Rect(leftRight.start, topBottom.start, leftRight.endExclusive, topBottom.endExclusive);
+ }
+ static hull(rects) {
+ let left = Number.MAX_SAFE_INTEGER;
+ let top = Number.MAX_SAFE_INTEGER;
+ let right = Number.MIN_SAFE_INTEGER;
+ let bottom = Number.MIN_SAFE_INTEGER;
+ for (const rect of rects) {
+ left = Math.min(left, rect.left);
+ top = Math.min(top, rect.top);
+ right = Math.max(right, rect.right);
+ bottom = Math.max(bottom, rect.bottom);
+ }
+ return new _Rect(left, top, right, bottom);
+ }
+ get width() {
+ return this.right - this.left;
+ }
+ get height() {
+ return this.bottom - this.top;
+ }
+ constructor(left, top, right, bottom) {
+ this.left = left;
+ this.top = top;
+ this.right = right;
+ this.bottom = bottom;
+ if (left > right) {
+ throw new BugIndicatingError("Invalid arguments: Horizontally offset by " + (left - right));
+ }
+ if (top > bottom) {
+ throw new BugIndicatingError("Invalid arguments: Vertically offset by " + (top - bottom));
+ }
+ }
+ withMargin(marginOrVerticalOrTop, rightOrHorizontal, bottom, left) {
+ let marginLeft, marginRight, marginTop, marginBottom;
+ if (rightOrHorizontal === void 0 && bottom === void 0 && left === void 0) {
+ marginLeft = marginRight = marginTop = marginBottom = marginOrVerticalOrTop;
+ } else if (bottom === void 0 && left === void 0) {
+ marginLeft = marginRight = rightOrHorizontal;
+ marginTop = marginBottom = marginOrVerticalOrTop;
+ } else {
+ marginLeft = left;
+ marginRight = rightOrHorizontal;
+ marginTop = marginOrVerticalOrTop;
+ marginBottom = bottom;
+ }
+ return new _Rect(this.left - marginLeft, this.top - marginTop, this.right + marginRight, this.bottom + marginBottom);
+ }
+ intersectVertical(range2) {
+ const newTop = Math.max(this.top, range2.start);
+ const newBottom = Math.min(this.bottom, range2.endExclusive);
+ return new _Rect(this.left, newTop, this.right, Math.max(newTop, newBottom));
+ }
+ intersectHorizontal(range2) {
+ const newLeft = Math.max(this.left, range2.start);
+ const newRight = Math.min(this.right, range2.endExclusive);
+ return new _Rect(newLeft, this.top, Math.max(newLeft, newRight), this.bottom);
+ }
+ toString() {
+ return `Rect{(${this.left},${this.top}), (${this.right},${this.bottom})}`;
+ }
+ intersect(parent) {
+ const left = Math.max(this.left, parent.left);
+ const right = Math.min(this.right, parent.right);
+ const top = Math.max(this.top, parent.top);
+ const bottom = Math.min(this.bottom, parent.bottom);
+ if (left > right || top > bottom) {
+ return void 0;
+ }
+ return new _Rect(left, top, right, bottom);
+ }
+ containsRect(other) {
+ return this.left <= other.left && this.top <= other.top && this.right >= other.right && this.bottom >= other.bottom;
+ }
+ containsPoint(point) {
+ return this.left <= point.x && this.top <= point.y && this.right >= point.x && this.bottom >= point.y;
+ }
+ moveToBeContainedIn(parent) {
+ const width2 = this.width;
+ const height = this.height;
+ let left = this.left;
+ let top = this.top;
+ if (left < parent.left) {
+ left = parent.left;
+ } else if (left + width2 > parent.right) {
+ left = parent.right - width2;
+ }
+ if (top < parent.top) {
+ top = parent.top;
+ } else if (top + height > parent.bottom) {
+ top = parent.bottom - height;
+ }
+ return new _Rect(left, top, left + width2, top + height);
+ }
+ withWidth(width2) {
+ return new _Rect(this.left, this.top, this.left + width2, this.bottom);
+ }
+ withHeight(height) {
+ return new _Rect(this.left, this.top, this.right, this.top + height);
+ }
+ withTop(top) {
+ return new _Rect(this.left, top, this.right, this.bottom);
+ }
+ withLeft(left) {
+ return new _Rect(left, this.top, this.right, this.bottom);
+ }
+ translateX(delta) {
+ return new _Rect(this.left + delta, this.top, this.right + delta, this.bottom);
+ }
+ translateY(delta) {
+ return new _Rect(this.left, this.top + delta, this.right, this.bottom + delta);
+ }
+ getLeftBottom() {
+ return new Point(this.left, this.bottom);
+ }
+ getRightBottom() {
+ return new Point(this.right, this.bottom);
+ }
+ getRightTop() {
+ return new Point(this.right, this.top);
+ }
+ toStyles() {
+ return {
+ position: "absolute",
+ left: `${this.left}px`,
+ top: `${this.top}px`,
+ width: `${this.width}px`,
+ height: `${this.height}px`
+ };
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js
+init_offsetRange();
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollController.js
+init_lifecycle();
+init_languageFeatures();
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollWidget.js
+init_dom();
+init_arrays();
+init_lifecycle();
+init_themables();
+init_position();
+init_stringBuilder();
+init_event();
+var StickyScrollWidgetState = class _StickyScrollWidgetState {
+ constructor(startLineNumbers, endLineNumbers, lastLineRelativePosition, showEndForLine = null) {
+ this.startLineNumbers = startLineNumbers;
+ this.endLineNumbers = endLineNumbers;
+ this.lastLineRelativePosition = lastLineRelativePosition;
+ this.showEndForLine = showEndForLine;
+ }
+ equals(other) {
+ return !!other && this.lastLineRelativePosition === other.lastLineRelativePosition && this.showEndForLine === other.showEndForLine && equals(this.startLineNumbers, other.startLineNumbers) && equals(this.endLineNumbers, other.endLineNumbers);
+ }
+ static get Empty() {
+ return new _StickyScrollWidgetState([], [], 0);
+ }
+};
+var _ttPolicy = createTrustedTypesPolicy("stickyScrollViewLayer", { createHTML: (value) => value });
+var STICKY_INDEX_ATTR = "data-sticky-line-index";
+var STICKY_IS_LINE_ATTR = "data-sticky-is-line";
+var STICKY_IS_LINE_NUMBER_ATTR = "data-sticky-is-line-number";
+var STICKY_IS_FOLDING_ICON_ATTR = "data-sticky-is-folding-icon";
+var StickyScrollWidget2 = class extends Disposable {
+ get height() {
+ return this._height;
+ }
+ constructor(editor2) {
+ super();
+ this._foldingIconStore = this._register(new DisposableStore());
+ this._rootDomNode = document.createElement("div");
+ this._lineNumbersDomNode = document.createElement("div");
+ this._linesDomNodeScrollable = document.createElement("div");
+ this._linesDomNode = document.createElement("div");
+ this._renderedStickyLines = [];
+ this._lineNumbers = [];
+ this._lastLineRelativePosition = 0;
+ this._minContentWidthInPx = 0;
+ this._isOnGlyphMargin = false;
+ this._height = -1;
+ this._onDidChangeStickyScrollHeight = this._register(new Emitter());
+ this.onDidChangeStickyScrollHeight = this._onDidChangeStickyScrollHeight.event;
+ this._editor = editor2;
+ this._lineHeight = editor2.getOption(
+ 75
+ /* EditorOption.lineHeight */
+ );
+ this._lineNumbersDomNode.className = "sticky-widget-line-numbers";
+ this._lineNumbersDomNode.setAttribute("role", "none");
+ this._linesDomNode.className = "sticky-widget-lines";
+ this._linesDomNode.setAttribute("role", "list");
+ this._linesDomNodeScrollable.className = "sticky-widget-lines-scrollable";
+ this._linesDomNodeScrollable.appendChild(this._linesDomNode);
+ this._rootDomNode.className = "sticky-widget";
+ this._rootDomNode.classList.toggle("peek", editor2 instanceof EmbeddedCodeEditorWidget);
+ this._rootDomNode.appendChild(this._lineNumbersDomNode);
+ this._rootDomNode.appendChild(this._linesDomNodeScrollable);
+ this._setHeight(0);
+ const updateScrollLeftPosition = () => {
+ this._linesDomNode.style.left = this._editor.getOption(
+ 131
+ /* EditorOption.stickyScroll */
+ ).scrollWithEditor ? `-${this._editor.getScrollLeft()}px` : "0px";
+ };
+ this._register(this._editor.onDidChangeConfiguration((e) => {
+ if (e.hasChanged(
+ 131
+ /* EditorOption.stickyScroll */
+ )) {
+ updateScrollLeftPosition();
+ }
+ if (e.hasChanged(
+ 75
+ /* EditorOption.lineHeight */
+ )) {
+ this._lineHeight = this._editor.getOption(
+ 75
+ /* EditorOption.lineHeight */
+ );
+ }
+ }));
+ this._register(this._editor.onDidScrollChange((e) => {
+ if (e.scrollLeftChanged) {
+ updateScrollLeftPosition();
+ }
+ if (e.scrollWidthChanged) {
+ this._updateWidgetWidth();
+ }
+ }));
+ this._register(this._editor.onDidChangeModel(() => {
+ updateScrollLeftPosition();
+ this._updateWidgetWidth();
+ }));
+ updateScrollLeftPosition();
+ this._register(this._editor.onDidLayoutChange((e) => {
+ this._updateWidgetWidth();
+ }));
+ this._updateWidgetWidth();
+ }
+ get lineNumbers() {
+ return this._lineNumbers;
+ }
+ get lineNumberCount() {
+ return this._lineNumbers.length;
+ }
+ getRenderedStickyLine(lineNumber) {
+ return this._renderedStickyLines.find((stickyLine) => stickyLine.lineNumber === lineNumber);
+ }
+ getCurrentLines() {
+ return this._lineNumbers;
+ }
+ setState(state, foldingModel, rebuildFromIndexCandidate) {
+ const currentStateAndPreviousStateUndefined = !this._state && !state;
+ const currentStateDefinedAndEqualsPreviousState = this._state && this._state.equals(state);
+ if (rebuildFromIndexCandidate === void 0 && (currentStateAndPreviousStateUndefined || currentStateDefinedAndEqualsPreviousState)) {
+ return;
+ }
+ const data = this._findRenderingData(state);
+ const previousLineNumbers = this._lineNumbers;
+ this._lineNumbers = data.lineNumbers;
+ this._lastLineRelativePosition = data.lastLineRelativePosition;
+ const rebuildFromIndex = this._findIndexToRebuildFrom(previousLineNumbers, this._lineNumbers, rebuildFromIndexCandidate);
+ this._renderRootNode(this._lineNumbers, this._lastLineRelativePosition, foldingModel, rebuildFromIndex);
+ this._state = state;
+ }
+ _findRenderingData(state) {
+ if (!state) {
+ return { lineNumbers: [], lastLineRelativePosition: 0 };
+ }
+ const candidateLineNumbers = [...state.startLineNumbers];
+ if (state.showEndForLine !== null) {
+ candidateLineNumbers[state.showEndForLine] = state.endLineNumbers[state.showEndForLine];
+ }
+ let totalHeight = 0;
+ for (let i2 = 0; i2 < candidateLineNumbers.length; i2++) {
+ totalHeight += this._editor.getLineHeightForPosition(new Position(candidateLineNumbers[i2], 1));
+ }
+ if (totalHeight === 0) {
+ return { lineNumbers: [], lastLineRelativePosition: 0 };
+ }
+ return { lineNumbers: candidateLineNumbers, lastLineRelativePosition: state.lastLineRelativePosition };
+ }
+ _findIndexToRebuildFrom(previousLineNumbers, newLineNumbers, rebuildFromIndexCandidate) {
+ if (newLineNumbers.length === 0) {
+ return 0;
+ }
+ if (rebuildFromIndexCandidate !== void 0) {
+ return rebuildFromIndexCandidate;
+ }
+ const validIndex = newLineNumbers.findIndex((startLineNumber) => !previousLineNumbers.includes(startLineNumber));
+ return validIndex === -1 ? 0 : validIndex;
+ }
+ _updateWidgetWidth() {
+ const layoutInfo = this._editor.getLayoutInfo();
+ const lineNumbersWidth = layoutInfo.contentLeft;
+ this._lineNumbersDomNode.style.width = `${lineNumbersWidth}px`;
+ this._linesDomNodeScrollable.style.setProperty("--vscode-editorStickyScroll-scrollableWidth", `${this._editor.getScrollWidth() - layoutInfo.verticalScrollbarWidth}px`);
+ this._rootDomNode.style.width = `${layoutInfo.width - layoutInfo.verticalScrollbarWidth}px`;
+ }
+ _useFoldingOpacityTransition(requireTransitions) {
+ this._lineNumbersDomNode.style.setProperty("--vscode-editorStickyScroll-foldingOpacityTransition", `opacity ${requireTransitions ? 0.5 : 0}s`);
+ }
+ _setFoldingIconsVisibility(allVisible) {
+ for (const line of this._renderedStickyLines) {
+ const foldingIcon = line.foldingIcon;
+ if (!foldingIcon) {
+ continue;
+ }
+ foldingIcon.setVisible(allVisible ? true : foldingIcon.isCollapsed);
+ }
+ }
+ async _renderRootNode(lineNumbers, lastLineRelativePosition, foldingModel, rebuildFromIndex) {
+ const viewModel = this._editor._getViewModel();
+ if (!viewModel) {
+ this._clearWidget();
+ return;
+ }
+ if (lineNumbers.length === 0) {
+ this._clearWidget();
+ return;
+ }
+ const renderedStickyLines = [];
+ const lastLineNumber = lineNumbers[lineNumbers.length - 1];
+ let top = 0;
+ for (let i2 = 0; i2 < this._renderedStickyLines.length; i2++) {
+ if (i2 < rebuildFromIndex) {
+ const renderedLine = this._renderedStickyLines[i2];
+ renderedStickyLines.push(this._updatePosition(renderedLine, top, renderedLine.lineNumber === lastLineNumber));
+ top += renderedLine.height;
+ } else {
+ const renderedLine = this._renderedStickyLines[i2];
+ renderedLine.lineNumberDomNode.remove();
+ renderedLine.lineDomNode.remove();
+ }
+ }
+ const layoutInfo = this._editor.getLayoutInfo();
+ for (let i2 = rebuildFromIndex; i2 < lineNumbers.length; i2++) {
+ const stickyLine = this._renderChildNode(viewModel, i2, lineNumbers[i2], top, lastLineNumber === lineNumbers[i2], foldingModel, layoutInfo);
+ top += stickyLine.height;
+ this._linesDomNode.appendChild(stickyLine.lineDomNode);
+ this._lineNumbersDomNode.appendChild(stickyLine.lineNumberDomNode);
+ renderedStickyLines.push(stickyLine);
+ }
+ if (foldingModel) {
+ this._setFoldingHoverListeners();
+ this._useFoldingOpacityTransition(!this._isOnGlyphMargin);
+ }
+ this._minContentWidthInPx = Math.max(...this._renderedStickyLines.map((l) => l.scrollWidth)) + layoutInfo.verticalScrollbarWidth;
+ this._renderedStickyLines = renderedStickyLines;
+ this._setHeight(top + lastLineRelativePosition);
+ this._editor.layoutOverlayWidget(this);
+ }
+ _clearWidget() {
+ for (let i2 = 0; i2 < this._renderedStickyLines.length; i2++) {
+ const stickyLine = this._renderedStickyLines[i2];
+ stickyLine.lineNumberDomNode.remove();
+ stickyLine.lineDomNode.remove();
+ }
+ this._setHeight(0);
+ }
+ _setHeight(height) {
+ if (this._height === height) {
+ return;
+ }
+ this._height = height;
+ if (this._height === 0) {
+ this._rootDomNode.style.display = "none";
+ } else {
+ this._rootDomNode.style.display = "block";
+ this._lineNumbersDomNode.style.height = `${this._height}px`;
+ this._linesDomNodeScrollable.style.height = `${this._height}px`;
+ this._rootDomNode.style.height = `${this._height}px`;
+ }
+ this._onDidChangeStickyScrollHeight.fire({ height: this._height });
+ }
+ _setFoldingHoverListeners() {
+ const showFoldingControls = this._editor.getOption(
+ 126
+ /* EditorOption.showFoldingControls */
+ );
+ if (showFoldingControls !== "mouseover") {
+ return;
+ }
+ this._foldingIconStore.clear();
+ this._foldingIconStore.add(addDisposableListener(this._lineNumbersDomNode, EventType.MOUSE_ENTER, () => {
+ this._isOnGlyphMargin = true;
+ this._setFoldingIconsVisibility(true);
+ }));
+ this._foldingIconStore.add(addDisposableListener(this._lineNumbersDomNode, EventType.MOUSE_LEAVE, () => {
+ this._isOnGlyphMargin = false;
+ this._useFoldingOpacityTransition(true);
+ this._setFoldingIconsVisibility(false);
+ }));
+ }
+ _renderChildNode(viewModel, index, line, top, isLastLine, foldingModel, layoutInfo) {
+ const viewLineNumber = viewModel.coordinatesConverter.convertModelPositionToViewPosition(new Position(line, 1)).lineNumber;
+ const lineRenderingData = viewModel.getViewLineRenderingData(viewLineNumber);
+ const lineNumberOption = this._editor.getOption(
+ 76
+ /* EditorOption.lineNumbers */
+ );
+ const verticalScrollbarSize = this._editor.getOption(
+ 117
+ /* EditorOption.scrollbar */
+ ).verticalScrollbarSize;
+ let actualInlineDecorations;
+ try {
+ actualInlineDecorations = LineDecoration.filter(lineRenderingData.inlineDecorations, viewLineNumber, lineRenderingData.minColumn, lineRenderingData.maxColumn);
+ } catch (err) {
+ actualInlineDecorations = [];
+ }
+ const lineHeight = this._editor.getLineHeightForPosition(new Position(line, 1));
+ const textDirection = viewModel.getTextDirection(line);
+ const renderLineInput = new RenderLineInput(true, true, lineRenderingData.content, lineRenderingData.continuesWithWrappedLine, lineRenderingData.isBasicASCII, lineRenderingData.containsRTL, 0, lineRenderingData.tokens, actualInlineDecorations, lineRenderingData.tabSize, lineRenderingData.startVisibleColumn, 1, 1, 1, 500, "none", true, true, null, textDirection, verticalScrollbarSize);
+ const sb = new StringBuilder(2e3);
+ const renderOutput = renderViewLine(renderLineInput, sb);
+ let newLine;
+ if (_ttPolicy) {
+ newLine = _ttPolicy.createHTML(sb.build());
+ } else {
+ newLine = sb.build();
+ }
+ const lineHTMLNode = document.createElement("span");
+ lineHTMLNode.setAttribute(STICKY_INDEX_ATTR, String(index));
+ lineHTMLNode.setAttribute(STICKY_IS_LINE_ATTR, "");
+ lineHTMLNode.setAttribute("role", "listitem");
+ lineHTMLNode.tabIndex = 0;
+ lineHTMLNode.className = "sticky-line-content";
+ lineHTMLNode.classList.add(`stickyLine${line}`);
+ lineHTMLNode.style.lineHeight = `${lineHeight}px`;
+ lineHTMLNode.innerHTML = newLine;
+ const lineNumberHTMLNode = document.createElement("span");
+ lineNumberHTMLNode.setAttribute(STICKY_INDEX_ATTR, String(index));
+ lineNumberHTMLNode.setAttribute(STICKY_IS_LINE_NUMBER_ATTR, "");
+ lineNumberHTMLNode.className = "sticky-line-number";
+ lineNumberHTMLNode.style.lineHeight = `${lineHeight}px`;
+ const lineNumbersWidth = layoutInfo.contentLeft;
+ lineNumberHTMLNode.style.width = `${lineNumbersWidth}px`;
+ const innerLineNumberHTML = document.createElement("span");
+ if (lineNumberOption.renderType === 1 || lineNumberOption.renderType === 3 && line % 10 === 0) {
+ innerLineNumberHTML.innerText = line.toString();
+ } else if (lineNumberOption.renderType === 2) {
+ innerLineNumberHTML.innerText = Math.abs(line - this._editor.getPosition().lineNumber).toString();
+ }
+ innerLineNumberHTML.className = "sticky-line-number-inner";
+ innerLineNumberHTML.style.width = `${layoutInfo.lineNumbersWidth}px`;
+ innerLineNumberHTML.style.paddingLeft = `${layoutInfo.lineNumbersLeft}px`;
+ lineNumberHTMLNode.appendChild(innerLineNumberHTML);
+ const foldingIcon = this._renderFoldingIconForLine(foldingModel, line);
+ if (foldingIcon) {
+ lineNumberHTMLNode.appendChild(foldingIcon.domNode);
+ foldingIcon.domNode.style.left = `${layoutInfo.lineNumbersWidth + layoutInfo.lineNumbersLeft}px`;
+ foldingIcon.domNode.style.lineHeight = `${lineHeight}px`;
+ }
+ this._editor.applyFontInfo(lineHTMLNode);
+ this._editor.applyFontInfo(lineNumberHTMLNode);
+ lineNumberHTMLNode.style.lineHeight = `${lineHeight}px`;
+ lineHTMLNode.style.lineHeight = `${lineHeight}px`;
+ lineNumberHTMLNode.style.height = `${lineHeight}px`;
+ lineHTMLNode.style.height = `${lineHeight}px`;
+ const renderedLine = new RenderedStickyLine(index, line, lineHTMLNode, lineNumberHTMLNode, foldingIcon, renderOutput.characterMapping, lineHTMLNode.scrollWidth, lineHeight);
+ return this._updatePosition(renderedLine, top, isLastLine);
+ }
+ _updatePosition(stickyLine, top, isLastLine) {
+ const lineHTMLNode = stickyLine.lineDomNode;
+ const lineNumberHTMLNode = stickyLine.lineNumberDomNode;
+ if (isLastLine) {
+ const zIndex = "0";
+ lineHTMLNode.style.zIndex = zIndex;
+ lineNumberHTMLNode.style.zIndex = zIndex;
+ const updatedTop = `${top + this._lastLineRelativePosition + (stickyLine.foldingIcon?.isCollapsed ? 1 : 0)}px`;
+ lineHTMLNode.style.top = updatedTop;
+ lineNumberHTMLNode.style.top = updatedTop;
+ } else {
+ const zIndex = "1";
+ lineHTMLNode.style.zIndex = zIndex;
+ lineNumberHTMLNode.style.zIndex = zIndex;
+ lineHTMLNode.style.top = `${top}px`;
+ lineNumberHTMLNode.style.top = `${top}px`;
+ }
+ return stickyLine;
+ }
+ _renderFoldingIconForLine(foldingModel, line) {
+ const showFoldingControls = this._editor.getOption(
+ 126
+ /* EditorOption.showFoldingControls */
+ );
+ if (!foldingModel || showFoldingControls === "never") {
+ return;
+ }
+ const foldingRegions = foldingModel.regions;
+ const indexOfFoldingRegion = foldingRegions.findRange(line);
+ const startLineNumber = foldingRegions.getStartLineNumber(indexOfFoldingRegion);
+ const isFoldingScope = line === startLineNumber;
+ if (!isFoldingScope) {
+ return;
+ }
+ const isCollapsed = foldingRegions.isCollapsed(indexOfFoldingRegion);
+ const foldingIcon = new StickyFoldingIcon(isCollapsed, startLineNumber, foldingRegions.getEndLineNumber(indexOfFoldingRegion), this._lineHeight);
+ foldingIcon.setVisible(this._isOnGlyphMargin ? true : isCollapsed || showFoldingControls === "always");
+ foldingIcon.domNode.setAttribute(STICKY_IS_FOLDING_ICON_ATTR, "");
+ return foldingIcon;
+ }
+ getId() {
+ return "editor.contrib.stickyScrollWidget";
+ }
+ getDomNode() {
+ return this._rootDomNode;
+ }
+ getPosition() {
+ return {
+ preference: 2,
+ stackOridinal: 10
+ };
+ }
+ getMinContentWidthInPx() {
+ return this._minContentWidthInPx;
+ }
+ focusLineWithIndex(index) {
+ if (0 <= index && index < this._renderedStickyLines.length) {
+ this._renderedStickyLines[index].lineDomNode.focus();
+ }
+ }
+ /**
+ * Given a leaf dom node, tries to find the editor position.
+ */
+ getEditorPositionFromNode(spanDomNode) {
+ if (!spanDomNode || spanDomNode.children.length > 0) {
+ return null;
+ }
+ const renderedStickyLine = this._getRenderedStickyLineFromChildDomNode(spanDomNode);
+ if (!renderedStickyLine) {
+ return null;
+ }
+ const column = getColumnOfNodeOffset(renderedStickyLine.characterMapping, spanDomNode, 0);
+ return new Position(renderedStickyLine.lineNumber, column);
+ }
+ getLineNumberFromChildDomNode(domNode) {
+ return this._getRenderedStickyLineFromChildDomNode(domNode)?.lineNumber ?? null;
+ }
+ _getRenderedStickyLineFromChildDomNode(domNode) {
+ const index = this.getLineIndexFromChildDomNode(domNode);
+ if (index === null || index < 0 || index >= this._renderedStickyLines.length) {
+ return null;
+ }
+ return this._renderedStickyLines[index];
+ }
+ /**
+ * Given a child dom node, tries to find the line number attribute that was stored in the node.
+ * @returns the attribute value or null if none is found.
+ */
+ getLineIndexFromChildDomNode(domNode) {
+ const lineIndex = this._getAttributeValue(domNode, STICKY_INDEX_ATTR);
+ return lineIndex ? parseInt(lineIndex, 10) : null;
+ }
+ /**
+ * Given a child dom node, tries to find if it is (contained in) a sticky line.
+ * @returns a boolean.
+ */
+ isInStickyLine(domNode) {
+ const isInLine = this._getAttributeValue(domNode, STICKY_IS_LINE_ATTR);
+ return isInLine !== void 0;
+ }
+ /**
+ * Given a child dom node, tries to find if this dom node is (contained in) a sticky folding icon.
+ * @returns a boolean.
+ */
+ isInFoldingIconDomNode(domNode) {
+ const isInFoldingIcon = this._getAttributeValue(domNode, STICKY_IS_FOLDING_ICON_ATTR);
+ return isInFoldingIcon !== void 0;
+ }
+ /**
+ * Given the dom node, finds if it or its parent sequence contains the given attribute.
+ * @returns the attribute value or undefined.
+ */
+ _getAttributeValue(domNode, attribute) {
+ while (domNode && domNode !== this._rootDomNode) {
+ const line = domNode.getAttribute(attribute);
+ if (line !== null) {
+ return line;
+ }
+ domNode = domNode.parentElement;
+ }
+ return;
+ }
+};
+var RenderedStickyLine = class {
+ constructor(index, lineNumber, lineDomNode, lineNumberDomNode, foldingIcon, characterMapping, scrollWidth, height) {
+ this.index = index;
+ this.lineNumber = lineNumber;
+ this.lineDomNode = lineDomNode;
+ this.lineNumberDomNode = lineNumberDomNode;
+ this.foldingIcon = foldingIcon;
+ this.characterMapping = characterMapping;
+ this.scrollWidth = scrollWidth;
+ this.height = height;
+ }
+};
+var StickyFoldingIcon = class {
+ constructor(isCollapsed, foldingStartLine, foldingEndLine, dimension) {
+ this.isCollapsed = isCollapsed;
+ this.foldingStartLine = foldingStartLine;
+ this.foldingEndLine = foldingEndLine;
+ this.dimension = dimension;
+ this.domNode = document.createElement("div");
+ this.domNode.style.width = `26px`;
+ this.domNode.style.height = `${dimension}px`;
+ this.domNode.style.lineHeight = `${dimension}px`;
+ this.domNode.className = ThemeIcon.asClassName(isCollapsed ? foldingCollapsedIcon : foldingExpandedIcon);
+ }
+ setVisible(visible) {
+ this.domNode.style.cursor = visible ? "pointer" : "default";
+ this.domNode.style.opacity = visible ? "1" : "0";
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollProvider.js
+init_lifecycle();
+init_languageFeatures();
+init_cancellation();
+init_async();
+init_arrays();
+init_event();
+init_languageConfigurationRegistry();
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollModelProvider.js
+init_lifecycle();
+init_languageFeatures();
+init_outlineModel();
+init_async();
+init_languageConfigurationRegistry();
+init_errors();
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollElement.js
+var StickyRange = class {
+ constructor(startLineNumber, endLineNumber) {
+ this.startLineNumber = startLineNumber;
+ this.endLineNumber = endLineNumber;
+ }
+};
+var StickyElement = class {
+ constructor(range2, children, parent) {
+ this.range = range2;
+ this.children = children;
+ this.parent = parent;
+ }
+};
+var StickyModel = class {
+ constructor(uri, version, element, outlineProviderId) {
+ this.uri = uri;
+ this.version = version;
+ this.element = element;
+ this.outlineProviderId = outlineProviderId;
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollModelProvider.js
+init_iterator();
+init_instantiation();
+var __decorate117 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param111 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var ModelProvider;
+(function(ModelProvider2) {
+ ModelProvider2["OUTLINE_MODEL"] = "outlineModel";
+ ModelProvider2["FOLDING_PROVIDER_MODEL"] = "foldingProviderModel";
+ ModelProvider2["INDENTATION_MODEL"] = "indentationModel";
+})(ModelProvider || (ModelProvider = {}));
+var Status;
+(function(Status2) {
+ Status2[Status2["VALID"] = 0] = "VALID";
+ Status2[Status2["INVALID"] = 1] = "INVALID";
+ Status2[Status2["CANCELED"] = 2] = "CANCELED";
+})(Status || (Status = {}));
+var StickyModelProvider = class StickyModelProvider2 extends Disposable {
+ constructor(_editor, onProviderUpdate, _languageConfigurationService, _languageFeaturesService) {
+ super();
+ this._editor = _editor;
+ this._modelProviders = [];
+ this._modelPromise = null;
+ this._updateScheduler = this._register(new Delayer(300));
+ this._updateOperation = this._register(new DisposableStore());
+ switch (this._editor.getOption(
+ 131
+ /* EditorOption.stickyScroll */
+ ).defaultModel) {
+ case ModelProvider.OUTLINE_MODEL:
+ this._modelProviders.push(new StickyModelFromCandidateOutlineProvider(this._editor, _languageFeaturesService));
+ // fall through
+ case ModelProvider.FOLDING_PROVIDER_MODEL:
+ this._modelProviders.push(new StickyModelFromCandidateSyntaxFoldingProvider(this._editor, onProviderUpdate, _languageFeaturesService));
+ // fall through
+ case ModelProvider.INDENTATION_MODEL:
+ this._modelProviders.push(new StickyModelFromCandidateIndentationFoldingProvider(this._editor, _languageConfigurationService));
+ break;
+ }
+ }
+ dispose() {
+ this._modelProviders.forEach((provider) => provider.dispose());
+ this._updateOperation.clear();
+ this._cancelModelPromise();
+ super.dispose();
+ }
+ _cancelModelPromise() {
+ if (this._modelPromise) {
+ this._modelPromise.cancel();
+ this._modelPromise = null;
+ }
+ }
+ async update(token) {
+ this._updateOperation.clear();
+ this._updateOperation.add({
+ dispose: () => {
+ this._cancelModelPromise();
+ this._updateScheduler.cancel();
+ }
+ });
+ this._cancelModelPromise();
+ return await this._updateScheduler.trigger(async () => {
+ for (const modelProvider of this._modelProviders) {
+ const { statusPromise, modelPromise } = modelProvider.computeStickyModel(token);
+ this._modelPromise = modelPromise;
+ const status2 = await statusPromise;
+ if (this._modelPromise !== modelPromise) {
+ return null;
+ }
+ switch (status2) {
+ case Status.CANCELED:
+ this._updateOperation.clear();
+ return null;
+ case Status.VALID:
+ return modelProvider.stickyModel;
+ }
+ }
+ return null;
+ }).catch((error) => {
+ onUnexpectedError(error);
+ return null;
+ });
+ }
+};
+StickyModelProvider = __decorate117([
+ __param111(2, IInstantiationService),
+ __param111(3, ILanguageFeaturesService)
+], StickyModelProvider);
+var StickyModelCandidateProvider = class extends Disposable {
+ constructor(_editor) {
+ super();
+ this._editor = _editor;
+ this._stickyModel = null;
+ }
+ get stickyModel() {
+ return this._stickyModel;
+ }
+ _invalid() {
+ this._stickyModel = null;
+ return Status.INVALID;
+ }
+ computeStickyModel(token) {
+ if (token.isCancellationRequested || !this.isProviderValid()) {
+ return { statusPromise: this._invalid(), modelPromise: null };
+ }
+ const providerModelPromise = createCancelablePromise((token2) => this.createModelFromProvider(token2));
+ return {
+ statusPromise: providerModelPromise.then((providerModel) => {
+ if (!this.isModelValid(providerModel)) {
+ return this._invalid();
+ }
+ if (token.isCancellationRequested) {
+ return Status.CANCELED;
+ }
+ this._stickyModel = this.createStickyModel(token, providerModel);
+ return Status.VALID;
+ }).then(void 0, (err) => {
+ onUnexpectedError(err);
+ return Status.CANCELED;
+ }),
+ modelPromise: providerModelPromise
+ };
+ }
+ /**
+ * Method which checks whether the model returned by the provider is valid and can be used to compute a sticky model.
+ * This method by default returns true.
+ * @param model model returned by the provider
+ * @returns boolean indicating whether the model is valid
+ */
+ isModelValid(model) {
+ return true;
+ }
+ /**
+ * Method which checks whether the provider is valid before applying it to find the provider model.
+ * This method by default returns true.
+ * @returns boolean indicating whether the provider is valid
+ */
+ isProviderValid() {
+ return true;
+ }
+};
+var StickyModelFromCandidateOutlineProvider = class StickyModelFromCandidateOutlineProvider2 extends StickyModelCandidateProvider {
+ constructor(_editor, _languageFeaturesService) {
+ super(_editor);
+ this._languageFeaturesService = _languageFeaturesService;
+ }
+ createModelFromProvider(token) {
+ return OutlineModel.create(this._languageFeaturesService.documentSymbolProvider, this._editor.getModel(), token);
+ }
+ createStickyModel(token, model) {
+ const { stickyOutlineElement, providerID } = this._stickyModelFromOutlineModel(model, this._stickyModel?.outlineProviderId);
+ const textModel = this._editor.getModel();
+ return new StickyModel(textModel.uri, textModel.getVersionId(), stickyOutlineElement, providerID);
+ }
+ isModelValid(model) {
+ return model && model.children.size > 0;
+ }
+ _stickyModelFromOutlineModel(outlineModel, preferredProvider) {
+ let outlineElements;
+ if (Iterable.first(outlineModel.children.values()) instanceof OutlineGroup) {
+ const provider = Iterable.find(outlineModel.children.values(), (outlineGroupOfModel) => outlineGroupOfModel.id === preferredProvider);
+ if (provider) {
+ outlineElements = provider.children;
+ } else {
+ let tempID = "";
+ let maxTotalSumOfRanges = -1;
+ let optimalOutlineGroup = void 0;
+ for (const [_key, outlineGroup] of outlineModel.children.entries()) {
+ const totalSumRanges = this._findSumOfRangesOfGroup(outlineGroup);
+ if (totalSumRanges > maxTotalSumOfRanges) {
+ optimalOutlineGroup = outlineGroup;
+ maxTotalSumOfRanges = totalSumRanges;
+ tempID = outlineGroup.id;
+ }
+ }
+ preferredProvider = tempID;
+ outlineElements = optimalOutlineGroup.children;
+ }
+ } else {
+ outlineElements = outlineModel.children;
+ }
+ const stickyChildren = [];
+ const outlineElementsArray = Array.from(outlineElements.values()).sort((element1, element2) => {
+ const range1 = new StickyRange(element1.symbol.range.startLineNumber, element1.symbol.range.endLineNumber);
+ const range2 = new StickyRange(element2.symbol.range.startLineNumber, element2.symbol.range.endLineNumber);
+ return this._comparator(range1, range2);
+ });
+ for (const outlineElement of outlineElementsArray) {
+ stickyChildren.push(this._stickyModelFromOutlineElement(outlineElement, outlineElement.symbol.selectionRange.startLineNumber));
+ }
+ const stickyOutlineElement = new StickyElement(void 0, stickyChildren, void 0);
+ return {
+ stickyOutlineElement,
+ providerID: preferredProvider
+ };
+ }
+ _stickyModelFromOutlineElement(outlineElement, previousStartLine) {
+ const children = [];
+ for (const child of outlineElement.children.values()) {
+ if (child.symbol.selectionRange.startLineNumber !== child.symbol.range.endLineNumber) {
+ if (child.symbol.selectionRange.startLineNumber !== previousStartLine) {
+ children.push(this._stickyModelFromOutlineElement(child, child.symbol.selectionRange.startLineNumber));
+ } else {
+ for (const subchild of child.children.values()) {
+ children.push(this._stickyModelFromOutlineElement(subchild, child.symbol.selectionRange.startLineNumber));
+ }
+ }
+ }
+ }
+ children.sort((child1, child2) => this._comparator(child1.range, child2.range));
+ const range2 = new StickyRange(outlineElement.symbol.selectionRange.startLineNumber, outlineElement.symbol.range.endLineNumber);
+ return new StickyElement(range2, children, void 0);
+ }
+ _comparator(range1, range2) {
+ if (range1.startLineNumber !== range2.startLineNumber) {
+ return range1.startLineNumber - range2.startLineNumber;
+ } else {
+ return range2.endLineNumber - range1.endLineNumber;
+ }
+ }
+ _findSumOfRangesOfGroup(outline) {
+ let res = 0;
+ for (const child of outline.children.values()) {
+ res += this._findSumOfRangesOfGroup(child);
+ }
+ if (outline instanceof OutlineElement) {
+ return res + outline.symbol.range.endLineNumber - outline.symbol.selectionRange.startLineNumber;
+ } else {
+ return res;
+ }
+ }
+};
+StickyModelFromCandidateOutlineProvider = __decorate117([
+ __param111(1, ILanguageFeaturesService)
+], StickyModelFromCandidateOutlineProvider);
+var StickyModelFromCandidateFoldingProvider = class extends StickyModelCandidateProvider {
+ constructor(editor2) {
+ super(editor2);
+ this._foldingLimitReporter = this._register(new RangesLimitReporter(editor2));
+ }
+ createStickyModel(token, model) {
+ const foldingElement = this._fromFoldingRegions(model);
+ const textModel = this._editor.getModel();
+ return new StickyModel(textModel.uri, textModel.getVersionId(), foldingElement, void 0);
+ }
+ isModelValid(model) {
+ return model !== null;
+ }
+ _fromFoldingRegions(foldingRegions) {
+ const length = foldingRegions.length;
+ const orderedStickyElements = [];
+ const stickyOutlineElement = new StickyElement(void 0, [], void 0);
+ for (let i2 = 0; i2 < length; i2++) {
+ const parentIndex = foldingRegions.getParentIndex(i2);
+ let parentNode;
+ if (parentIndex !== -1) {
+ parentNode = orderedStickyElements[parentIndex];
+ } else {
+ parentNode = stickyOutlineElement;
+ }
+ const child = new StickyElement(new StickyRange(foldingRegions.getStartLineNumber(i2), foldingRegions.getEndLineNumber(i2) + 1), [], parentNode);
+ parentNode.children.push(child);
+ orderedStickyElements.push(child);
+ }
+ return stickyOutlineElement;
+ }
+};
+var StickyModelFromCandidateIndentationFoldingProvider = class StickyModelFromCandidateIndentationFoldingProvider2 extends StickyModelFromCandidateFoldingProvider {
+ constructor(editor2, _languageConfigurationService) {
+ super(editor2);
+ this._languageConfigurationService = _languageConfigurationService;
+ this.provider = this._register(new IndentRangeProvider(editor2.getModel(), this._languageConfigurationService, this._foldingLimitReporter));
+ }
+ async createModelFromProvider(token) {
+ return this.provider.compute(token);
+ }
+};
+StickyModelFromCandidateIndentationFoldingProvider = __decorate117([
+ __param111(1, ILanguageConfigurationService)
+], StickyModelFromCandidateIndentationFoldingProvider);
+var StickyModelFromCandidateSyntaxFoldingProvider = class StickyModelFromCandidateSyntaxFoldingProvider2 extends StickyModelFromCandidateFoldingProvider {
+ constructor(editor2, onProviderUpdate, _languageFeaturesService) {
+ super(editor2);
+ this._languageFeaturesService = _languageFeaturesService;
+ this.provider = this._register(new MutableDisposable());
+ this._register(this._languageFeaturesService.foldingRangeProvider.onDidChange(() => {
+ this._updateProvider(editor2, onProviderUpdate);
+ }));
+ this._updateProvider(editor2, onProviderUpdate);
+ }
+ _updateProvider(editor2, onProviderUpdate) {
+ const selectedProviders = FoldingController.getFoldingRangeProviders(this._languageFeaturesService, editor2.getModel());
+ if (selectedProviders.length === 0) {
+ return;
+ }
+ this.provider.value = new SyntaxRangeProvider(editor2.getModel(), selectedProviders, onProviderUpdate, this._foldingLimitReporter, void 0);
+ }
+ isProviderValid() {
+ return this.provider !== void 0;
+ }
+ async createModelFromProvider(token) {
+ return this.provider.value?.compute(token) ?? null;
+ }
+};
+StickyModelFromCandidateSyntaxFoldingProvider = __decorate117([
+ __param111(2, ILanguageFeaturesService)
+], StickyModelFromCandidateSyntaxFoldingProvider);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollProvider.js
+init_position();
+init_range();
+var __decorate118 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param112 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var StickyLineCandidate = class {
+ constructor(startLineNumber, endLineNumber, top, height) {
+ this.startLineNumber = startLineNumber;
+ this.endLineNumber = endLineNumber;
+ this.top = top;
+ this.height = height;
+ }
+};
+var StickyLineCandidateProvider = class StickyLineCandidateProvider2 extends Disposable {
+ constructor(editor2, _languageFeaturesService, _languageConfigurationService) {
+ super();
+ this._languageFeaturesService = _languageFeaturesService;
+ this._languageConfigurationService = _languageConfigurationService;
+ this._onDidChangeStickyScroll = this._register(new Emitter());
+ this.onDidChangeStickyScroll = this._onDidChangeStickyScroll.event;
+ this._model = null;
+ this._cts = null;
+ this._stickyModelProvider = null;
+ this._editor = editor2;
+ this._sessionStore = this._register(new DisposableStore());
+ this._updateSoon = this._register(new RunOnceScheduler(() => this.update(), 50));
+ this._register(this._editor.onDidChangeConfiguration((e) => {
+ if (e.hasChanged(
+ 131
+ /* EditorOption.stickyScroll */
+ )) {
+ this.readConfiguration();
+ }
+ }));
+ this.readConfiguration();
+ }
+ /**
+ * Read and apply the sticky scroll configuration.
+ */
+ readConfiguration() {
+ this._sessionStore.clear();
+ const options2 = this._editor.getOption(
+ 131
+ /* EditorOption.stickyScroll */
+ );
+ if (!options2.enabled) {
+ return;
+ }
+ this._sessionStore.add(this._editor.onDidChangeModel(() => {
+ this._model = null;
+ this.updateStickyModelProvider();
+ this._onDidChangeStickyScroll.fire();
+ this.update();
+ }));
+ this._sessionStore.add(this._editor.onDidChangeHiddenAreas(() => this.update()));
+ this._sessionStore.add(this._editor.onDidChangeModelContent(() => this._updateSoon.schedule()));
+ this._sessionStore.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(() => this.update()));
+ this._sessionStore.add(toDisposable(() => {
+ this._stickyModelProvider?.dispose();
+ this._stickyModelProvider = null;
+ }));
+ this.updateStickyModelProvider();
+ this.update();
+ }
+ /**
+ * Get the version ID of the sticky model.
+ */
+ getVersionId() {
+ return this._model?.version;
+ }
+ /**
+ * Update the sticky model provider.
+ */
+ updateStickyModelProvider() {
+ this._stickyModelProvider?.dispose();
+ this._stickyModelProvider = null;
+ if (this._editor.hasModel()) {
+ this._stickyModelProvider = new StickyModelProvider(this._editor, () => this._updateSoon.schedule(), this._languageConfigurationService, this._languageFeaturesService);
+ }
+ }
+ /**
+ * Update the sticky line candidates.
+ */
+ async update() {
+ this._cts?.dispose(true);
+ this._cts = new CancellationTokenSource();
+ await this.updateStickyModel(this._cts.token);
+ this._onDidChangeStickyScroll.fire();
+ }
+ /**
+ * Update the sticky model based on the current editor state.
+ */
+ async updateStickyModel(token) {
+ if (!this._editor.hasModel() || !this._stickyModelProvider || this._editor.getModel().isTooLargeForTokenization()) {
+ this._model = null;
+ return;
+ }
+ const model = await this._stickyModelProvider.update(token);
+ if (!token.isCancellationRequested) {
+ this._model = model;
+ }
+ }
+ /**
+ * Get sticky line candidates intersecting a given range.
+ */
+ getCandidateStickyLinesIntersecting(range2) {
+ if (!this._model?.element) {
+ return [];
+ }
+ const stickyLineCandidates = [];
+ this.getCandidateStickyLinesIntersectingFromStickyModel(range2, this._model.element, stickyLineCandidates, 0, 0, -1);
+ return this.filterHiddenRanges(stickyLineCandidates);
+ }
+ /**
+ * Get sticky line candidates intersecting a given range from the sticky model.
+ */
+ getCandidateStickyLinesIntersectingFromStickyModel(range2, outlineModel, result, depth, top, lastStartLineNumber) {
+ const textModel = this._editor.getModel();
+ if (!textModel) {
+ return;
+ }
+ if (outlineModel.children.length === 0) {
+ return;
+ }
+ let lastLine = lastStartLineNumber;
+ const childrenStartLines = [];
+ for (let i2 = 0; i2 < outlineModel.children.length; i2++) {
+ const child = outlineModel.children[i2];
+ if (child.range) {
+ childrenStartLines.push(child.range.startLineNumber);
+ }
+ }
+ const lowerBound = this.updateIndex(binarySearch(childrenStartLines, range2.startLineNumber, (a, b) => {
+ return a - b;
+ }));
+ const upperBound = this.updateIndex(binarySearch(childrenStartLines, range2.endLineNumber, (a, b) => {
+ return a - b;
+ }));
+ for (let i2 = lowerBound; i2 <= upperBound; i2++) {
+ const child = outlineModel.children[i2];
+ if (!child || !child.range) {
+ continue;
+ }
+ const { startLineNumber, endLineNumber } = child.range;
+ if (endLineNumber > startLineNumber + 1 && range2.startLineNumber <= endLineNumber + 1 && startLineNumber - 1 <= range2.endLineNumber && startLineNumber !== lastLine && textModel.isValidRange(new Range(startLineNumber, 1, endLineNumber, 1))) {
+ lastLine = startLineNumber;
+ const lineHeight = this._editor.getLineHeightForPosition(new Position(startLineNumber, 1));
+ result.push(new StickyLineCandidate(startLineNumber, endLineNumber - 1, top, lineHeight));
+ this.getCandidateStickyLinesIntersectingFromStickyModel(range2, child, result, depth + 1, top + lineHeight, startLineNumber);
+ }
+ }
+ }
+ /**
+ * Filter out sticky line candidates that are within hidden ranges.
+ */
+ filterHiddenRanges(stickyLineCandidates) {
+ const hiddenRanges = this._editor._getViewModel()?.getHiddenAreas();
+ if (!hiddenRanges) {
+ return stickyLineCandidates;
+ }
+ return stickyLineCandidates.filter((candidate) => {
+ return !hiddenRanges.some((hiddenRange) => candidate.startLineNumber >= hiddenRange.startLineNumber && candidate.endLineNumber <= hiddenRange.endLineNumber + 1);
+ });
+ }
+ /**
+ * Update the binary search index.
+ */
+ updateIndex(index) {
+ if (index === -1) {
+ return 0;
+ } else if (index < 0) {
+ return -index - 2;
+ }
+ return index;
+ }
+};
+StickyLineCandidateProvider = __decorate118([
+ __param112(1, ILanguageFeaturesService),
+ __param112(2, ILanguageConfigurationService)
+], StickyLineCandidateProvider);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/stickyScroll/browser/stickyScrollController.js
+init_instantiation();
+init_actions2();
+init_contextkey();
+init_editorContextKeys();
+init_range();
+init_position();
+init_cancellation();
+init_languageConfigurationRegistry();
+init_languageFeatureDebounce();
+init_dom();
+init_mouseEvent();
+init_event();
+init_window();
+var __decorate119 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param113 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var StickyScrollController_1;
+var StickyScrollController2 = class StickyScrollController3 extends Disposable {
+ static {
+ StickyScrollController_1 = this;
+ }
+ static {
+ this.ID = "store.contrib.stickyScrollController";
+ }
+ constructor(_editor, _contextMenuService, _languageFeaturesService, _instaService, _languageConfigurationService, _languageFeatureDebounceService, _contextKeyService) {
+ super();
+ this._editor = _editor;
+ this._contextMenuService = _contextMenuService;
+ this._languageFeaturesService = _languageFeaturesService;
+ this._instaService = _instaService;
+ this._contextKeyService = _contextKeyService;
+ this._sessionStore = new DisposableStore();
+ this._maxStickyLines = Number.MAX_SAFE_INTEGER;
+ this._candidateDefinitionsLength = -1;
+ this._focusedStickyElementIndex = -1;
+ this._enabled = false;
+ this._focused = false;
+ this._positionRevealed = false;
+ this._onMouseDown = false;
+ this._endLineNumbers = [];
+ this._mouseTarget = null;
+ this._onDidChangeStickyScrollHeight = this._register(new Emitter());
+ this.onDidChangeStickyScrollHeight = this._onDidChangeStickyScrollHeight.event;
+ this._stickyScrollWidget = new StickyScrollWidget2(this._editor);
+ this._stickyLineCandidateProvider = new StickyLineCandidateProvider(this._editor, _languageFeaturesService, _languageConfigurationService);
+ this._register(this._stickyScrollWidget);
+ this._register(this._stickyLineCandidateProvider);
+ this._widgetState = StickyScrollWidgetState.Empty;
+ const stickyScrollDomNode = this._stickyScrollWidget.getDomNode();
+ this._register(this._editor.onDidChangeLineHeight((e) => {
+ e.changes.forEach((change) => {
+ const lineNumber = change.lineNumber;
+ if (this._widgetState.startLineNumbers.includes(lineNumber)) {
+ this._renderStickyScroll(lineNumber);
+ }
+ });
+ }));
+ this._register(this._editor.onDidChangeFont((e) => {
+ e.changes.forEach((change) => {
+ const lineNumber = change.lineNumber;
+ if (this._widgetState.startLineNumbers.includes(lineNumber)) {
+ this._renderStickyScroll(lineNumber);
+ }
+ });
+ }));
+ this._register(this._editor.onDidChangeConfiguration((e) => {
+ this._readConfigurationChange(e);
+ }));
+ this._register(addDisposableListener(stickyScrollDomNode, EventType.CONTEXT_MENU, async (event) => {
+ this._onContextMenu(getWindow(stickyScrollDomNode), event);
+ }));
+ this._stickyScrollFocusedContextKey = EditorContextKeys.stickyScrollFocused.bindTo(this._contextKeyService);
+ this._stickyScrollVisibleContextKey = EditorContextKeys.stickyScrollVisible.bindTo(this._contextKeyService);
+ const focusTracker = this._register(trackFocus(stickyScrollDomNode));
+ this._register(focusTracker.onDidBlur((_) => {
+ if (this._positionRevealed === false && stickyScrollDomNode.clientHeight === 0) {
+ this._focusedStickyElementIndex = -1;
+ this.focus();
+ } else {
+ this._disposeFocusStickyScrollStore();
+ }
+ }));
+ this._register(focusTracker.onDidFocus((_) => {
+ this.focus();
+ }));
+ this._registerMouseListeners();
+ this._register(addDisposableListener(stickyScrollDomNode, EventType.MOUSE_DOWN, (e) => {
+ this._onMouseDown = true;
+ }));
+ this._register(this._stickyScrollWidget.onDidChangeStickyScrollHeight((e) => {
+ this._onDidChangeStickyScrollHeight.fire(e);
+ }));
+ this._onDidResize();
+ this._readConfiguration();
+ }
+ get stickyScrollWidgetHeight() {
+ return this._stickyScrollWidget.height;
+ }
+ static get(editor2) {
+ return editor2.getContribution(StickyScrollController_1.ID);
+ }
+ _disposeFocusStickyScrollStore() {
+ this._stickyScrollFocusedContextKey.set(false);
+ this._focusDisposableStore?.dispose();
+ this._focused = false;
+ this._positionRevealed = false;
+ this._onMouseDown = false;
+ }
+ isFocused() {
+ return this._focused;
+ }
+ focus() {
+ if (this._onMouseDown) {
+ this._onMouseDown = false;
+ this._editor.focus();
+ return;
+ }
+ const focusState = this._stickyScrollFocusedContextKey.get();
+ if (focusState === true) {
+ return;
+ }
+ this._focused = true;
+ this._focusDisposableStore = new DisposableStore();
+ this._stickyScrollFocusedContextKey.set(true);
+ this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumbers.length - 1;
+ this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
+ }
+ focusNext() {
+ if (this._focusedStickyElementIndex < this._stickyScrollWidget.lineNumberCount - 1) {
+ this._focusNav(true);
+ }
+ }
+ focusPrevious() {
+ if (this._focusedStickyElementIndex > 0) {
+ this._focusNav(false);
+ }
+ }
+ selectEditor() {
+ this._editor.focus();
+ }
+ // True is next, false is previous
+ _focusNav(direction) {
+ this._focusedStickyElementIndex = direction ? this._focusedStickyElementIndex + 1 : this._focusedStickyElementIndex - 1;
+ this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
+ }
+ goToFocused() {
+ const lineNumbers = this._stickyScrollWidget.lineNumbers;
+ this._disposeFocusStickyScrollStore();
+ this._revealPosition({ lineNumber: lineNumbers[this._focusedStickyElementIndex], column: 1 });
+ }
+ _revealPosition(position) {
+ this._reveaInEditor(position, () => this._editor.revealPosition(position));
+ }
+ _revealLineInCenterIfOutsideViewport(position) {
+ this._reveaInEditor(position, () => this._editor.revealLineInCenterIfOutsideViewport(
+ position.lineNumber,
+ 0
+ /* ScrollType.Smooth */
+ ));
+ }
+ _reveaInEditor(position, revealFunction) {
+ if (this._focused) {
+ this._disposeFocusStickyScrollStore();
+ }
+ this._positionRevealed = true;
+ revealFunction();
+ this._editor.setSelection(Range.fromPositions(position));
+ this._editor.focus();
+ }
+ _registerMouseListeners() {
+ const sessionStore = this._register(new DisposableStore());
+ const gesture = this._register(new ClickLinkGesture(this._editor, {
+ extractLineNumberFromMouseEvent: (e) => {
+ const position = this._stickyScrollWidget.getEditorPositionFromNode(e.target.element);
+ return position ? position.lineNumber : 0;
+ }
+ }));
+ const getMouseEventTarget = (mouseEvent) => {
+ if (!this._editor.hasModel()) {
+ return null;
+ }
+ if (mouseEvent.target.type !== 12 || mouseEvent.target.detail !== this._stickyScrollWidget.getId()) {
+ return null;
+ }
+ const mouseTargetElement = mouseEvent.target.element;
+ if (!mouseTargetElement || mouseTargetElement.innerText !== mouseTargetElement.innerHTML) {
+ return null;
+ }
+ const position = this._stickyScrollWidget.getEditorPositionFromNode(mouseTargetElement);
+ if (!position) {
+ return null;
+ }
+ return {
+ range: new Range(position.lineNumber, position.column, position.lineNumber, position.column + mouseTargetElement.innerText.length),
+ textElement: mouseTargetElement
+ };
+ };
+ const stickyScrollWidgetDomNode = this._stickyScrollWidget.getDomNode();
+ this._register(addStandardDisposableListener(stickyScrollWidgetDomNode, EventType.CLICK, (mouseEvent) => {
+ if (mouseEvent.ctrlKey || mouseEvent.altKey || mouseEvent.metaKey) {
+ return;
+ }
+ if (!mouseEvent.leftButton) {
+ return;
+ }
+ if (mouseEvent.shiftKey) {
+ const lineIndex = this._stickyScrollWidget.getLineIndexFromChildDomNode(mouseEvent.target);
+ if (lineIndex === null) {
+ return;
+ }
+ const position2 = new Position(this._endLineNumbers[lineIndex], 1);
+ this._revealLineInCenterIfOutsideViewport(position2);
+ return;
+ }
+ const isInFoldingIconDomNode = this._stickyScrollWidget.isInFoldingIconDomNode(mouseEvent.target);
+ if (isInFoldingIconDomNode) {
+ const lineNumber = this._stickyScrollWidget.getLineNumberFromChildDomNode(mouseEvent.target);
+ this._toggleFoldingRegionForLine(lineNumber);
+ return;
+ }
+ const isInStickyLine = this._stickyScrollWidget.isInStickyLine(mouseEvent.target);
+ if (!isInStickyLine) {
+ return;
+ }
+ let position = this._stickyScrollWidget.getEditorPositionFromNode(mouseEvent.target);
+ if (!position) {
+ const lineNumber = this._stickyScrollWidget.getLineNumberFromChildDomNode(mouseEvent.target);
+ if (lineNumber === null) {
+ return;
+ }
+ position = new Position(lineNumber, 1);
+ }
+ this._revealPosition(position);
+ }));
+ this._register(addDisposableListener(mainWindow, EventType.MOUSE_MOVE, (mouseEvent) => {
+ this._mouseTarget = mouseEvent.target;
+ this._onMouseMoveOrKeyDown(mouseEvent);
+ }));
+ this._register(addDisposableListener(mainWindow, EventType.KEY_DOWN, (mouseEvent) => {
+ this._onMouseMoveOrKeyDown(mouseEvent);
+ }));
+ this._register(addDisposableListener(mainWindow, EventType.KEY_UP, () => {
+ if (this._showEndForLine !== void 0) {
+ this._showEndForLine = void 0;
+ this._renderStickyScroll();
+ }
+ }));
+ this._register(gesture.onMouseMoveOrRelevantKeyDown(([mouseEvent, _keyboardEvent]) => {
+ const mouseTarget = getMouseEventTarget(mouseEvent);
+ if (!mouseTarget || !mouseEvent.hasTriggerModifier || !this._editor.hasModel()) {
+ sessionStore.clear();
+ return;
+ }
+ const { range: range2, textElement } = mouseTarget;
+ if (!range2.equalsRange(this._stickyRangeProjectedOnEditor)) {
+ this._stickyRangeProjectedOnEditor = range2;
+ sessionStore.clear();
+ } else if (textElement.style.textDecoration === "underline") {
+ return;
+ }
+ const cancellationToken = new CancellationTokenSource();
+ sessionStore.add(toDisposable(() => cancellationToken.dispose(true)));
+ let currentHTMLChild;
+ getDefinitionsAtPosition(this._languageFeaturesService.definitionProvider, this._editor.getModel(), new Position(range2.startLineNumber, range2.startColumn + 1), false, cancellationToken.token).then(((candidateDefinitions) => {
+ if (cancellationToken.token.isCancellationRequested) {
+ return;
+ }
+ if (candidateDefinitions.length !== 0) {
+ this._candidateDefinitionsLength = candidateDefinitions.length;
+ const childHTML = textElement;
+ if (currentHTMLChild !== childHTML) {
+ sessionStore.clear();
+ currentHTMLChild = childHTML;
+ currentHTMLChild.style.textDecoration = "underline";
+ sessionStore.add(toDisposable(() => {
+ currentHTMLChild.style.textDecoration = "none";
+ }));
+ } else if (!currentHTMLChild) {
+ currentHTMLChild = childHTML;
+ currentHTMLChild.style.textDecoration = "underline";
+ sessionStore.add(toDisposable(() => {
+ currentHTMLChild.style.textDecoration = "none";
+ }));
+ }
+ } else {
+ sessionStore.clear();
+ }
+ }));
+ }));
+ this._register(gesture.onCancel(() => {
+ sessionStore.clear();
+ }));
+ this._register(gesture.onExecute(async (e) => {
+ if (e.target.type !== 12 || e.target.detail !== this._stickyScrollWidget.getId()) {
+ return;
+ }
+ const position = this._stickyScrollWidget.getEditorPositionFromNode(e.target.element);
+ if (!position) {
+ return;
+ }
+ if (!this._editor.hasModel() || !this._stickyRangeProjectedOnEditor) {
+ return;
+ }
+ if (this._candidateDefinitionsLength > 1) {
+ if (this._focused) {
+ this._disposeFocusStickyScrollStore();
+ }
+ this._revealPosition({ lineNumber: position.lineNumber, column: 1 });
+ }
+ this._instaService.invokeFunction(goToDefinitionWithLocation, e, this._editor, { uri: this._editor.getModel().uri, range: this._stickyRangeProjectedOnEditor });
+ }));
+ }
+ _onContextMenu(targetWindow, e) {
+ const event = new StandardMouseEvent(targetWindow, e);
+ this._contextMenuService.showContextMenu({
+ menuId: MenuId.StickyScrollContext,
+ getAnchor: () => event
+ });
+ }
+ _onMouseMoveOrKeyDown(mouseEvent) {
+ if (!mouseEvent.shiftKey) {
+ return;
+ }
+ if (!this._mouseTarget || !isHTMLElement(this._mouseTarget)) {
+ return;
+ }
+ const currentEndForLineIndex = this._stickyScrollWidget.getLineIndexFromChildDomNode(this._mouseTarget);
+ if (currentEndForLineIndex === null || this._showEndForLine === currentEndForLineIndex) {
+ return;
+ }
+ this._showEndForLine = currentEndForLineIndex;
+ this._renderStickyScroll();
+ }
+ _toggleFoldingRegionForLine(line) {
+ if (!this._foldingModel || line === null) {
+ return;
+ }
+ const stickyLine = this._stickyScrollWidget.getRenderedStickyLine(line);
+ const foldingIcon = stickyLine?.foldingIcon;
+ if (!foldingIcon) {
+ return;
+ }
+ toggleCollapseState(this._foldingModel, 1, [line]);
+ foldingIcon.isCollapsed = !foldingIcon.isCollapsed;
+ const scrollTop = (foldingIcon.isCollapsed ? this._editor.getTopForLineNumber(foldingIcon.foldingEndLine) : this._editor.getTopForLineNumber(foldingIcon.foldingStartLine)) - this._editor.getOption(
+ 75
+ /* EditorOption.lineHeight */
+ ) * stickyLine.index + 1;
+ this._editor.setScrollTop(scrollTop);
+ this._renderStickyScroll(line);
+ }
+ _readConfiguration() {
+ const options2 = this._editor.getOption(
+ 131
+ /* EditorOption.stickyScroll */
+ );
+ if (options2.enabled === false) {
+ this._editor.removeOverlayWidget(this._stickyScrollWidget);
+ this._resetState();
+ this._sessionStore.clear();
+ this._enabled = false;
+ return;
+ } else if (options2.enabled && !this._enabled) {
+ this._editor.addOverlayWidget(this._stickyScrollWidget);
+ this._sessionStore.add(this._editor.onDidScrollChange((e) => {
+ if (e.scrollTopChanged) {
+ this._showEndForLine = void 0;
+ this._renderStickyScroll();
+ }
+ }));
+ this._sessionStore.add(this._editor.onDidLayoutChange(() => this._onDidResize()));
+ this._sessionStore.add(this._editor.onDidChangeModelTokens((e) => this._onTokensChange(e)));
+ this._sessionStore.add(this._stickyLineCandidateProvider.onDidChangeStickyScroll(() => {
+ this._showEndForLine = void 0;
+ this._renderStickyScroll();
+ }));
+ this._enabled = true;
+ }
+ const lineNumberOption = this._editor.getOption(
+ 76
+ /* EditorOption.lineNumbers */
+ );
+ if (lineNumberOption.renderType === 2) {
+ this._sessionStore.add(this._editor.onDidChangeCursorPosition(() => {
+ this._showEndForLine = void 0;
+ this._renderStickyScroll(0);
+ }));
+ }
+ }
+ _readConfigurationChange(event) {
+ if (event.hasChanged(
+ 131
+ /* EditorOption.stickyScroll */
+ ) || event.hasChanged(
+ 81
+ /* EditorOption.minimap */
+ ) || event.hasChanged(
+ 75
+ /* EditorOption.lineHeight */
+ ) || event.hasChanged(
+ 126
+ /* EditorOption.showFoldingControls */
+ ) || event.hasChanged(
+ 76
+ /* EditorOption.lineNumbers */
+ )) {
+ this._readConfiguration();
+ }
+ if (event.hasChanged(
+ 76
+ /* EditorOption.lineNumbers */
+ ) || event.hasChanged(
+ 52
+ /* EditorOption.folding */
+ ) || event.hasChanged(
+ 126
+ /* EditorOption.showFoldingControls */
+ )) {
+ this._renderStickyScroll(0);
+ }
+ }
+ _needsUpdate(event) {
+ const stickyLineNumbers = this._stickyScrollWidget.getCurrentLines();
+ for (const stickyLineNumber of stickyLineNumbers) {
+ for (const range2 of event.ranges) {
+ if (stickyLineNumber >= range2.fromLineNumber && stickyLineNumber <= range2.toLineNumber) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ _onTokensChange(event) {
+ if (this._needsUpdate(event)) {
+ this._renderStickyScroll(0);
+ }
+ }
+ _onDidResize() {
+ const layoutInfo = this._editor.getLayoutInfo();
+ const theoreticalLines = layoutInfo.height / this._editor.getOption(
+ 75
+ /* EditorOption.lineHeight */
+ );
+ this._maxStickyLines = Math.round(theoreticalLines * 0.25);
+ this._renderStickyScroll(0);
+ }
+ async _renderStickyScroll(rebuildFromLine) {
+ const model = this._editor.getModel();
+ if (!model || model.isTooLargeForTokenization()) {
+ this._resetState();
+ return;
+ }
+ const nextRebuildFromLine = this._updateAndGetMinRebuildFromLine(rebuildFromLine);
+ const stickyWidgetVersion = this._stickyLineCandidateProvider.getVersionId();
+ const shouldUpdateState = stickyWidgetVersion === void 0 || stickyWidgetVersion === model.getVersionId();
+ if (shouldUpdateState) {
+ if (!this._focused) {
+ await this._updateState(nextRebuildFromLine);
+ } else {
+ if (this._focusedStickyElementIndex === -1) {
+ await this._updateState(nextRebuildFromLine);
+ this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumberCount - 1;
+ if (this._focusedStickyElementIndex !== -1) {
+ this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
+ }
+ } else {
+ const focusedStickyElementLineNumber = this._stickyScrollWidget.lineNumbers[this._focusedStickyElementIndex];
+ await this._updateState(nextRebuildFromLine);
+ if (this._stickyScrollWidget.lineNumberCount === 0) {
+ this._focusedStickyElementIndex = -1;
+ } else {
+ const previousFocusedLineNumberExists = this._stickyScrollWidget.lineNumbers.includes(focusedStickyElementLineNumber);
+ if (!previousFocusedLineNumberExists) {
+ this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumberCount - 1;
+ }
+ this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
+ }
+ }
+ }
+ }
+ }
+ _updateAndGetMinRebuildFromLine(rebuildFromLine) {
+ if (rebuildFromLine !== void 0) {
+ const minRebuildFromLineOrInfinity = this._minRebuildFromLine !== void 0 ? this._minRebuildFromLine : Infinity;
+ this._minRebuildFromLine = Math.min(rebuildFromLine, minRebuildFromLineOrInfinity);
+ }
+ return this._minRebuildFromLine;
+ }
+ async _updateState(rebuildFromLine) {
+ this._minRebuildFromLine = void 0;
+ this._foldingModel = await FoldingController.get(this._editor)?.getFoldingModel() ?? void 0;
+ this._widgetState = this.findScrollWidgetState();
+ const stickyWidgetHasLines = this._widgetState.startLineNumbers.length > 0;
+ this._stickyScrollVisibleContextKey.set(stickyWidgetHasLines);
+ this._stickyScrollWidget.setState(this._widgetState, this._foldingModel, rebuildFromLine);
+ }
+ async _resetState() {
+ this._minRebuildFromLine = void 0;
+ this._foldingModel = void 0;
+ this._widgetState = StickyScrollWidgetState.Empty;
+ this._stickyScrollVisibleContextKey.set(false);
+ this._stickyScrollWidget.setState(void 0, void 0);
+ }
+ findScrollWidgetState() {
+ const maxNumberStickyLines = Math.min(this._maxStickyLines, this._editor.getOption(
+ 131
+ /* EditorOption.stickyScroll */
+ ).maxLineCount);
+ const scrollTop = this._editor.getScrollTop();
+ let lastLineRelativePosition = 0;
+ const startLineNumbers = [];
+ const endLineNumbers = [];
+ const arrayVisibleRanges = this._editor.getVisibleRanges();
+ if (arrayVisibleRanges.length !== 0) {
+ const fullVisibleRange = new StickyRange(arrayVisibleRanges[0].startLineNumber, arrayVisibleRanges[arrayVisibleRanges.length - 1].endLineNumber);
+ const candidateRanges = this._stickyLineCandidateProvider.getCandidateStickyLinesIntersecting(fullVisibleRange);
+ for (const range2 of candidateRanges) {
+ const start = range2.startLineNumber;
+ const end = range2.endLineNumber;
+ const topOfElement = range2.top;
+ const bottomOfElement = topOfElement + range2.height;
+ const topOfBeginningLine = this._editor.getTopForLineNumber(start) - scrollTop;
+ const bottomOfEndLine = this._editor.getBottomForLineNumber(end) - scrollTop;
+ if (topOfElement > topOfBeginningLine && topOfElement <= bottomOfEndLine) {
+ startLineNumbers.push(start);
+ endLineNumbers.push(end + 1);
+ if (bottomOfElement > bottomOfEndLine) {
+ lastLineRelativePosition = bottomOfEndLine - bottomOfElement;
+ }
+ }
+ if (startLineNumbers.length === maxNumberStickyLines) {
+ break;
+ }
+ }
+ }
+ this._endLineNumbers = endLineNumbers;
+ return new StickyScrollWidgetState(startLineNumbers, endLineNumbers, lastLineRelativePosition, this._showEndForLine);
+ }
+ dispose() {
+ super.dispose();
+ this._sessionStore.dispose();
+ }
+};
+StickyScrollController2 = StickyScrollController_1 = __decorate119([
+ __param113(1, IContextMenuService),
+ __param113(2, ILanguageFeaturesService),
+ __param113(3, IInstantiationService),
+ __param113(4, ILanguageConfigurationService),
+ __param113(5, ILanguageFeatureDebounceService),
+ __param113(6, IContextKeyService)
+], StickyScrollController2);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/theme.js
+init_errors();
+init_observable();
+init_nls();
+init_colorRegistry();
+init_colorUtils();
+var originalBackgroundColor = registerColor("inlineEdit.originalBackground", transparent(diffRemoved, 0.2), localize(1220, "Background color for the original text in inline edits."), true);
+var modifiedBackgroundColor = registerColor("inlineEdit.modifiedBackground", transparent(diffInserted, 0.3), localize(1221, "Background color for the modified text in inline edits."), true);
+var originalChangedLineBackgroundColor = registerColor("inlineEdit.originalChangedLineBackground", transparent(diffRemoved, 0.8), localize(1222, "Background color for the changed lines in the original text of inline edits."), true);
+var originalChangedTextOverlayColor = registerColor("inlineEdit.originalChangedTextBackground", transparent(diffRemoved, 0.8), localize(1223, "Overlay color for the changed text in the original text of inline edits."), true);
+var modifiedChangedLineBackgroundColor = registerColor("inlineEdit.modifiedChangedLineBackground", {
+ light: transparent(diffInsertedLine, 0.7),
+ dark: transparent(diffInsertedLine, 0.7),
+ hcDark: diffInsertedLine,
+ hcLight: diffInsertedLine
+}, localize(1224, "Background color for the changed lines in the modified text of inline edits."), true);
+var modifiedChangedTextOverlayColor = registerColor("inlineEdit.modifiedChangedTextBackground", transparent(diffInserted, 0.7), localize(1225, "Overlay color for the changed text in the modified text of inline edits."), true);
+var inlineEditIndicatorPrimaryForeground = registerColor("inlineEdit.gutterIndicator.primaryForeground", buttonForeground, localize(1226, "Foreground color for the primary inline edit gutter indicator."));
+var inlineEditIndicatorPrimaryBorder = registerColor("inlineEdit.gutterIndicator.primaryBorder", buttonBackground, localize(1227, "Border color for the primary inline edit gutter indicator."));
+var inlineEditIndicatorPrimaryBackground = registerColor("inlineEdit.gutterIndicator.primaryBackground", {
+ light: transparent(inlineEditIndicatorPrimaryBorder, 0.5),
+ dark: transparent(inlineEditIndicatorPrimaryBorder, 0.4),
+ hcDark: transparent(inlineEditIndicatorPrimaryBorder, 0.4),
+ hcLight: transparent(inlineEditIndicatorPrimaryBorder, 0.5)
+}, localize(1228, "Background color for the primary inline edit gutter indicator."));
+var inlineEditIndicatorSecondaryForeground = registerColor("inlineEdit.gutterIndicator.secondaryForeground", buttonSecondaryForeground, localize(1229, "Foreground color for the secondary inline edit gutter indicator."));
+var inlineEditIndicatorSecondaryBorder = registerColor("inlineEdit.gutterIndicator.secondaryBorder", buttonSecondaryBackground, localize(1230, "Border color for the secondary inline edit gutter indicator."));
+var inlineEditIndicatorSecondaryBackground = registerColor("inlineEdit.gutterIndicator.secondaryBackground", inlineEditIndicatorSecondaryBorder, localize(1231, "Background color for the secondary inline edit gutter indicator."));
+var inlineEditIndicatorsuccessfulForeground = registerColor("inlineEdit.gutterIndicator.successfulForeground", buttonForeground, localize(1232, "Foreground color for the successful inline edit gutter indicator."));
+var inlineEditIndicatorsuccessfulBorder = registerColor("inlineEdit.gutterIndicator.successfulBorder", buttonBackground, localize(1233, "Border color for the successful inline edit gutter indicator."));
+var inlineEditIndicatorsuccessfulBackground = registerColor("inlineEdit.gutterIndicator.successfulBackground", inlineEditIndicatorsuccessfulBorder, localize(1234, "Background color for the successful inline edit gutter indicator."));
+var inlineEditIndicatorBackground = registerColor("inlineEdit.gutterIndicator.background", {
+ hcDark: transparent("tab.inactiveBackground", 0.5),
+ hcLight: transparent("tab.inactiveBackground", 0.5),
+ dark: transparent("tab.inactiveBackground", 0.5),
+ light: "#5f5f5f18"
+}, localize(1235, "Background color for the inline edit gutter indicator."));
+var originalBorder = registerColor("inlineEdit.originalBorder", {
+ light: diffRemoved,
+ dark: diffRemoved,
+ hcDark: diffRemoved,
+ hcLight: diffRemoved
+}, localize(1236, "Border color for the original text in inline edits."));
+var modifiedBorder = registerColor("inlineEdit.modifiedBorder", {
+ light: darken(diffInserted, 0.6),
+ dark: diffInserted,
+ hcDark: diffInserted,
+ hcLight: diffInserted
+}, localize(1237, "Border color for the modified text in inline edits."));
+var tabWillAcceptModifiedBorder = registerColor("inlineEdit.tabWillAcceptModifiedBorder", {
+ light: darken(modifiedBorder, 0),
+ dark: darken(modifiedBorder, 0),
+ hcDark: darken(modifiedBorder, 0),
+ hcLight: darken(modifiedBorder, 0)
+}, localize(1238, "Modified border color for the inline edits widget when tab will accept it."));
+var tabWillAcceptOriginalBorder = registerColor("inlineEdit.tabWillAcceptOriginalBorder", {
+ light: darken(originalBorder, 0),
+ dark: darken(originalBorder, 0),
+ hcDark: darken(originalBorder, 0),
+ hcLight: darken(originalBorder, 0)
+}, localize(1239, "Original border color for the inline edits widget over the original text when tab will accept it."));
+function getModifiedBorderColor(tabAction) {
+ return tabAction.map((a) => a === InlineEditTabAction.Accept ? tabWillAcceptModifiedBorder : modifiedBorder);
+}
+function getOriginalBorderColor(tabAction) {
+ return tabAction.map((a) => a === InlineEditTabAction.Accept ? tabWillAcceptOriginalBorder : originalBorder);
+}
+function getEditorBlendedColor(colorIdentifier, themeService) {
+ let color;
+ if (typeof colorIdentifier === "string") {
+ color = observeColor(colorIdentifier, themeService);
+ } else {
+ color = colorIdentifier.map((identifier, reader) => observeColor(identifier, themeService).read(reader));
+ }
+ const backgroundColor = observeColor(editorBackground, themeService);
+ return color.map((c, reader) => (
+ /** @description makeOpaque */
+ c.makeOpaque(backgroundColor.read(reader))
+ ));
+}
+function observeColor(colorIdentifier, themeService) {
+ return observableFromEventOpts({
+ owner: { observeColor: colorIdentifier },
+ equalsFn: (a, b) => a.equals(b),
+ debugName: () => `observeColor(${colorIdentifier})`
+ }, themeService.onDidColorThemeChange, () => {
+ const color = themeService.getColorTheme().getColor(colorIdentifier);
+ if (!color) {
+ throw new BugIndicatingError(`Missing color: ${colorIdentifier}`);
+ }
+ return color;
+ });
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/utils/utils.js
+init_arrays();
+init_arraysFind();
+init_observable();
+init_strings();
+init_observableCodeEditor();
+init_offsetRange();
+init_position();
+init_range();
+init_textModel();
+init_errors();
+function maxContentWidthInRange(editor2, range2, reader) {
+ editor2.layoutInfo.read(reader);
+ editor2.value.read(reader);
+ const model = editor2.model.read(reader);
+ if (!model) {
+ return 0;
+ }
+ let maxContentWidth = 0;
+ editor2.scrollTop.read(reader);
+ for (let i2 = range2.startLineNumber; i2 < range2.endLineNumberExclusive; i2++) {
+ const column = model.getLineMaxColumn(i2);
+ let lineContentWidth = editor2.editor.getOffsetForColumn(i2, column);
+ if (lineContentWidth === -1) {
+ const typicalHalfwidthCharacterWidth = editor2.editor.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).typicalHalfwidthCharacterWidth;
+ const approximation = column * typicalHalfwidthCharacterWidth;
+ lineContentWidth = approximation;
+ }
+ maxContentWidth = Math.max(maxContentWidth, lineContentWidth);
+ }
+ const lines = range2.mapToLineArray((l) => model.getLineContent(l));
+ if (maxContentWidth < 5 && lines.some((l) => l.length > 0) && model.uri.scheme !== "file") {
+ console.error("unexpected width");
+ }
+ return maxContentWidth;
+}
+function getOffsetForPos(editor2, pos, reader) {
+ editor2.layoutInfo.read(reader);
+ editor2.value.read(reader);
+ const model = editor2.model.read(reader);
+ if (!model) {
+ return 0;
+ }
+ editor2.scrollTop.read(reader);
+ const lineContentWidth = editor2.editor.getOffsetForColumn(pos.lineNumber, pos.column);
+ return lineContentWidth;
+}
+function getPrefixTrim(diffRanges, originalLinesRange, modifiedLines, editor2, reader = void 0) {
+ const textModel = editor2.getModel();
+ if (!textModel) {
+ return { prefixTrim: 0, prefixLeftOffset: 0 };
+ }
+ const replacementStart = diffRanges.map((r) => r.isSingleLine() ? r.startColumn - 1 : 0);
+ const originalIndents = originalLinesRange.mapToLineArray((line) => indentOfLine(textModel.getLineContent(line)));
+ const modifiedIndents = modifiedLines.filter((line) => line !== "").map((line) => indentOfLine(line));
+ const prefixTrim = Math.min(...replacementStart, ...originalIndents, ...modifiedIndents);
+ let prefixLeftOffset;
+ const startLineIndent = textModel.getLineIndentColumn(originalLinesRange.startLineNumber);
+ if (startLineIndent >= prefixTrim + 1) {
+ observableCodeEditor(editor2).scrollTop.read(reader);
+ prefixLeftOffset = editor2.getOffsetForColumn(originalLinesRange.startLineNumber, prefixTrim + 1);
+ } else if (modifiedLines.length > 0) {
+ prefixLeftOffset = getContentRenderWidth(modifiedLines[0].slice(0, prefixTrim), editor2, textModel);
+ } else {
+ return { prefixTrim: 0, prefixLeftOffset: 0 };
+ }
+ return { prefixTrim, prefixLeftOffset };
+}
+function getContentRenderWidth(content, editor2, textModel) {
+ const w = editor2.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).typicalHalfwidthCharacterWidth;
+ const tabSize = textModel.getOptions().tabSize * w;
+ const numTabs = content.split(" ").length - 1;
+ const numNoneTabs = content.length - numTabs;
+ return numNoneTabs * w + numTabs * tabSize;
+}
+function getEditorValidOverlayRect(editor2) {
+ const contentLeft = editor2.layoutInfoContentLeft;
+ const width2 = derived({ name: "editor.validOverlay.width" }, (r) => {
+ const hasMinimapOnTheRight = editor2.layoutInfoMinimap.read(r).minimapLeft !== 0;
+ const editorWidth = editor2.layoutInfoWidth.read(r) - contentLeft.read(r);
+ if (hasMinimapOnTheRight) {
+ const minimapAndScrollbarWidth = editor2.layoutInfoMinimap.read(r).minimapWidth + editor2.layoutInfoVerticalScrollbarWidth.read(r);
+ return editorWidth - minimapAndScrollbarWidth;
+ }
+ return editorWidth;
+ });
+ const height = derived({ name: "editor.validOverlay.height" }, (r) => editor2.layoutInfoHeight.read(r) + editor2.contentHeight.read(r));
+ return derived({ name: "editor.validOverlay" }, (r) => Rect.fromLeftTopWidthHeight(contentLeft.read(r), 0, width2.read(r), height.read(r)));
+}
+function applyEditToModifiedRangeMappings(rangeMapping, edit2) {
+ const updatedMappings = [];
+ for (const m of rangeMapping) {
+ const updatedRange = edit2.mapRange(m.modifiedRange);
+ updatedMappings.push(new RangeMapping(m.originalRange, updatedRange));
+ }
+ return updatedMappings;
+}
+function classNames(...classes2) {
+ return classes2.filter((c) => typeof c === "string").join(" ");
+}
+function offsetRangeToRange(columnOffsetRange, startPos) {
+ return new Range(startPos.lineNumber, startPos.column + columnOffsetRange.start, startPos.lineNumber, startPos.column + columnOffsetRange.endExclusive);
+}
+function getIndentationSize(line, tabSize) {
+ let currentSize = 0;
+ loop: for (let i2 = 0, len = line.length; i2 < len; i2++) {
+ switch (line.charCodeAt(i2)) {
+ case 9:
+ currentSize += tabSize;
+ break;
+ case 32:
+ currentSize++;
+ break;
+ default:
+ break loop;
+ }
+ }
+ return currentSize - currentSize % tabSize;
+}
+function indentSizeToIndentLength(line, indentSize, tabSize) {
+ let remainingSize = indentSize - indentSize % tabSize;
+ let i2 = 0;
+ for (; i2 < line.length; i2++) {
+ if (remainingSize === 0) {
+ break;
+ }
+ switch (line.charCodeAt(i2)) {
+ case 9:
+ remainingSize -= tabSize;
+ break;
+ case 32:
+ remainingSize--;
+ break;
+ default:
+ throw new BugIndicatingError("Unexpected character found while calculating indent length");
+ }
+ }
+ return i2;
+}
+function createReindentEdit(text2, range2, tabSize) {
+ const newLines = splitLines(text2);
+ const edits = [];
+ const minIndentSize = findFirstMin(range2.mapToLineArray((l) => getIndentationSize(newLines[l - 1], tabSize)), numberComparator);
+ range2.forEach((lineNumber) => {
+ const indentLength = indentSizeToIndentLength(newLines[lineNumber - 1], minIndentSize, tabSize);
+ edits.push(new TextReplacement(offsetRangeToRange(new OffsetRange(0, indentLength), new Position(lineNumber, 1)), ""));
+ });
+ return new TextEdit(edits);
+}
+var PathBuilder = class {
+ constructor() {
+ this._data = "";
+ }
+ moveTo(point) {
+ this._data += `M ${point.x} ${point.y} `;
+ return this;
+ }
+ lineTo(point) {
+ this._data += `L ${point.x} ${point.y} `;
+ return this;
+ }
+ build() {
+ return this._data;
+ }
+};
+function mapOutFalsy(obs) {
+ const nonUndefinedObs = derivedObservableWithCache(void 0, (reader, lastValue) => obs.read(reader) || lastValue);
+ return derivedOpts({
+ debugName: () => `${obs.debugName}.mapOutFalsy`
+ }, (reader) => {
+ nonUndefinedObs.read(reader);
+ const val = obs.read(reader);
+ if (!val) {
+ return void 0;
+ }
+ return nonUndefinedObs;
+ });
+}
+function rectToProps(fn, debugLocation = DebugLocation.ofCaller()) {
+ return {
+ left: derived({ name: "editor.validOverlay.left" }, (reader) => (
+ /** @description left */
+ fn(reader).left
+ ), debugLocation),
+ top: derived({ name: "editor.validOverlay.top" }, (reader) => (
+ /** @description top */
+ fn(reader).top
+ ), debugLocation),
+ width: derived({ name: "editor.validOverlay.width" }, (reader) => (
+ /** @description width */
+ fn(reader).right - fn(reader).left
+ ), debugLocation),
+ height: derived({ name: "editor.validOverlay.height" }, (reader) => (
+ /** @description height */
+ fn(reader).bottom - fn(reader).top
+ ), debugLocation)
+ };
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorMenu.js
+init_dom();
+init_iconLabels2();
+init_codicons();
+init_observable();
+init_platform();
+init_themables();
+init_nls();
+init_commands();
+init_contextkey();
+init_colorRegistry();
+var __decorate120 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param114 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var GutterIndicatorMenuContent = class GutterIndicatorMenuContent2 {
+ constructor(_model, _close, _editorObs, _contextKeyService, _keybindingService, _commandService) {
+ this._model = _model;
+ this._close = _close;
+ this._editorObs = _editorObs;
+ this._contextKeyService = _contextKeyService;
+ this._keybindingService = _keybindingService;
+ this._commandService = _commandService;
+ this._inlineEditsShowCollapsed = this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((s) => s.edits.showCollapsed);
+ }
+ toDisposableLiveElement() {
+ return this._createHoverContent().toDisposableLiveElement();
+ }
+ _createHoverContent() {
+ const activeElement = observableValue("active", void 0);
+ const createOptionArgs = (options2) => {
+ return {
+ title: options2.title,
+ icon: options2.icon,
+ keybinding: typeof options2.commandId === "string" ? this._getKeybinding(options2.commandArgs ? void 0 : options2.commandId) : derived(this, (reader) => typeof options2.commandId === "string" ? void 0 : this._getKeybinding(options2.commandArgs ? void 0 : options2.commandId.read(reader)).read(reader)),
+ isActive: activeElement.map((v) => v === options2.id),
+ onHoverChange: (v) => activeElement.set(v ? options2.id : void 0, void 0),
+ onAction: () => {
+ this._close(true);
+ return this._commandService.executeCommand(typeof options2.commandId === "string" ? options2.commandId : options2.commandId.get(), ...options2.commandArgs ?? []);
+ }
+ };
+ };
+ const title = header(this._model.displayName);
+ const gotoAndAccept = option(createOptionArgs({
+ id: "gotoAndAccept",
+ title: `${localize(1212, "Go To")} / ${localize(1213, "Accept")}`,
+ icon: Codicon.check,
+ commandId: inlineSuggestCommitId
+ }));
+ const reject = option(createOptionArgs({
+ id: "reject",
+ title: localize(1214, "Reject"),
+ icon: Codicon.close,
+ commandId: hideInlineCompletionId
+ }));
+ const extensionCommands = this._model.extensionCommands.map((c, idx) => option(createOptionArgs({
+ id: c.command.id + "_" + idx,
+ title: c.command.title,
+ icon: c.icon ?? Codicon.symbolEvent,
+ commandId: c.command.id,
+ commandArgs: c.command.arguments
+ })));
+ const toggleCollapsedMode = this._inlineEditsShowCollapsed.map((showCollapsed) => showCollapsed ? option(createOptionArgs({
+ id: "showExpanded",
+ title: localize(1215, "Show Expanded"),
+ icon: Codicon.expandAll,
+ commandId: toggleShowCollapsedId
+ })) : option(createOptionArgs({
+ id: "showCollapsed",
+ title: localize(1216, "Show Collapsed"),
+ icon: Codicon.collapseAll,
+ commandId: toggleShowCollapsedId
+ })));
+ const snooze = option(createOptionArgs({
+ id: "snooze",
+ title: localize(1217, "Snooze"),
+ icon: Codicon.bellSlash,
+ commandId: "editor.action.inlineSuggest.snooze"
+ }));
+ const settings = option(createOptionArgs({
+ id: "settings",
+ title: localize(1218, "Settings"),
+ icon: Codicon.gear,
+ commandId: "workbench.action.openSettings",
+ commandArgs: ["@tag:nextEditSuggestions"]
+ }));
+ const actions = this._model.action ? [this._model.action] : [];
+ const actionBarFooter = actions.length > 0 ? actionBar(actions.map((action) => ({
+ id: action.id,
+ label: action.title + "...",
+ enabled: true,
+ run: () => this._commandService.executeCommand(action.id, ...action.arguments ?? []),
+ class: void 0,
+ tooltip: action.tooltip ?? action.title
+ })), {
+ hoverDelegate: nativeHoverDelegate
+ /* unable to show hover inside another hover */
+ }) : void 0;
+ return hoverContent([
+ title,
+ gotoAndAccept,
+ reject,
+ toggleCollapsedMode,
+ extensionCommands.length ? separator() : void 0,
+ snooze,
+ settings,
+ ...extensionCommands,
+ actionBarFooter ? separator() : void 0,
+ actionBarFooter
+ ]);
+ }
+ _getKeybinding(commandId) {
+ if (!commandId) {
+ return constObservable(void 0);
+ }
+ return observableFromEvent(this._contextKeyService.onDidChangeContext, () => this._keybindingService.lookupKeybinding(commandId));
+ }
+};
+GutterIndicatorMenuContent = __decorate120([
+ __param114(3, IContextKeyService),
+ __param114(4, IKeybindingService),
+ __param114(5, ICommandService)
+], GutterIndicatorMenuContent);
+function hoverContent(content) {
+ return n.div({
+ class: "content",
+ style: {
+ margin: 4,
+ minWidth: 180
+ }
+ }, content);
+}
+function header(title) {
+ return n.div({
+ class: "header",
+ style: {
+ color: asCssVariable(descriptionForeground),
+ fontSize: "13px",
+ fontWeight: "600",
+ padding: "0 4px",
+ lineHeight: 28
+ }
+ }, [title]);
+}
+function option(props) {
+ return derived({ name: "inlineEdits.option" }, (_reader) => n.div({
+ class: ["monaco-menu-option", props.isActive?.map((v) => v && "active")],
+ onmouseenter: () => props.onHoverChange?.(true),
+ onmouseleave: () => props.onHoverChange?.(false),
+ onclick: props.onAction,
+ onkeydown: (e) => {
+ if (e.key === "Enter") {
+ props.onAction?.();
+ }
+ },
+ tabIndex: 0,
+ style: {
+ borderRadius: 3
+ // same as hover widget border radius
+ }
+ }, [
+ n.elem("span", {
+ style: {
+ fontSize: 16,
+ display: "flex"
+ }
+ }, [ThemeIcon.isThemeIcon(props.icon) ? renderIcon(props.icon) : props.icon.map((icon) => renderIcon(icon))]),
+ n.elem("span", {}, [props.title]),
+ n.div({
+ style: { marginLeft: "auto" },
+ ref: (elem) => {
+ const keybindingLabel = _reader.store.add(new KeybindingLabel(elem, OS, {
+ disableTitle: true,
+ ...defaultKeybindingLabelStyles,
+ keybindingLabelShadow: void 0,
+ keybindingLabelForeground: asCssVariable(descriptionForeground),
+ keybindingLabelBackground: "transparent",
+ keybindingLabelBorder: "transparent",
+ keybindingLabelBottomBorder: void 0
+ }));
+ _reader.store.add(autorun((reader) => {
+ keybindingLabel.set(props.keybinding.read(reader));
+ }));
+ }
+ })
+ ]));
+}
+function actionBar(actions, options2) {
+ return derived({ name: "inlineEdits.actionBar" }, (_reader) => n.div({
+ class: ["action-widget-action-bar"],
+ style: {
+ padding: "3px 24px"
+ }
+ }, [
+ n.div({
+ ref: (elem) => {
+ const actionBar2 = _reader.store.add(new ActionBar(elem, options2));
+ actionBar2.push(actions, { icon: false, label: true });
+ }
+ })
+ ]));
+}
+function separator() {
+ return n.div({
+ id: "inline-edit-gutter-indicator-menu-separator",
+ class: "menu-separator",
+ style: {
+ color: asCssVariable(editorActionListForeground),
+ padding: "2px 0"
+ }
+ }, n.div({
+ style: {
+ borderBottom: `1px solid ${asCssVariable(editorHoverBorder)}`
+ }
+ }));
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js
+init_assert();
+var __decorate121 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param115 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineEditsGutterIndicator = class InlineEditsGutterIndicator2 extends Disposable {
+ get model() {
+ const model = this._model.get();
+ if (!model) {
+ throw new BugIndicatingError("Inline Edit Model not available");
+ }
+ return model;
+ }
+ constructor(_editorObs, _originalRange, _verticalOffset, _model, _isHoveringOverInlineEdit, _focusIsInMenu, _hoverService, _instantiationService, _accessibilityService, themeService) {
+ super();
+ this._editorObs = _editorObs;
+ this._originalRange = _originalRange;
+ this._verticalOffset = _verticalOffset;
+ this._model = _model;
+ this._isHoveringOverInlineEdit = _isHoveringOverInlineEdit;
+ this._focusIsInMenu = _focusIsInMenu;
+ this._hoverService = _hoverService;
+ this._instantiationService = _instantiationService;
+ this._accessibilityService = _accessibilityService;
+ this._tabAction = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return InlineEditTabAction.Inactive;
+ }
+ return model.tabAction.read(reader);
+ });
+ this._hoverVisible = observableValue(this, false);
+ this.isHoverVisible = this._hoverVisible;
+ this._isHoveredOverIcon = observableValue(this, false);
+ this._isHoveredOverIconDebounced = debouncedObservable(this._isHoveredOverIcon, 100);
+ this.isHoveredOverIcon = this._isHoveredOverIconDebounced;
+ this._isHoveredOverInlineEditDebounced = debouncedObservable(this._isHoveringOverInlineEdit, 100);
+ this._gutterIndicatorStyles = this._tabAction.map(this, (v, reader) => {
+ switch (v) {
+ case InlineEditTabAction.Inactive:
+ return {
+ background: getEditorBlendedColor(inlineEditIndicatorSecondaryBackground, themeService).read(reader).toString(),
+ foreground: getEditorBlendedColor(inlineEditIndicatorSecondaryForeground, themeService).read(reader).toString(),
+ border: getEditorBlendedColor(inlineEditIndicatorSecondaryBorder, themeService).read(reader).toString()
+ };
+ case InlineEditTabAction.Jump:
+ return {
+ background: getEditorBlendedColor(inlineEditIndicatorPrimaryBackground, themeService).read(reader).toString(),
+ foreground: getEditorBlendedColor(inlineEditIndicatorPrimaryForeground, themeService).read(reader).toString(),
+ border: getEditorBlendedColor(inlineEditIndicatorPrimaryBorder, themeService).read(reader).toString()
+ };
+ case InlineEditTabAction.Accept:
+ return {
+ background: getEditorBlendedColor(inlineEditIndicatorsuccessfulBackground, themeService).read(reader).toString(),
+ foreground: getEditorBlendedColor(inlineEditIndicatorsuccessfulForeground, themeService).read(reader).toString(),
+ border: getEditorBlendedColor(inlineEditIndicatorsuccessfulBorder, themeService).read(reader).toString()
+ };
+ default:
+ assertNever(v);
+ }
+ });
+ this._originalRangeObs = mapOutFalsy(this._originalRange);
+ this._state = derived(this, (reader) => {
+ const range2 = this._originalRangeObs.read(reader);
+ if (!range2) {
+ return void 0;
+ }
+ return {
+ range: range2,
+ lineOffsetRange: this._editorObs.observeLineOffsetRange(range2, reader.store)
+ };
+ });
+ this._stickyScrollController = StickyScrollController2.get(this._editorObs.editor);
+ this._stickyScrollHeight = this._stickyScrollController ? observableFromEvent(this._stickyScrollController.onDidChangeStickyScrollHeight, () => this._stickyScrollController.stickyScrollWidgetHeight) : constObservable(0);
+ this._lineNumberToRender = derived(this, (reader) => {
+ if (this._verticalOffset.read(reader) !== 0) {
+ return "";
+ }
+ const lineNumber = this._originalRange.read(reader)?.startLineNumber;
+ const lineNumberOptions = this._editorObs.getOption(
+ 76
+ /* EditorOption.lineNumbers */
+ ).read(reader);
+ if (lineNumber === void 0 || lineNumberOptions.renderType === 0) {
+ return "";
+ }
+ if (lineNumberOptions.renderType === 3) {
+ const cursorPosition = this._editorObs.cursorPosition.read(reader);
+ if (lineNumber % 10 === 0 || cursorPosition && cursorPosition.lineNumber === lineNumber) {
+ return lineNumber.toString();
+ }
+ return "";
+ }
+ if (lineNumberOptions.renderType === 2) {
+ const cursorPosition = this._editorObs.cursorPosition.read(reader);
+ if (!cursorPosition) {
+ return "";
+ }
+ const relativeLineNumber = Math.abs(lineNumber - cursorPosition.lineNumber);
+ if (relativeLineNumber === 0) {
+ return lineNumber.toString();
+ }
+ return relativeLineNumber.toString();
+ }
+ if (lineNumberOptions.renderType === 4) {
+ if (lineNumberOptions.renderFn) {
+ return lineNumberOptions.renderFn(lineNumber);
+ }
+ return "";
+ }
+ return lineNumber.toString();
+ });
+ this._availableWidthForIcon = derived(this, (reader) => {
+ const textModel = this._editorObs.editor.getModel();
+ const editor2 = this._editorObs.editor;
+ const layout2 = this._editorObs.layoutInfo.read(reader);
+ const gutterWidth = layout2.decorationsLeft + layout2.decorationsWidth - layout2.glyphMarginLeft;
+ if (!textModel || gutterWidth <= 0) {
+ return () => 0;
+ }
+ if (layout2.lineNumbersLeft === 0) {
+ return () => gutterWidth;
+ }
+ const lineNumberOptions = this._editorObs.getOption(
+ 76
+ /* EditorOption.lineNumbers */
+ ).read(reader);
+ if (lineNumberOptions.renderType === 2 || /* likely to flicker */
+ lineNumberOptions.renderType === 0) {
+ return () => gutterWidth;
+ }
+ const w = editor2.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).typicalHalfwidthCharacterWidth;
+ const rightOfLineNumber = layout2.lineNumbersLeft + layout2.lineNumbersWidth;
+ const totalLines = textModel.getLineCount();
+ const totalLinesDigits = (totalLines + 1).toString().length;
+ const offsetDigits = [];
+ for (let digits = 1; digits <= totalLinesDigits; digits++) {
+ const firstLineNumberWithDigitCount = 10 ** (digits - 1);
+ const topOfLineNumber = editor2.getTopForLineNumber(firstLineNumberWithDigitCount);
+ const digitsWidth = digits * w;
+ const usableWidthLeftOfLineNumber = Math.min(gutterWidth, Math.max(0, rightOfLineNumber - digitsWidth - layout2.glyphMarginLeft));
+ offsetDigits.push({ firstLineNumberWithDigitCount, topOfLineNumber, usableWidthLeftOfLineNumber });
+ }
+ return (topOffset) => {
+ for (let i2 = offsetDigits.length - 1; i2 >= 0; i2--) {
+ if (topOffset >= offsetDigits[i2].topOfLineNumber) {
+ return offsetDigits[i2].usableWidthLeftOfLineNumber;
+ }
+ }
+ throw new BugIndicatingError("Could not find avilable width for icon");
+ };
+ });
+ this._layout = derived(this, (reader) => {
+ const s = this._state.read(reader);
+ if (!s) {
+ return void 0;
+ }
+ const layout2 = this._editorObs.layoutInfo.read(reader);
+ const lineHeight = this._editorObs.observeLineHeightForLine(s.range.map((r) => r.startLineNumber)).read(reader);
+ const gutterViewPortPadding = 2;
+ const gutterWidthWithoutPadding = layout2.decorationsLeft + layout2.decorationsWidth - layout2.glyphMarginLeft - 2 * gutterViewPortPadding;
+ const gutterHeightWithoutPadding = layout2.height - 2 * gutterViewPortPadding;
+ const gutterViewPortWithStickyScroll = Rect.fromLeftTopWidthHeight(gutterViewPortPadding, gutterViewPortPadding, gutterWidthWithoutPadding, gutterHeightWithoutPadding);
+ const gutterViewPortWithoutStickyScrollWithoutPaddingTop = gutterViewPortWithStickyScroll.withTop(this._stickyScrollHeight.read(reader));
+ const gutterViewPortWithoutStickyScroll = gutterViewPortWithStickyScroll.withTop(gutterViewPortWithoutStickyScrollWithoutPaddingTop.top + gutterViewPortPadding);
+ const verticalEditRange = s.lineOffsetRange.read(reader);
+ const gutterEditArea = Rect.fromRanges(OffsetRange.fromTo(gutterViewPortWithoutStickyScroll.left, gutterViewPortWithoutStickyScroll.right), verticalEditRange);
+ const pillHeight = lineHeight;
+ const pillOffset = this._verticalOffset.read(reader);
+ const pillFullyDockedRect = gutterEditArea.withHeight(pillHeight).translateY(pillOffset);
+ const pillIsFullyDocked = gutterViewPortWithoutStickyScrollWithoutPaddingTop.containsRect(pillFullyDockedRect);
+ const iconNoneDocked = this._tabAction.map((action) => action === InlineEditTabAction.Accept ? Codicon.keyboardTab : Codicon.arrowRight);
+ const iconDocked = derived(this, (reader2) => {
+ if (this._isHoveredOverIconDebounced.read(reader2) || this._isHoveredOverInlineEditDebounced.read(reader2)) {
+ return Codicon.check;
+ }
+ if (this._tabAction.read(reader2) === InlineEditTabAction.Accept) {
+ return Codicon.keyboardTab;
+ }
+ const cursorLineNumber = this._editorObs.cursorLineNumber.read(reader2) ?? 0;
+ const editStartLineNumber = s.range.read(reader2).startLineNumber;
+ return cursorLineNumber <= editStartLineNumber ? Codicon.keyboardTabAbove : Codicon.keyboardTabBelow;
+ });
+ const idealIconWidth = 22;
+ const minimalIconWidth = 16;
+ const iconWidth = (pillRect2) => {
+ const availableWidth = this._availableWidthForIcon.read(void 0)(pillRect2.bottom + this._editorObs.editor.getScrollTop()) - gutterViewPortPadding;
+ return Math.max(Math.min(availableWidth, idealIconWidth), minimalIconWidth);
+ };
+ if (pillIsFullyDocked) {
+ const pillRect2 = pillFullyDockedRect;
+ let lineNumberWidth;
+ if (layout2.lineNumbersWidth === 0) {
+ lineNumberWidth = Math.min(Math.max(layout2.lineNumbersLeft - gutterViewPortWithStickyScroll.left, 0), pillRect2.width - idealIconWidth);
+ } else {
+ lineNumberWidth = Math.max(layout2.lineNumbersLeft + layout2.lineNumbersWidth - gutterViewPortWithStickyScroll.left, 0);
+ }
+ const lineNumberRect = pillRect2.withWidth(lineNumberWidth);
+ const iconWidth2 = Math.max(Math.min(layout2.decorationsWidth, idealIconWidth), minimalIconWidth);
+ const iconRect2 = pillRect2.withWidth(iconWidth2).translateX(lineNumberWidth);
+ return {
+ gutterEditArea,
+ icon: iconDocked,
+ iconDirection: "right",
+ iconRect: iconRect2,
+ pillRect: pillRect2,
+ lineNumberRect
+ };
+ }
+ const pillPartiallyDockedPossibleArea = gutterViewPortWithStickyScroll.intersect(gutterEditArea);
+ const pillIsPartiallyDocked = pillPartiallyDockedPossibleArea && pillPartiallyDockedPossibleArea.height >= pillHeight;
+ if (pillIsPartiallyDocked) {
+ const pillRectMoved2 = pillFullyDockedRect.moveToBeContainedIn(gutterViewPortWithoutStickyScroll).moveToBeContainedIn(pillPartiallyDockedPossibleArea);
+ const pillRect2 = pillRectMoved2.withWidth(iconWidth(pillRectMoved2));
+ const iconRect2 = pillRect2;
+ return {
+ gutterEditArea,
+ icon: iconDocked,
+ iconDirection: "right",
+ iconRect: iconRect2,
+ pillRect: pillRect2
+ };
+ }
+ const pillRectMoved = pillFullyDockedRect.moveToBeContainedIn(gutterViewPortWithStickyScroll);
+ const pillRect = pillRectMoved.withWidth(iconWidth(pillRectMoved));
+ const iconRect = pillRect;
+ const iconDirection = pillRect.top < pillFullyDockedRect.top ? "top" : "bottom";
+ return {
+ gutterEditArea,
+ icon: iconNoneDocked,
+ iconDirection,
+ iconRect,
+ pillRect
+ };
+ });
+ this._iconRef = n.ref();
+ this.isVisible = this._layout.map((l) => !!l);
+ this._indicator = n.div({
+ class: "inline-edits-view-gutter-indicator",
+ onclick: () => {
+ const layout2 = this._layout.get();
+ const acceptOnClick = layout2?.icon.get() === Codicon.check;
+ this._editorObs.editor.focus();
+ if (acceptOnClick) {
+ this.model.accept();
+ } else {
+ this.model.jump();
+ }
+ },
+ tabIndex: 0,
+ style: {
+ position: "absolute",
+ overflow: "visible"
+ }
+ }, mapOutFalsy(this._layout).map((layout2) => !layout2 ? [] : [
+ n.div({
+ style: {
+ position: "absolute",
+ background: asCssVariable(inlineEditIndicatorBackground),
+ borderRadius: "4px",
+ ...rectToProps((reader) => layout2.read(reader).gutterEditArea)
+ }
+ }),
+ n.div({
+ class: "icon",
+ ref: this._iconRef,
+ onmouseenter: () => {
+ this._showHover();
+ },
+ style: {
+ cursor: "pointer",
+ zIndex: "20",
+ position: "absolute",
+ backgroundColor: this._gutterIndicatorStyles.map((v) => v.background),
+ // eslint-disable-next-line local/code-no-any-casts
+ ["--vscodeIconForeground"]: this._gutterIndicatorStyles.map((v) => v.foreground),
+ border: this._gutterIndicatorStyles.map((v) => `1px solid ${v.border}`),
+ boxSizing: "border-box",
+ borderRadius: "4px",
+ display: "flex",
+ justifyContent: "flex-end",
+ transition: "background-color 0.2s ease-in-out, width 0.2s ease-in-out",
+ ...rectToProps((reader) => layout2.read(reader).pillRect)
+ }
+ }, [
+ n.div({
+ className: "line-number",
+ style: {
+ lineHeight: layout2.map((l) => l.lineNumberRect ? l.lineNumberRect.height : 0),
+ display: layout2.map((l) => l.lineNumberRect ? "flex" : "none"),
+ alignItems: "center",
+ justifyContent: "flex-end",
+ width: layout2.map((l) => l.lineNumberRect ? l.lineNumberRect.width : 0),
+ height: "100%",
+ color: this._gutterIndicatorStyles.map((v) => v.foreground)
+ }
+ }, this._lineNumberToRender),
+ n.div({
+ style: {
+ rotate: layout2.map((l) => `${getRotationFromDirection(l.iconDirection)}deg`),
+ transition: "rotate 0.2s ease-in-out",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ height: "100%",
+ marginRight: layout2.map((l) => l.pillRect.width - l.iconRect.width - (l.lineNumberRect?.width ?? 0)),
+ width: layout2.map((l) => l.iconRect.width)
+ }
+ }, [
+ layout2.map((l, reader) => renderIcon(l.icon.read(reader)))
+ ])
+ ])
+ ])).keepUpdated(this._store);
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: this._indicator.element,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: constObservable(0)
+ }));
+ this._register(this._editorObs.editor.onMouseMove((e) => {
+ const state = this._state.get();
+ if (state === void 0) {
+ return;
+ }
+ const el = this._iconRef.element;
+ const rect = el.getBoundingClientRect();
+ const rectangularArea = Rect.fromLeftTopWidthHeight(rect.left, rect.top, rect.width, rect.height);
+ const point = new Point(e.event.posx, e.event.posy);
+ this._isHoveredOverIcon.set(rectangularArea.containsPoint(point), void 0);
+ }));
+ this._register(this._editorObs.editor.onDidScrollChange(() => {
+ this._isHoveredOverIcon.set(false, void 0);
+ }));
+ this._register(runOnChange(this._isHoveredOverInlineEditDebounced, (isHovering) => {
+ if (isHovering) {
+ this.triggerAnimation();
+ }
+ }));
+ this._register(autorun((reader) => {
+ this._indicator.readEffect(reader);
+ if (this._indicator.element) {
+ this._editorObs.editor.applyFontInfo(this._indicator.element);
+ }
+ }));
+ }
+ triggerAnimation() {
+ if (this._accessibilityService.isMotionReduced()) {
+ return new Animation(null, null).finished;
+ }
+ const animation = this._iconRef.element.animate([
+ {
+ outline: `2px solid ${this._gutterIndicatorStyles.map((v) => v.border).get()}`,
+ outlineOffset: "-1px",
+ offset: 0
+ },
+ {
+ outline: `2px solid transparent`,
+ outlineOffset: "10px",
+ offset: 1
+ }
+ ], { duration: 500 });
+ return animation.finished;
+ }
+ _showHover() {
+ if (this._hoverVisible.get()) {
+ return;
+ }
+ const disposableStore = new DisposableStore();
+ const content = disposableStore.add(this._instantiationService.createInstance(GutterIndicatorMenuContent, this.model, (focusEditor) => {
+ if (focusEditor) {
+ this._editorObs.editor.focus();
+ }
+ h2?.dispose();
+ }, this._editorObs).toDisposableLiveElement());
+ const focusTracker = disposableStore.add(trackFocus(content.element));
+ disposableStore.add(focusTracker.onDidBlur(() => this._focusIsInMenu.set(false, void 0)));
+ disposableStore.add(focusTracker.onDidFocus(() => this._focusIsInMenu.set(true, void 0)));
+ disposableStore.add(toDisposable(() => this._focusIsInMenu.set(false, void 0)));
+ const h2 = this._hoverService.showInstantHover({
+ target: this._iconRef.element,
+ content: content.element
+ });
+ if (h2) {
+ this._hoverVisible.set(true, void 0);
+ disposableStore.add(this._editorObs.editor.onDidScrollChange(() => h2.dispose()));
+ disposableStore.add(h2.onDispose(() => {
+ this._hoverVisible.set(false, void 0);
+ disposableStore.dispose();
+ }));
+ } else {
+ disposableStore.dispose();
+ }
+ }
+};
+InlineEditsGutterIndicator = __decorate121([
+ __param115(6, IHoverService),
+ __param115(7, IInstantiationService),
+ __param115(8, IAccessibilityService),
+ __param115(9, IThemeService)
+], InlineEditsGutterIndicator);
+function getRotationFromDirection(direction) {
+ switch (direction) {
+ case "top":
+ return 90;
+ case "bottom":
+ return -90;
+ case "right":
+ return 0;
+ }
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsNewUsers.js
+init_async();
+init_errors();
+init_lifecycle();
+init_observable();
+init_configuration();
+var __decorate122 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param116 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var UserKind;
+(function(UserKind2) {
+ UserKind2["FirstTime"] = "firstTime";
+ UserKind2["SecondTime"] = "secondTime";
+ UserKind2["Active"] = "active";
+})(UserKind || (UserKind = {}));
+var InlineEditsOnboardingExperience = class InlineEditsOnboardingExperience2 extends Disposable {
+ constructor(_host, _model, _indicator, _collapsedView, _storageService, _configurationService) {
+ super();
+ this._host = _host;
+ this._model = _model;
+ this._indicator = _indicator;
+ this._collapsedView = _collapsedView;
+ this._storageService = _storageService;
+ this._configurationService = _configurationService;
+ this._disposables = this._register(new MutableDisposable());
+ this._setupDone = observableValue({ name: "setupDone" }, false);
+ this._activeCompletionId = derived((reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return void 0;
+ }
+ if (!this._setupDone.read(reader)) {
+ return void 0;
+ }
+ const indicator = this._indicator.read(reader);
+ if (!indicator || !indicator.isVisible.read(reader)) {
+ return void 0;
+ }
+ return model.inlineEdit.inlineCompletion.identity.id;
+ });
+ this._register(this._initializeDebugSetting());
+ this._disposables.value = this.setupNewUserExperience();
+ this._setupDone.set(true, void 0);
+ }
+ setupNewUserExperience() {
+ if (this.getNewUserType() === UserKind.Active) {
+ return void 0;
+ }
+ const disposableStore = new DisposableStore();
+ let userHasHoveredOverIcon = false;
+ let inlineEditHasBeenAccepted = false;
+ let firstTimeUserAnimationCount = 0;
+ let secondTimeUserAnimationCount = 0;
+ disposableStore.add(runOnChangeWithCancellationToken(this._activeCompletionId, async (id, _, __, token) => {
+ if (id === void 0) {
+ return;
+ }
+ let userType = this.getNewUserType();
+ switch (userType) {
+ case UserKind.FirstTime: {
+ if (firstTimeUserAnimationCount++ >= 5 || userHasHoveredOverIcon) {
+ userType = UserKind.SecondTime;
+ this.setNewUserType(userType);
+ }
+ break;
+ }
+ case UserKind.SecondTime: {
+ if (secondTimeUserAnimationCount++ >= 3 && inlineEditHasBeenAccepted) {
+ userType = UserKind.Active;
+ this.setNewUserType(userType);
+ }
+ break;
+ }
+ }
+ switch (userType) {
+ case UserKind.FirstTime: {
+ for (let i2 = 0; i2 < 3 && !token.isCancellationRequested; i2++) {
+ await this._indicator.get()?.triggerAnimation();
+ await timeout(500);
+ }
+ break;
+ }
+ case UserKind.SecondTime: {
+ this._indicator.get()?.triggerAnimation();
+ break;
+ }
+ }
+ }));
+ disposableStore.add(autorun((reader) => {
+ if (this._collapsedView.isVisible.read(reader)) {
+ if (this.getNewUserType() !== UserKind.Active) {
+ this._collapsedView.triggerAnimation();
+ }
+ }
+ }));
+ disposableStore.add(autorunWithStore((reader, store) => {
+ const indicator = this._indicator.read(reader);
+ if (!indicator) {
+ return;
+ }
+ store.add(runOnChange(indicator.isHoveredOverIcon, async (isHovered) => {
+ if (isHovered) {
+ userHasHoveredOverIcon = true;
+ }
+ }));
+ }));
+ disposableStore.add(autorunWithStore((reader, store) => {
+ const host = this._host.read(reader);
+ if (!host) {
+ return;
+ }
+ store.add(host.onDidAccept(() => {
+ inlineEditHasBeenAccepted = true;
+ }));
+ }));
+ return disposableStore;
+ }
+ getNewUserType() {
+ return this._storageService.get("inlineEditsGutterIndicatorUserKind", -1, UserKind.FirstTime);
+ }
+ setNewUserType(value) {
+ switch (value) {
+ case UserKind.FirstTime:
+ throw new BugIndicatingError("UserKind should not be set to first time");
+ case UserKind.SecondTime:
+ break;
+ case UserKind.Active:
+ this._disposables.clear();
+ break;
+ }
+ this._storageService.store(
+ "inlineEditsGutterIndicatorUserKind",
+ value,
+ -1,
+ 0
+ /* StorageTarget.USER */
+ );
+ }
+ _initializeDebugSetting() {
+ const hiddenDebugSetting = "editor.inlineSuggest.edits.resetNewUserExperience";
+ if (this._configurationService.getValue(hiddenDebugSetting)) {
+ this._storageService.remove(
+ "inlineEditsGutterIndicatorUserKind",
+ -1
+ /* StorageScope.APPLICATION */
+ );
+ }
+ const disposable = this._configurationService.onDidChangeConfiguration((e) => {
+ if (e.affectsConfiguration(hiddenDebugSetting) && this._configurationService.getValue(hiddenDebugSetting)) {
+ this._storageService.remove(
+ "inlineEditsGutterIndicatorUserKind",
+ -1
+ /* StorageScope.APPLICATION */
+ );
+ this._disposables.value = this.setupNewUserExperience();
+ }
+ });
+ return disposable;
+ }
+};
+InlineEditsOnboardingExperience = __decorate122([
+ __param116(4, IStorageService),
+ __param116(5, IConfigurationService)
+], InlineEditsOnboardingExperience);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsCollapsedView.js
+init_dom();
+init_event();
+init_lifecycle();
+init_observable();
+init_colorUtils();
+init_observableCodeEditor();
+init_point();
+var __decorate123 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param117 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineEditsCollapsedView = class InlineEditsCollapsedView2 extends Disposable {
+ constructor(_editor, _edit, _accessibilityService) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._accessibilityService = _accessibilityService;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._iconRef = n.ref();
+ this.isHovered = constObservable(false);
+ this._editorObs = observableCodeEditor(this._editor);
+ const firstEdit = this._edit.map((inlineEdit) => inlineEdit?.edit.replacements[0] ?? null);
+ const startPosition = firstEdit.map((edit2) => edit2 ? singleTextRemoveCommonPrefix(edit2, this._editor.getModel()).range.getStartPosition() : null);
+ const observedStartPoint = this._editorObs.observePosition(startPosition, this._store);
+ const startPoint = derived((reader) => {
+ const point = observedStartPoint.read(reader);
+ if (!point) {
+ return null;
+ }
+ const contentLeft = this._editorObs.layoutInfoContentLeft.read(reader);
+ const scrollLeft = this._editorObs.scrollLeft.read(reader);
+ return new Point(contentLeft + point.x - scrollLeft, point.y);
+ });
+ const overlayElement = n.div({
+ class: "inline-edits-collapsed-view",
+ style: {
+ position: "absolute",
+ overflow: "visible",
+ top: "0px",
+ left: "0px",
+ display: "block"
+ }
+ }, [
+ [this.getCollapsedIndicator(startPoint)]
+ ]).keepUpdated(this._store).element;
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: overlayElement,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: constObservable(0)
+ }));
+ this.isVisible = this._edit.map((inlineEdit, reader) => !!inlineEdit && startPoint.read(reader) !== null);
+ }
+ triggerAnimation() {
+ if (this._accessibilityService.isMotionReduced()) {
+ return new Animation(null, null).finished;
+ }
+ const animation = this._iconRef.element.animate([
+ { offset: 0, transform: "translateY(-3px)" },
+ { offset: 0.2, transform: "translateY(1px)" },
+ { offset: 0.36, transform: "translateY(-1px)" },
+ { offset: 0.52, transform: "translateY(1px)" },
+ { offset: 0.68, transform: "translateY(-1px)" },
+ { offset: 0.84, transform: "translateY(1px)" },
+ { offset: 1, transform: "translateY(0px)" }
+ ], { duration: 2e3 });
+ return animation.finished;
+ }
+ getCollapsedIndicator(startPoint) {
+ const contentLeft = this._editorObs.layoutInfoContentLeft;
+ const startPointTranslated = startPoint.map((p, reader) => p ? p.deltaX(-contentLeft.read(reader)) : null);
+ const iconPath = this.createIconPath(startPointTranslated);
+ return n.svg({
+ class: "collapsedView",
+ ref: this._iconRef,
+ style: {
+ position: "absolute",
+ ...rectToProps((r) => getEditorValidOverlayRect(this._editorObs).read(r)),
+ overflow: "hidden",
+ pointerEvents: "none"
+ }
+ }, [
+ n.svgElem("path", {
+ class: "collapsedViewPath",
+ d: iconPath,
+ fill: asCssVariable(inlineEditIndicatorPrimaryBorder)
+ })
+ ]);
+ }
+ createIconPath(indicatorPoint) {
+ const width2 = 6;
+ const triangleHeight = 3;
+ const baseHeight = 1;
+ return indicatorPoint.map((point) => {
+ if (!point) {
+ return new PathBuilder().build();
+ }
+ const baseTopLeft = point.deltaX(-width2 / 2).deltaY(-baseHeight);
+ const baseTopRight = baseTopLeft.deltaX(width2);
+ const baseBottomLeft = baseTopLeft.deltaY(baseHeight);
+ const baseBottomRight = baseTopRight.deltaY(baseHeight);
+ const triangleBottomCenter = baseBottomLeft.deltaX(width2 / 2).deltaY(triangleHeight);
+ return new PathBuilder().moveTo(baseTopLeft).lineTo(baseTopRight).lineTo(baseBottomRight).lineTo(triangleBottomCenter).lineTo(baseBottomLeft).lineTo(baseTopLeft).build();
+ });
+ }
+};
+InlineEditsCollapsedView = __decorate123([
+ __param117(2, IAccessibilityService)
+], InlineEditsCollapsedView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsCustomView.js
+init_dom();
+init_mouseEvent();
+init_event();
+init_lifecycle();
+init_observable();
+init_colorRegistry();
+init_colorUtils();
+init_themeService();
+init_observableCodeEditor();
+init_lineRange();
+init_languages();
+init_language();
+init_lineTokens();
+var __decorate124 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param118 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var MIN_END_OF_LINE_PADDING = 14;
+var PADDING_VERTICALLY = 0;
+var PADDING_HORIZONTALLY = 4;
+var HORIZONTAL_OFFSET_WHEN_ABOVE_BELOW = 4;
+var VERTICAL_OFFSET_WHEN_ABOVE_BELOW = 2;
+var InlineEditsCustomView = class InlineEditsCustomView2 extends Disposable {
+ constructor(_editor, displayLocation, tabAction, themeService, _languageService) {
+ super();
+ this._editor = _editor;
+ this._languageService = _languageService;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._isHovered = observableValue(this, false);
+ this.isHovered = this._isHovered;
+ this._viewRef = n.ref();
+ this._editorObs = observableCodeEditor(this._editor);
+ const styles = tabAction.map((v, reader) => {
+ let border;
+ switch (v) {
+ case InlineEditTabAction.Inactive:
+ border = inlineEditIndicatorSecondaryBackground;
+ break;
+ case InlineEditTabAction.Jump:
+ border = inlineEditIndicatorPrimaryBackground;
+ break;
+ case InlineEditTabAction.Accept:
+ border = inlineEditIndicatorsuccessfulBackground;
+ break;
+ }
+ return {
+ border: getEditorBlendedColor(border, themeService).read(reader).toString(),
+ background: asCssVariable(editorBackground)
+ };
+ });
+ const state = displayLocation.map((dl) => dl ? this.getState(dl) : void 0);
+ const view = state.map((s) => s ? this.getRendering(s, styles) : void 0);
+ this.minEditorScrollHeight = derived(this, (reader) => {
+ const s = state.read(reader);
+ if (!s) {
+ return 0;
+ }
+ return s.rect.read(reader).bottom + this._editor.getScrollTop();
+ });
+ const overlay = n.div({
+ class: "inline-edits-custom-view",
+ style: {
+ position: "absolute",
+ overflow: "visible",
+ top: "0px",
+ left: "0px",
+ display: "block"
+ }
+ }, [view]).keepUpdated(this._store);
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: overlay.element,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: derivedObservableWithCache(this, (reader, prev) => {
+ const s = state.read(reader);
+ if (!s) {
+ return prev ?? 0;
+ }
+ const current = s.rect.map((rect) => rect.right).read(reader) + this._editorObs.layoutInfoVerticalScrollbarWidth.read(reader) + PADDING_HORIZONTALLY - this._editorObs.layoutInfoContentLeft.read(reader);
+ return Math.max(prev ?? 0, current);
+ }).recomputeInitiallyAndOnChange(this._store)
+ }));
+ this._register(autorun((reader) => {
+ const v = view.read(reader);
+ if (!v) {
+ this._isHovered.set(false, void 0);
+ return;
+ }
+ this._isHovered.set(overlay.isHovered.read(reader), void 0);
+ }));
+ }
+ // TODO: this is very similar to side by side `fitsInsideViewport`, try to use the same function
+ fitsInsideViewport(range2, displayLabel, reader) {
+ const editorWidth = this._editorObs.layoutInfoWidth.read(reader);
+ const editorContentLeft = this._editorObs.layoutInfoContentLeft.read(reader);
+ const editorVerticalScrollbar = this._editor.getLayoutInfo().verticalScrollbarWidth;
+ const minimapWidth = this._editorObs.layoutInfoMinimap.read(reader).minimapLeft !== 0 ? this._editorObs.layoutInfoMinimap.read(reader).minimapWidth : 0;
+ const maxOriginalContent = maxContentWidthInRange(this._editorObs, range2, void 0);
+ const maxModifiedContent = getContentRenderWidth(displayLabel, this._editor, this._editor.getModel());
+ const padding = PADDING_HORIZONTALLY + MIN_END_OF_LINE_PADDING;
+ return maxOriginalContent + maxModifiedContent + padding < editorWidth - editorContentLeft - editorVerticalScrollbar - minimapWidth;
+ }
+ getState(displayLocation) {
+ const contentState = derived(this, (reader) => {
+ const startLineNumber2 = displayLocation.range.startLineNumber;
+ const endLineNumber2 = displayLocation.range.endLineNumber;
+ const startColumn = displayLocation.range.startColumn;
+ const endColumn = displayLocation.range.endColumn;
+ const lineCount = this._editor.getModel()?.getLineCount() ?? 0;
+ const lineWidth = maxContentWidthInRange(this._editorObs, new LineRange(startLineNumber2, startLineNumber2 + 1), reader);
+ const lineWidthBelow = startLineNumber2 + 1 <= lineCount ? maxContentWidthInRange(this._editorObs, new LineRange(startLineNumber2 + 1, startLineNumber2 + 2), reader) : void 0;
+ const lineWidthAbove = startLineNumber2 - 1 >= 1 ? maxContentWidthInRange(this._editorObs, new LineRange(startLineNumber2 - 1, startLineNumber2), reader) : void 0;
+ const startContentLeftOffset = this._editor.getOffsetForColumn(startLineNumber2, startColumn);
+ const endContentLeftOffset = this._editor.getOffsetForColumn(endLineNumber2, endColumn);
+ return {
+ lineWidth,
+ lineWidthBelow,
+ lineWidthAbove,
+ startContentLeftOffset,
+ endContentLeftOffset
+ };
+ });
+ const startLineNumber = displayLocation.range.startLineNumber;
+ const endLineNumber = displayLocation.range.endLineNumber;
+ const fitsInsideViewport = this.fitsInsideViewport(new LineRange(startLineNumber, endLineNumber + 1), displayLocation.content, void 0);
+ const rect = derived(this, (reader) => {
+ const w = this._editorObs.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).read(reader).typicalHalfwidthCharacterWidth;
+ const { lineWidth, lineWidthBelow, lineWidthAbove, startContentLeftOffset, endContentLeftOffset } = contentState.read(reader);
+ const contentLeft = this._editorObs.layoutInfoContentLeft.read(reader);
+ const lineHeight = this._editorObs.observeLineHeightForLine(startLineNumber).recomputeInitiallyAndOnChange(reader.store).read(reader);
+ const scrollTop = this._editorObs.scrollTop.read(reader);
+ const scrollLeft = this._editorObs.scrollLeft.read(reader);
+ let position;
+ if (startLineNumber === endLineNumber && endContentLeftOffset + 5 * w >= lineWidth && fitsInsideViewport) {
+ position = "end";
+ } else if (lineWidthBelow !== void 0 && lineWidthBelow + MIN_END_OF_LINE_PADDING - HORIZONTAL_OFFSET_WHEN_ABOVE_BELOW - PADDING_HORIZONTALLY < startContentLeftOffset) {
+ position = "below";
+ } else if (lineWidthAbove !== void 0 && lineWidthAbove + MIN_END_OF_LINE_PADDING - HORIZONTAL_OFFSET_WHEN_ABOVE_BELOW - PADDING_HORIZONTALLY < startContentLeftOffset) {
+ position = "above";
+ } else {
+ position = "end";
+ }
+ let topOfLine;
+ let contentStartOffset;
+ let deltaX = 0;
+ let deltaY = 0;
+ switch (position) {
+ case "end": {
+ topOfLine = this._editorObs.editor.getTopForLineNumber(startLineNumber);
+ contentStartOffset = lineWidth;
+ deltaX = PADDING_HORIZONTALLY + MIN_END_OF_LINE_PADDING;
+ break;
+ }
+ case "below": {
+ topOfLine = this._editorObs.editor.getTopForLineNumber(startLineNumber + 1);
+ contentStartOffset = startContentLeftOffset;
+ deltaX = PADDING_HORIZONTALLY + HORIZONTAL_OFFSET_WHEN_ABOVE_BELOW;
+ deltaY = PADDING_VERTICALLY + VERTICAL_OFFSET_WHEN_ABOVE_BELOW;
+ break;
+ }
+ case "above": {
+ topOfLine = this._editorObs.editor.getTopForLineNumber(startLineNumber - 1);
+ contentStartOffset = startContentLeftOffset;
+ deltaX = PADDING_HORIZONTALLY + HORIZONTAL_OFFSET_WHEN_ABOVE_BELOW;
+ deltaY = -PADDING_VERTICALLY + VERTICAL_OFFSET_WHEN_ABOVE_BELOW;
+ break;
+ }
+ }
+ const textRect = Rect.fromLeftTopWidthHeight(contentLeft + contentStartOffset - scrollLeft, topOfLine - scrollTop, w * displayLocation.content.length, lineHeight);
+ return textRect.withMargin(PADDING_VERTICALLY, PADDING_HORIZONTALLY).translateX(deltaX).translateY(deltaY);
+ });
+ return {
+ rect,
+ label: displayLocation.content,
+ kind: displayLocation.style
+ };
+ }
+ getRendering(state, styles) {
+ const line = document.createElement("div");
+ const t = this._editor.getModel().tokenization.tokenizeLinesAt(1, [state.label])?.[0];
+ let tokens;
+ if (t && state.kind === InlineCompletionHintStyle.Code) {
+ tokens = TokenArray.fromLineTokens(t).toLineTokens(state.label, this._languageService.languageIdCodec);
+ } else {
+ tokens = LineTokens.createEmpty(state.label, this._languageService.languageIdCodec);
+ }
+ const result = renderLines(new LineSource([tokens]), RenderOptions.fromEditor(this._editor).withSetWidth(false).withScrollBeyondLastColumn(0), [], line, true);
+ line.style.width = `${result.minWidthInPx}px`;
+ const rect = state.rect.map((r) => r.withMargin(0, PADDING_HORIZONTALLY));
+ return n.div({
+ class: "collapsedView",
+ ref: this._viewRef,
+ style: {
+ position: "absolute",
+ ...rectToProps((reader) => rect.read(reader)),
+ overflow: "hidden",
+ boxSizing: "border-box",
+ cursor: "pointer",
+ border: styles.map((s) => `1px solid ${s.border}`),
+ borderRadius: "4px",
+ backgroundColor: styles.map((s) => s.background),
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ whiteSpace: "nowrap"
+ },
+ onmousedown: (e) => {
+ e.preventDefault();
+ },
+ onclick: (e) => {
+ this._onDidClick.fire(new StandardMouseEvent(getWindow(e), e));
+ }
+ }, [
+ line
+ ]);
+ }
+};
+InlineEditsCustomView = __decorate124([
+ __param118(3, IThemeService),
+ __param118(4, ILanguageService)
+], InlineEditsCustomView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsDeletionView.js
+init_dom();
+init_event();
+init_lifecycle();
+init_observable();
+init_colorRegistry();
+init_colorUtils();
+init_observableCodeEditor();
+init_offsetRange();
+init_position();
+var HORIZONTAL_PADDING = 0;
+var VERTICAL_PADDING = 0;
+var BORDER_WIDTH = 1;
+var WIDGET_SEPARATOR_WIDTH = 1;
+var WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH = 3;
+var BORDER_RADIUS = 4;
+var InlineEditsDeletionView = class extends Disposable {
+ constructor(_editor, _edit, _uiState, _tabAction) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._uiState = _uiState;
+ this._tabAction = _tabAction;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._display = derived(this, (reader) => !!this._uiState.read(reader) ? "block" : "none");
+ this._editorMaxContentWidthInRange = derived(this, (reader) => {
+ const originalDisplayRange = this._originalDisplayRange.read(reader);
+ if (!originalDisplayRange) {
+ return constObservable(0);
+ }
+ this._editorObs.versionId.read(reader);
+ return derivedObservableWithCache(this, (reader2, lastValue) => {
+ const maxWidth = maxContentWidthInRange(this._editorObs, originalDisplayRange, reader2);
+ return Math.max(maxWidth, lastValue ?? 0);
+ });
+ }).map((v, r) => v.read(r));
+ this._maxPrefixTrim = derived(this, (reader) => {
+ const state = this._uiState.read(reader);
+ if (!state) {
+ return { prefixTrim: 0, prefixLeftOffset: 0 };
+ }
+ return getPrefixTrim(state.deletions, state.originalRange, [], this._editor);
+ });
+ this._editorLayoutInfo = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ if (!inlineEdit) {
+ return null;
+ }
+ const state = this._uiState.read(reader);
+ if (!state) {
+ return null;
+ }
+ const editorLayout = this._editorObs.layoutInfo.read(reader);
+ const horizontalScrollOffset = this._editorObs.scrollLeft.read(reader);
+ const w = this._editorObs.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).map((f) => f.typicalHalfwidthCharacterWidth).read(reader);
+ const right = editorLayout.contentLeft + Math.max(this._editorMaxContentWidthInRange.read(reader), w) - horizontalScrollOffset;
+ const range2 = inlineEdit.originalLineRange;
+ const selectionTop = this._originalVerticalStartPosition.read(reader) ?? this._editor.getTopForLineNumber(range2.startLineNumber) - this._editorObs.scrollTop.read(reader);
+ const selectionBottom = this._originalVerticalEndPosition.read(reader) ?? this._editor.getTopForLineNumber(range2.endLineNumberExclusive) - this._editorObs.scrollTop.read(reader);
+ const left = editorLayout.contentLeft + this._maxPrefixTrim.read(reader).prefixLeftOffset - horizontalScrollOffset;
+ if (right <= left) {
+ return null;
+ }
+ const codeRect = Rect.fromLeftTopRightBottom(left, selectionTop, right, selectionBottom).withMargin(VERTICAL_PADDING, HORIZONTAL_PADDING);
+ return {
+ codeRect,
+ contentLeft: editorLayout.contentLeft
+ };
+ }).recomputeInitiallyAndOnChange(this._store);
+ this._originalOverlay = n.div({
+ style: { pointerEvents: "none" }
+ }, derived(this, (reader) => {
+ const layoutInfoObs = mapOutFalsy(this._editorLayoutInfo).read(reader);
+ if (!layoutInfoObs) {
+ return void 0;
+ }
+ const overlayhider = layoutInfoObs.map((layoutInfo) => Rect.fromLeftTopRightBottom(layoutInfo.contentLeft - BORDER_RADIUS - BORDER_WIDTH, layoutInfo.codeRect.top, layoutInfo.contentLeft, layoutInfo.codeRect.bottom));
+ const overlayRect = derived(this, (reader2) => {
+ const rect = layoutInfoObs.read(reader2).codeRect;
+ const overlayHider = overlayhider.read(reader2);
+ return rect.intersectHorizontal(new OffsetRange(overlayHider.left, Number.MAX_SAFE_INTEGER));
+ });
+ const separatorWidth = this._uiState.map((s) => s?.inDiffEditor ? WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH : WIDGET_SEPARATOR_WIDTH).read(reader);
+ const separatorRect = overlayRect.map((rect) => rect.withMargin(separatorWidth, separatorWidth));
+ return [
+ n.div({
+ class: "originalSeparatorDeletion",
+ style: {
+ ...separatorRect.read(reader).toStyles(),
+ borderRadius: `${BORDER_RADIUS}px`,
+ border: `${BORDER_WIDTH + separatorWidth}px solid ${asCssVariable(editorBackground)}`,
+ boxSizing: "border-box"
+ }
+ }),
+ n.div({
+ class: "originalOverlayDeletion",
+ style: {
+ ...overlayRect.read(reader).toStyles(),
+ borderRadius: `${BORDER_RADIUS}px`,
+ border: getOriginalBorderColor(this._tabAction).map((bc) => `${BORDER_WIDTH}px solid ${asCssVariable(bc)}`),
+ boxSizing: "border-box",
+ backgroundColor: asCssVariable(originalBackgroundColor)
+ }
+ }),
+ n.div({
+ class: "originalOverlayHiderDeletion",
+ style: {
+ ...overlayhider.read(reader).toStyles(),
+ backgroundColor: asCssVariable(editorBackground)
+ }
+ })
+ ];
+ })).keepUpdated(this._store);
+ this._nonOverflowView = n.div({
+ class: "inline-edits-view",
+ style: {
+ position: "absolute",
+ overflow: "visible",
+ top: "0px",
+ left: "0px",
+ display: this._display
+ }
+ }, [
+ [this._originalOverlay]
+ ]).keepUpdated(this._store);
+ this.isHovered = constObservable(false);
+ this._editorObs = observableCodeEditor(this._editor);
+ const originalStartPosition = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ return inlineEdit ? new Position(inlineEdit.originalLineRange.startLineNumber, 1) : null;
+ });
+ const originalEndPosition = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ return inlineEdit ? new Position(inlineEdit.originalLineRange.endLineNumberExclusive, 1) : null;
+ });
+ this._originalDisplayRange = this._uiState.map((s) => s?.originalRange);
+ this._originalVerticalStartPosition = this._editorObs.observePosition(originalStartPosition, this._store).map((p) => p?.y);
+ this._originalVerticalEndPosition = this._editorObs.observePosition(originalEndPosition, this._store).map((p) => p?.y);
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: this._nonOverflowView.element,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: derived(this, (reader) => {
+ const info = this._editorLayoutInfo.read(reader);
+ if (info === null) {
+ return 0;
+ }
+ return info.codeRect.width;
+ })
+ }));
+ }
+};
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsInsertionView.js
+init_dom();
+init_event();
+init_lifecycle();
+init_observable();
+init_instantiation();
+init_colorRegistry();
+init_colorUtils();
+init_observableCodeEditor();
+init_position();
+init_range();
+init_lineRange();
+init_offsetRange();
+init_language();
+init_lineTokens();
+var __decorate125 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param119 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var BORDER_WIDTH2 = 1;
+var WIDGET_SEPARATOR_WIDTH2 = 1;
+var WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH2 = 3;
+var BORDER_RADIUS2 = 4;
+var InlineEditsInsertionView = class InlineEditsInsertionView2 extends Disposable {
+ constructor(_editor, _input, _tabAction, instantiationService, _languageService) {
+ super();
+ this._editor = _editor;
+ this._input = _input;
+ this._tabAction = _tabAction;
+ this._languageService = _languageService;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._state = derived(this, (reader) => {
+ const state = this._input.read(reader);
+ if (!state) {
+ return void 0;
+ }
+ const textModel = this._editor.getModel();
+ const eol = textModel.getEOL();
+ if (state.startColumn === 1 && state.lineNumber > 1 && textModel.getLineLength(state.lineNumber) !== 0 && state.text.endsWith(eol) && !state.text.startsWith(eol)) {
+ const endOfLineColumn = textModel.getLineLength(state.lineNumber - 1) + 1;
+ return { lineNumber: state.lineNumber - 1, column: endOfLineColumn, text: eol + state.text.slice(0, -eol.length) };
+ }
+ return { lineNumber: state.lineNumber, column: state.startColumn, text: state.text };
+ });
+ this._trimVertically = derived(this, (reader) => {
+ const state = this._state.read(reader);
+ const text2 = state?.text;
+ if (!text2 || text2.trim() === "") {
+ return { topOffset: 0, bottomOffset: 0, linesTop: 0, linesBottom: 0 };
+ }
+ const lineHeight = this._editor.getLineHeightForPosition(new Position(state.lineNumber, 1));
+ const eol = this._editor.getModel().getEOL();
+ let linesTop = 0;
+ let linesBottom = 0;
+ let i2 = 0;
+ for (; i2 < text2.length && text2.startsWith(eol, i2); i2 += eol.length) {
+ linesTop += 1;
+ }
+ for (let j = text2.length; j > i2 && text2.endsWith(eol, j); j -= eol.length) {
+ linesBottom += 1;
+ }
+ return { topOffset: linesTop * lineHeight, bottomOffset: linesBottom * lineHeight, linesTop, linesBottom };
+ });
+ this._maxPrefixTrim = derived(this, (reader) => {
+ const state = this._state.read(reader);
+ if (!state) {
+ return { prefixLeftOffset: 0, prefixTrim: 0 };
+ }
+ const textModel = this._editor.getModel();
+ const eol = textModel.getEOL();
+ const trimVertically = this._trimVertically.read(reader);
+ const lines = state.text.split(eol);
+ const modifiedLines = lines.slice(trimVertically.linesTop, lines.length - trimVertically.linesBottom);
+ if (trimVertically.linesTop === 0) {
+ modifiedLines[0] = textModel.getLineContent(state.lineNumber) + modifiedLines[0];
+ }
+ const originalRange = new LineRange(state.lineNumber, state.lineNumber + (trimVertically.linesTop > 0 ? 0 : 1));
+ return getPrefixTrim([], originalRange, modifiedLines, this._editor);
+ });
+ this._ghostText = derived((reader) => {
+ const state = this._state.read(reader);
+ const prefixTrim = this._maxPrefixTrim.read(reader);
+ if (!state) {
+ return void 0;
+ }
+ const textModel = this._editor.getModel();
+ const eol = textModel.getEOL();
+ const modifiedLines = state.text.split(eol);
+ const inlineDecorations = modifiedLines.map((line, i2) => new InlineDecoration(
+ new Range(i2 + 1, i2 === 0 ? 1 : prefixTrim.prefixTrim + 1, i2 + 1, line.length + 1),
+ "modified-background",
+ 0
+ /* InlineDecorationType.Regular */
+ ));
+ return new GhostText(state.lineNumber, [new GhostTextPart(state.column, state.text, false, inlineDecorations)]);
+ });
+ this._display = derived(this, (reader) => !!this._state.read(reader) ? "block" : "none");
+ this._editorMaxContentWidthInRange = derived(this, (reader) => {
+ const state = this._state.read(reader);
+ if (!state) {
+ return 0;
+ }
+ this._editorObs.versionId.read(reader);
+ const textModel = this._editor.getModel();
+ const eol = textModel.getEOL();
+ const textBeforeInsertion = state.text.startsWith(eol) ? "" : textModel.getValueInRange(new Range(state.lineNumber, 1, state.lineNumber, state.column));
+ const textAfterInsertion = textModel.getValueInRange(new Range(state.lineNumber, state.column, state.lineNumber, textModel.getLineLength(state.lineNumber) + 1));
+ const text2 = textBeforeInsertion + state.text + textAfterInsertion;
+ const lines = text2.split(eol);
+ const renderOptions = RenderOptions.fromEditor(this._editor).withSetWidth(false).withScrollBeyondLastColumn(0);
+ const lineWidths = lines.map((line) => {
+ const t = textModel.tokenization.tokenizeLinesAt(state.lineNumber, [line])?.[0];
+ let tokens;
+ if (t) {
+ tokens = TokenArray.fromLineTokens(t).toLineTokens(line, this._languageService.languageIdCodec);
+ } else {
+ tokens = LineTokens.createEmpty(line, this._languageService.languageIdCodec);
+ }
+ return renderLines(new LineSource([tokens]), renderOptions, [], $("div"), true).minWidthInPx;
+ });
+ return Math.max(...lineWidths);
+ });
+ this.startLineOffset = this._trimVertically.map((v) => v.topOffset);
+ this.originalLines = this._state.map((s) => s ? new LineRange(s.lineNumber, Math.min(s.lineNumber + 2, this._editor.getModel().getLineCount() + 1)) : void 0);
+ this._overlayLayout = derived(this, (reader) => {
+ this._ghostText.read(reader);
+ const state = this._state.read(reader);
+ if (!state) {
+ return null;
+ }
+ this._editorObs.observePosition(observableValue(this, new Position(state.lineNumber, state.column)), reader.store).read(reader);
+ const editorLayout = this._editorObs.layoutInfo.read(reader);
+ const horizontalScrollOffset = this._editorObs.scrollLeft.read(reader);
+ const verticalScrollbarWidth = this._editorObs.layoutInfoVerticalScrollbarWidth.read(reader);
+ const right = editorLayout.contentLeft + this._editorMaxContentWidthInRange.read(reader) - horizontalScrollOffset;
+ const prefixLeftOffset = this._maxPrefixTrim.read(reader).prefixLeftOffset ?? 0;
+ const left = editorLayout.contentLeft + prefixLeftOffset - horizontalScrollOffset;
+ if (right <= left) {
+ return null;
+ }
+ const { topOffset: topTrim, bottomOffset: bottomTrim } = this._trimVertically.read(reader);
+ const scrollTop = this._editorObs.scrollTop.read(reader);
+ const height = this._ghostTextView.height.read(reader) - topTrim - bottomTrim;
+ const top = this._editor.getTopForLineNumber(state.lineNumber) - scrollTop + topTrim;
+ const bottom = top + height;
+ const overlay = new Rect(left, top, right, bottom);
+ return {
+ overlay,
+ startsAtContentLeft: prefixLeftOffset === 0,
+ contentLeft: editorLayout.contentLeft,
+ minContentWidthRequired: prefixLeftOffset + overlay.width + verticalScrollbarWidth
+ };
+ }).recomputeInitiallyAndOnChange(this._store);
+ this._modifiedOverlay = n.div({
+ style: { pointerEvents: "none" }
+ }, derived(this, (reader) => {
+ const overlayLayoutObs = mapOutFalsy(this._overlayLayout).read(reader);
+ if (!overlayLayoutObs) {
+ return void 0;
+ }
+ const overlayHider = overlayLayoutObs.map((layoutInfo) => Rect.fromLeftTopRightBottom(layoutInfo.contentLeft - BORDER_RADIUS2 - BORDER_WIDTH2, layoutInfo.overlay.top, layoutInfo.contentLeft, layoutInfo.overlay.bottom)).read(reader);
+ const separatorWidth = this._input.map((i2) => i2?.inDiffEditor ? WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH2 : WIDGET_SEPARATOR_WIDTH2).read(reader);
+ const overlayRect = overlayLayoutObs.map((l) => l.overlay.withMargin(0, BORDER_WIDTH2, 0, l.startsAtContentLeft ? 0 : BORDER_WIDTH2).intersectHorizontal(new OffsetRange(overlayHider.left, Number.MAX_SAFE_INTEGER)));
+ const underlayRect = overlayRect.map((rect) => rect.withMargin(separatorWidth, separatorWidth));
+ return [
+ n.div({
+ class: "originalUnderlayInsertion",
+ style: {
+ ...underlayRect.read(reader).toStyles(),
+ borderRadius: BORDER_RADIUS2,
+ border: `${BORDER_WIDTH2 + separatorWidth}px solid ${asCssVariable(editorBackground)}`,
+ boxSizing: "border-box"
+ }
+ }),
+ n.div({
+ class: "originalOverlayInsertion",
+ style: {
+ ...overlayRect.read(reader).toStyles(),
+ borderRadius: BORDER_RADIUS2,
+ border: getModifiedBorderColor(this._tabAction).map((bc) => `${BORDER_WIDTH2}px solid ${asCssVariable(bc)}`),
+ boxSizing: "border-box",
+ backgroundColor: asCssVariable(modifiedBackgroundColor)
+ }
+ }),
+ n.div({
+ class: "originalOverlayHiderInsertion",
+ style: {
+ ...overlayHider.toStyles(),
+ backgroundColor: asCssVariable(editorBackground)
+ }
+ })
+ ];
+ })).keepUpdated(this._store);
+ this._view = n.div({
+ class: "inline-edits-view",
+ style: {
+ position: "absolute",
+ overflow: "visible",
+ top: "0px",
+ left: "0px",
+ display: this._display
+ }
+ }, [
+ [this._modifiedOverlay]
+ ]).keepUpdated(this._store);
+ this._editorObs = observableCodeEditor(this._editor);
+ this._ghostTextView = this._register(instantiationService.createInstance(GhostTextView, this._editor, {
+ ghostText: this._ghostText,
+ minReservedLineCount: constObservable(0),
+ targetTextModel: this._editorObs.model.map((model) => model ?? void 0),
+ warning: constObservable(void 0),
+ handleInlineCompletionShown: constObservable(() => {
+ })
+ }, observableValue(this, { syntaxHighlightingEnabled: true, extraClasses: ["inline-edit"] }), true, true));
+ this.isHovered = this._ghostTextView.isHovered;
+ this._register(this._ghostTextView.onDidClick((e) => {
+ this._onDidClick.fire(e);
+ }));
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: this._view.element,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: derived(this, (reader) => {
+ const info = this._overlayLayout.read(reader);
+ if (info === null) {
+ return 0;
+ }
+ return info.minContentWidthRequired;
+ })
+ }));
+ }
+};
+InlineEditsInsertionView = __decorate125([
+ __param119(3, IInstantiationService),
+ __param119(4, ILanguageService)
+], InlineEditsInsertionView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsLineReplacementView.js
+init_dom();
+init_mouseEvent();
+init_event();
+init_lifecycle();
+init_observable();
+init_colorRegistry();
+init_colorUtils();
+init_themeService();
+init_point();
+init_range();
+init_offsetRange();
+init_language();
+init_lineTokens();
+var __decorate126 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param120 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineEditsLineReplacementView = class InlineEditsLineReplacementView2 extends Disposable {
+ constructor(_editor, _edit, _isInDiffEditor, _tabAction, _languageService, _themeService) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._isInDiffEditor = _isInDiffEditor;
+ this._tabAction = _tabAction;
+ this._languageService = _languageService;
+ this._themeService = _themeService;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._maxPrefixTrim = this._edit.map((e, reader) => e ? getPrefixTrim(e.replacements.flatMap((r) => [r.originalRange, r.modifiedRange]), e.originalRange, e.modifiedLines, this._editor.editor, reader) : void 0);
+ this._modifiedLineElements = derived(this, (reader) => {
+ const lines = [];
+ let requiredWidth = 0;
+ const prefixTrim = this._maxPrefixTrim.read(reader);
+ const edit2 = this._edit.read(reader);
+ if (!edit2 || !prefixTrim) {
+ return void 0;
+ }
+ const maxPrefixTrim = prefixTrim.prefixTrim;
+ const modifiedBubbles = rangesToBubbleRanges(edit2.replacements.map((r) => r.modifiedRange)).map((r) => new Range(r.startLineNumber, r.startColumn - maxPrefixTrim, r.endLineNumber, r.endColumn - maxPrefixTrim));
+ const textModel = this._editor.model.get();
+ const startLineNumber = edit2.modifiedRange.startLineNumber;
+ for (let i2 = 0; i2 < edit2.modifiedRange.length; i2++) {
+ const line = document.createElement("div");
+ const lineNumber = startLineNumber + i2;
+ const modLine = edit2.modifiedLines[i2].slice(maxPrefixTrim);
+ const t = textModel.tokenization.tokenizeLinesAt(lineNumber, [modLine])?.[0];
+ let tokens;
+ if (t) {
+ tokens = TokenArray.fromLineTokens(t).toLineTokens(modLine, this._languageService.languageIdCodec);
+ } else {
+ tokens = LineTokens.createEmpty(modLine, this._languageService.languageIdCodec);
+ }
+ const decorations = [];
+ for (const modified of modifiedBubbles.filter((b) => b.startLineNumber === lineNumber)) {
+ const validatedEndColumn = Math.min(modified.endColumn, modLine.length + 1);
+ decorations.push(new InlineDecoration(
+ new Range(1, modified.startColumn, 1, validatedEndColumn),
+ "inlineCompletions-modified-bubble",
+ 0
+ /* InlineDecorationType.Regular */
+ ));
+ }
+ const result = renderLines(new LineSource([tokens]), RenderOptions.fromEditor(this._editor.editor).withSetWidth(false).withScrollBeyondLastColumn(0), decorations, line, true);
+ this._editor.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).read(reader);
+ requiredWidth = Math.max(requiredWidth, result.minWidthInPx);
+ lines.push(line);
+ }
+ return { lines, requiredWidth };
+ });
+ this._layout = derived(this, (reader) => {
+ const modifiedLines = this._modifiedLineElements.read(reader);
+ const maxPrefixTrim = this._maxPrefixTrim.read(reader);
+ const edit2 = this._edit.read(reader);
+ if (!modifiedLines || !maxPrefixTrim || !edit2) {
+ return void 0;
+ }
+ const { prefixLeftOffset } = maxPrefixTrim;
+ const { requiredWidth } = modifiedLines;
+ const originalLineHeights = this._editor.observeLineHeightsForLineRange(edit2.originalRange).read(reader);
+ const modifiedLineHeights = (() => {
+ const lineHeights = originalLineHeights.slice(0, edit2.modifiedRange.length);
+ while (lineHeights.length < edit2.modifiedRange.length) {
+ lineHeights.push(originalLineHeights[originalLineHeights.length - 1]);
+ }
+ return lineHeights;
+ })();
+ const contentLeft = this._editor.layoutInfoContentLeft.read(reader);
+ const verticalScrollbarWidth = this._editor.layoutInfoVerticalScrollbarWidth.read(reader);
+ const scrollLeft = this._editor.scrollLeft.read(reader);
+ const scrollTop = this._editor.scrollTop.read(reader);
+ const editorLeftOffset = contentLeft - scrollLeft;
+ const textModel = this._editor.editor.getModel();
+ const originalLineWidths = edit2.originalRange.mapToLineArray((line) => this._editor.editor.getOffsetForColumn(line, textModel.getLineMaxColumn(line)) - prefixLeftOffset);
+ const maxLineWidth = Math.max(...originalLineWidths, requiredWidth);
+ const startLineNumber = edit2.originalRange.startLineNumber;
+ const endLineNumber = edit2.originalRange.endLineNumberExclusive - 1;
+ const topOfOriginalLines = this._editor.editor.getTopForLineNumber(startLineNumber) - scrollTop;
+ const bottomOfOriginalLines = this._editor.editor.getBottomForLineNumber(endLineNumber) - scrollTop;
+ const originalLinesOverlay = Rect.fromLeftTopWidthHeight(editorLeftOffset + prefixLeftOffset, topOfOriginalLines, maxLineWidth, bottomOfOriginalLines - topOfOriginalLines);
+ const modifiedLinesOverlay = Rect.fromLeftTopWidthHeight(originalLinesOverlay.left, originalLinesOverlay.bottom, originalLinesOverlay.width, modifiedLineHeights.reduce((sum2, h2) => sum2 + h2, 0));
+ const background = Rect.hull([originalLinesOverlay, modifiedLinesOverlay]);
+ const lowerBackground = background.intersectVertical(new OffsetRange(originalLinesOverlay.bottom, Number.MAX_SAFE_INTEGER));
+ const lowerText = new Rect(lowerBackground.left, lowerBackground.top, lowerBackground.right, lowerBackground.bottom);
+ return {
+ originalLinesOverlay,
+ modifiedLinesOverlay,
+ background,
+ lowerBackground,
+ lowerText,
+ modifiedLineHeights,
+ minContentWidthRequired: prefixLeftOffset + maxLineWidth + verticalScrollbarWidth
+ };
+ });
+ this._viewZoneInfo = derived((reader) => {
+ const shouldShowViewZone = this._editor.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((o) => o.edits.allowCodeShifting === "always").read(reader);
+ if (!shouldShowViewZone) {
+ return void 0;
+ }
+ const layout2 = this._layout.read(reader);
+ const edit2 = this._edit.read(reader);
+ if (!layout2 || !edit2) {
+ return void 0;
+ }
+ const viewZoneHeight = layout2.lowerBackground.height;
+ const viewZoneLineNumber = edit2.originalRange.endLineNumberExclusive;
+ return { height: viewZoneHeight, lineNumber: viewZoneLineNumber };
+ });
+ this.minEditorScrollHeight = derived(this, (reader) => {
+ const layout2 = mapOutFalsy(this._layout).read(reader);
+ if (!layout2 || this._viewZoneInfo.read(reader) !== void 0) {
+ return 0;
+ }
+ return layout2.read(reader).lowerText.bottom + this._editor.editor.getScrollTop();
+ });
+ this._div = n.div({
+ class: "line-replacement"
+ }, [
+ derived(this, (reader) => {
+ const layout2 = mapOutFalsy(this._layout).read(reader);
+ const modifiedLineElements = this._modifiedLineElements.read(reader);
+ if (!layout2 || !modifiedLineElements) {
+ return [];
+ }
+ const layoutProps = layout2.read(reader);
+ const contentLeft = this._editor.layoutInfoContentLeft.read(reader);
+ const separatorWidth = this._isInDiffEditor.read(reader) ? 3 : 1;
+ modifiedLineElements.lines.forEach((l, i2) => {
+ l.style.width = `${layoutProps.lowerText.width}px`;
+ l.style.height = `${layoutProps.modifiedLineHeights[i2]}px`;
+ l.style.position = "relative";
+ });
+ const modifiedBorderColor = getModifiedBorderColor(this._tabAction).read(reader);
+ const originalBorderColor = getOriginalBorderColor(this._tabAction).read(reader);
+ return [
+ n.div({
+ style: {
+ position: "absolute",
+ ...rectToProps((r) => getEditorValidOverlayRect(this._editor).read(r)),
+ overflow: "hidden",
+ pointerEvents: "none"
+ }
+ }, [
+ n.div({
+ class: "borderAroundLineReplacement",
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).background.translateX(-contentLeft).withMargin(separatorWidth)),
+ borderRadius: "4px",
+ border: `${separatorWidth + 1}px solid ${asCssVariable(editorBackground)}`,
+ boxSizing: "border-box",
+ pointerEvents: "none"
+ }
+ }),
+ n.div({
+ class: "originalOverlayLineReplacement",
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).background.translateX(-contentLeft)),
+ borderRadius: "4px",
+ border: getEditorBlendedColor(originalBorderColor, this._themeService).map((c) => `1px solid ${c.toString()}`),
+ pointerEvents: "none",
+ boxSizing: "border-box",
+ background: asCssVariable(originalBackgroundColor)
+ }
+ }),
+ n.div({
+ class: "modifiedOverlayLineReplacement",
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).lowerBackground.translateX(-contentLeft)),
+ borderRadius: "0 0 4px 4px",
+ background: asCssVariable(editorBackground),
+ boxShadow: `${asCssVariable(scrollbarShadow)} 0 6px 6px -6px`,
+ border: `1px solid ${asCssVariable(modifiedBorderColor)}`,
+ boxSizing: "border-box",
+ overflow: "hidden",
+ cursor: "pointer",
+ pointerEvents: "auto"
+ },
+ onmousedown: (e) => {
+ e.preventDefault();
+ },
+ onclick: (e) => this._onDidClick.fire(new StandardMouseEvent(getWindow(e), e))
+ }, [
+ n.div({
+ style: {
+ position: "absolute",
+ top: 0,
+ left: 0,
+ width: "100%",
+ height: "100%",
+ background: asCssVariable(modifiedChangedLineBackgroundColor)
+ }
+ })
+ ]),
+ n.div({
+ class: "modifiedLinesLineReplacement",
+ style: {
+ position: "absolute",
+ boxSizing: "border-box",
+ ...rectToProps((reader2) => layout2.read(reader2).lowerText.translateX(-contentLeft)),
+ fontFamily: this._editor.getOption(
+ 58
+ /* EditorOption.fontFamily */
+ ),
+ fontSize: this._editor.getOption(
+ 61
+ /* EditorOption.fontSize */
+ ),
+ fontWeight: this._editor.getOption(
+ 62
+ /* EditorOption.fontWeight */
+ ),
+ pointerEvents: "none",
+ whiteSpace: "nowrap",
+ borderRadius: "0 0 4px 4px",
+ overflow: "hidden"
+ }
+ }, [...modifiedLineElements.lines])
+ ])
+ ];
+ })
+ ]).keepUpdated(this._store);
+ this.isHovered = this._editor.isTargetHovered((e) => this._isMouseOverWidget(e), this._store);
+ this._previousViewZoneInfo = void 0;
+ this._register(toDisposable(() => this._editor.editor.changeViewZones((accessor) => this.removePreviousViewZone(accessor))));
+ this._register(autorunDelta(this._viewZoneInfo, ({ lastValue, newValue }) => {
+ if (lastValue === newValue || lastValue?.height === newValue?.height && lastValue?.lineNumber === newValue?.lineNumber) {
+ return;
+ }
+ this._editor.editor.changeViewZones((changeAccessor) => {
+ this.removePreviousViewZone(changeAccessor);
+ if (!newValue) {
+ return;
+ }
+ this.addViewZone(newValue, changeAccessor);
+ });
+ }));
+ this._register(this._editor.createOverlayWidget({
+ domNode: this._div.element,
+ minContentWidthInPx: derived(this, (reader) => {
+ return this._layout.read(reader)?.minContentWidthRequired ?? 0;
+ }),
+ position: constObservable({ preference: { top: 0, left: 0 } }),
+ allowEditorOverflow: false
+ }));
+ }
+ _isMouseOverWidget(e) {
+ const layout2 = this._layout.get();
+ if (!layout2 || !(e.event instanceof EditorMouseEvent)) {
+ return false;
+ }
+ return layout2.lowerBackground.containsPoint(new Point(e.event.relativePos.x, e.event.relativePos.y));
+ }
+ removePreviousViewZone(changeAccessor) {
+ if (!this._previousViewZoneInfo) {
+ return;
+ }
+ changeAccessor.removeZone(this._previousViewZoneInfo.id);
+ const cursorLineNumber = this._editor.cursorLineNumber.get();
+ if (cursorLineNumber !== null && cursorLineNumber >= this._previousViewZoneInfo.lineNumber) {
+ this._editor.editor.setScrollTop(this._editor.scrollTop.get() - this._previousViewZoneInfo.height);
+ }
+ this._previousViewZoneInfo = void 0;
+ }
+ addViewZone(viewZoneInfo, changeAccessor) {
+ const activeViewZone = changeAccessor.addZone({
+ afterLineNumber: viewZoneInfo.lineNumber - 1,
+ heightInPx: viewZoneInfo.height,
+ // move computation to layout?
+ domNode: $("div")
+ });
+ this._previousViewZoneInfo = { height: viewZoneInfo.height, lineNumber: viewZoneInfo.lineNumber, id: activeViewZone };
+ const cursorLineNumber = this._editor.cursorLineNumber.get();
+ if (cursorLineNumber !== null && cursorLineNumber >= viewZoneInfo.lineNumber) {
+ this._editor.editor.setScrollTop(this._editor.scrollTop.get() + viewZoneInfo.height);
+ }
+ }
+};
+InlineEditsLineReplacementView = __decorate126([
+ __param120(4, ILanguageService),
+ __param120(5, IThemeService)
+], InlineEditsLineReplacementView);
+function rangesToBubbleRanges(ranges) {
+ const result = [];
+ while (ranges.length) {
+ let range2 = ranges.shift();
+ if (range2.startLineNumber !== range2.endLineNumber) {
+ ranges.push(new Range(range2.startLineNumber + 1, 1, range2.endLineNumber, range2.endColumn));
+ range2 = new Range(range2.startLineNumber, range2.startColumn, range2.startLineNumber, Number.MAX_SAFE_INTEGER);
+ }
+ result.push(range2);
+ }
+ return result;
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsSideBySideView.js
+init_dom();
+init_mouseEvent();
+init_color();
+init_event();
+init_lifecycle();
+init_observable();
+init_instantiation();
+init_colorRegistry();
+init_colorUtils();
+init_themeService();
+init_observableCodeEditor();
+init_offsetRange();
+init_position();
+init_range();
+var __decorate127 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param121 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var HORIZONTAL_PADDING2 = 0;
+var VERTICAL_PADDING2 = 0;
+var ENABLE_OVERFLOW = false;
+var BORDER_WIDTH3 = 1;
+var WIDGET_SEPARATOR_WIDTH3 = 1;
+var WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH3 = 3;
+var BORDER_RADIUS3 = 4;
+var ORIGINAL_END_PADDING = 20;
+var MODIFIED_END_PADDING = 12;
+var InlineEditsSideBySideView = class InlineEditsSideBySideView2 extends Disposable {
+ // This is an approximation and should be improved by using the real parameters used bellow
+ static fitsInsideViewport(editor2, textModel, edit2, reader) {
+ const editorObs = observableCodeEditor(editor2);
+ const editorWidth = editorObs.layoutInfoWidth.read(reader);
+ const editorContentLeft = editorObs.layoutInfoContentLeft.read(reader);
+ const editorVerticalScrollbar = editor2.getLayoutInfo().verticalScrollbarWidth;
+ const minimapWidth = editorObs.layoutInfoMinimap.read(reader).minimapLeft !== 0 ? editorObs.layoutInfoMinimap.read(reader).minimapWidth : 0;
+ const maxOriginalContent = maxContentWidthInRange(
+ editorObs,
+ edit2.displayRange,
+ void 0
+ /* do not reconsider on each layout info change */
+ );
+ const maxModifiedContent = edit2.lineEdit.newLines.reduce((max, line) => Math.max(max, getContentRenderWidth(line, editor2, textModel)), 0);
+ const originalPadding = ORIGINAL_END_PADDING;
+ const modifiedPadding = MODIFIED_END_PADDING + 2 * BORDER_WIDTH3;
+ return maxOriginalContent + maxModifiedContent + originalPadding + modifiedPadding < editorWidth - editorContentLeft - editorVerticalScrollbar - minimapWidth;
+ }
+ constructor(_editor, _edit, _previewTextModel, _uiState, _tabAction, _instantiationService, _themeService) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._previewTextModel = _previewTextModel;
+ this._uiState = _uiState;
+ this._tabAction = _tabAction;
+ this._instantiationService = _instantiationService;
+ this._themeService = _themeService;
+ this._editorObs = observableCodeEditor(this._editor);
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._display = derived(this, (reader) => !!this._uiState.read(reader) ? "block" : "none");
+ this.previewRef = n.ref();
+ const separatorWidthObs = this._uiState.map((s) => s?.isInDiffEditor ? WIDGET_SEPARATOR_DIFF_EDITOR_WIDTH3 : WIDGET_SEPARATOR_WIDTH3);
+ this._editorContainer = n.div({
+ class: ["editorContainer"],
+ style: { position: "absolute", overflow: "hidden", cursor: "pointer" },
+ onmousedown: (e) => {
+ e.preventDefault();
+ },
+ onclick: (e) => {
+ this._onDidClick.fire(new StandardMouseEvent(getWindow(e), e));
+ }
+ }, [
+ n.div({ class: "preview", style: { pointerEvents: "none" }, ref: this.previewRef })
+ ]).keepUpdated(this._store);
+ this.isHovered = this._editorContainer.didMouseMoveDuringHover;
+ this.previewEditor = this._register(this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this.previewRef.element, {
+ glyphMargin: false,
+ lineNumbers: "off",
+ minimap: { enabled: false },
+ guides: {
+ indentation: false,
+ bracketPairs: false,
+ bracketPairsHorizontal: false,
+ highlightActiveIndentation: false
+ },
+ rulers: [],
+ padding: { top: 0, bottom: 0 },
+ folding: false,
+ selectOnLineNumbers: false,
+ selectionHighlight: false,
+ columnSelection: false,
+ overviewRulerBorder: false,
+ overviewRulerLanes: 0,
+ lineDecorationsWidth: 0,
+ lineNumbersMinChars: 0,
+ revealHorizontalRightPadding: 0,
+ bracketPairColorization: { enabled: true, independentColorPoolPerBracketType: false },
+ scrollBeyondLastLine: false,
+ scrollbar: {
+ vertical: "hidden",
+ horizontal: "hidden",
+ handleMouseWheel: false
+ },
+ readOnly: true,
+ wordWrap: "off",
+ wordWrapOverride1: "off",
+ wordWrapOverride2: "off"
+ }, {
+ contextKeyValues: {
+ [InlineCompletionContextKeys.inInlineEditsPreviewEditor.key]: true
+ },
+ contributions: []
+ }, this._editor));
+ this._previewEditorObs = observableCodeEditor(this.previewEditor);
+ this._activeViewZones = [];
+ this._updatePreviewEditor = derived(this, (reader) => {
+ this._editorContainer.readEffect(reader);
+ this._previewEditorObs.model.read(reader);
+ this._display.read(reader);
+ if (this._nonOverflowView) {
+ this._nonOverflowView.element.style.display = this._display.read(reader);
+ }
+ const uiState = this._uiState.read(reader);
+ const edit2 = this._edit.read(reader);
+ if (!uiState || !edit2) {
+ return;
+ }
+ const range2 = edit2.originalLineRange;
+ const hiddenAreas = [];
+ if (range2.startLineNumber > 1) {
+ hiddenAreas.push(new Range(1, 1, range2.startLineNumber - 1, 1));
+ }
+ if (range2.startLineNumber + uiState.newTextLineCount < this._previewTextModel.getLineCount() + 1) {
+ hiddenAreas.push(new Range(range2.startLineNumber + uiState.newTextLineCount, 1, this._previewTextModel.getLineCount() + 1, 1));
+ }
+ this.previewEditor.setHiddenAreas(hiddenAreas, void 0, true);
+ const previousViewZones = [...this._activeViewZones];
+ this._activeViewZones = [];
+ const reducedLinesCount = range2.endLineNumberExclusive - range2.startLineNumber - uiState.newTextLineCount;
+ this.previewEditor.changeViewZones((changeAccessor) => {
+ previousViewZones.forEach((id) => changeAccessor.removeZone(id));
+ if (reducedLinesCount > 0) {
+ this._activeViewZones.push(changeAccessor.addZone({
+ afterLineNumber: range2.startLineNumber + uiState.newTextLineCount - 1,
+ heightInLines: reducedLinesCount,
+ showInHiddenAreas: true,
+ domNode: $("div.diagonal-fill.inline-edits-view-zone")
+ }));
+ }
+ });
+ });
+ this._previewEditorWidth = derived(this, (reader) => {
+ const edit2 = this._edit.read(reader);
+ if (!edit2) {
+ return 0;
+ }
+ this._updatePreviewEditor.read(reader);
+ return maxContentWidthInRange(this._previewEditorObs, edit2.modifiedLineRange, reader);
+ });
+ this._cursorPosIfTouchesEdit = derived(this, (reader) => {
+ const cursorPos = this._editorObs.cursorPosition.read(reader);
+ const edit2 = this._edit.read(reader);
+ if (!edit2 || !cursorPos) {
+ return void 0;
+ }
+ return edit2.modifiedLineRange.contains(cursorPos.lineNumber) ? cursorPos : void 0;
+ });
+ this._originalStartPosition = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ return inlineEdit ? new Position(inlineEdit.originalLineRange.startLineNumber, 1) : null;
+ });
+ this._originalEndPosition = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ return inlineEdit ? new Position(inlineEdit.originalLineRange.endLineNumberExclusive, 1) : null;
+ });
+ this._originalVerticalStartPosition = this._editorObs.observePosition(this._originalStartPosition, this._store).map((p) => p?.y);
+ this._originalVerticalEndPosition = this._editorObs.observePosition(this._originalEndPosition, this._store).map((p) => p?.y);
+ this._originalDisplayRange = this._edit.map((e) => e?.displayRange);
+ this._editorMaxContentWidthInRange = derived(this, (reader) => {
+ const originalDisplayRange = this._originalDisplayRange.read(reader);
+ if (!originalDisplayRange) {
+ return constObservable(0);
+ }
+ this._editorObs.versionId.read(reader);
+ return derivedObservableWithCache(this, (reader2, lastValue) => {
+ const maxWidth = maxContentWidthInRange(this._editorObs, originalDisplayRange, reader2);
+ return Math.max(maxWidth, lastValue ?? 0);
+ });
+ }).map((v, r) => v.read(r));
+ this._previewEditorLayoutInfo = derived(this, (reader) => {
+ const inlineEdit = this._edit.read(reader);
+ if (!inlineEdit) {
+ return null;
+ }
+ const state = this._uiState.read(reader);
+ if (!state) {
+ return null;
+ }
+ const range2 = inlineEdit.originalLineRange;
+ const horizontalScrollOffset = this._editorObs.scrollLeft.read(reader);
+ const editorContentMaxWidthInRange = this._editorMaxContentWidthInRange.read(reader);
+ const editorLayout = this._editorObs.layoutInfo.read(reader);
+ const previewContentWidth = this._previewEditorWidth.read(reader);
+ const editorContentAreaWidth = editorLayout.contentWidth - editorLayout.verticalScrollbarWidth;
+ const editorBoundingClientRect = this._editor.getContainerDomNode().getBoundingClientRect();
+ const clientContentAreaRight = editorLayout.contentLeft + editorLayout.contentWidth + editorBoundingClientRect.left;
+ const remainingWidthRightOfContent = getWindow(this._editor.getContainerDomNode()).innerWidth - clientContentAreaRight;
+ const remainingWidthRightOfEditor = getWindow(this._editor.getContainerDomNode()).innerWidth - editorBoundingClientRect.right;
+ const desiredMinimumWidth = Math.min(editorLayout.contentWidth * 0.3, previewContentWidth, 100);
+ const IN_EDITOR_DISPLACEMENT = 0;
+ const maximumAvailableWidth = IN_EDITOR_DISPLACEMENT + remainingWidthRightOfContent;
+ const cursorPos = this._cursorPosIfTouchesEdit.read(reader);
+ const maxPreviewEditorLeft = Math.max(
+ // We're starting from the content area right and moving it left by IN_EDITOR_DISPLACEMENT and also by an amount to ensure some minimum desired width
+ editorContentAreaWidth + horizontalScrollOffset - IN_EDITOR_DISPLACEMENT - Math.max(0, desiredMinimumWidth - maximumAvailableWidth),
+ // But we don't want that the moving left ends up covering the cursor, so this will push it to the right again
+ Math.min(cursorPos ? getOffsetForPos(this._editorObs, cursorPos, reader) + 50 : 0, editorContentAreaWidth + horizontalScrollOffset)
+ );
+ const previewEditorLeftInTextArea = Math.min(editorContentMaxWidthInRange + ORIGINAL_END_PADDING, maxPreviewEditorLeft);
+ const maxContentWidth = editorContentMaxWidthInRange + ORIGINAL_END_PADDING + previewContentWidth + 70;
+ const dist = maxPreviewEditorLeft - previewEditorLeftInTextArea;
+ let desiredPreviewEditorScrollLeft;
+ let codeRight;
+ if (previewEditorLeftInTextArea > horizontalScrollOffset) {
+ desiredPreviewEditorScrollLeft = 0;
+ codeRight = editorLayout.contentLeft + previewEditorLeftInTextArea - horizontalScrollOffset;
+ } else {
+ desiredPreviewEditorScrollLeft = horizontalScrollOffset - previewEditorLeftInTextArea;
+ codeRight = editorLayout.contentLeft;
+ }
+ const selectionTop = this._originalVerticalStartPosition.read(reader) ?? this._editor.getTopForLineNumber(range2.startLineNumber) - this._editorObs.scrollTop.read(reader);
+ const selectionBottom = this._originalVerticalEndPosition.read(reader) ?? this._editor.getBottomForLineNumber(range2.endLineNumberExclusive - 1) - this._editorObs.scrollTop.read(reader);
+ const codeLeft = editorLayout.contentLeft - horizontalScrollOffset;
+ let codeRect = Rect.fromLeftTopRightBottom(codeLeft, selectionTop, codeRight, selectionBottom);
+ const isInsertion2 = codeRect.height === 0;
+ if (!isInsertion2) {
+ codeRect = codeRect.withMargin(VERTICAL_PADDING2, HORIZONTAL_PADDING2);
+ }
+ const previewLineHeights = this._previewEditorObs.observeLineHeightsForLineRange(inlineEdit.modifiedLineRange).read(reader);
+ const editHeight = previewLineHeights.reduce((acc, h2) => acc + h2, 0);
+ const codeHeight = selectionBottom - selectionTop;
+ const previewEditorHeight = Math.max(codeHeight, editHeight);
+ const clipped = dist === 0;
+ const codeEditDist = 0;
+ const previewEditorWidth = Math.min(previewContentWidth + MODIFIED_END_PADDING, remainingWidthRightOfEditor + editorLayout.width - editorLayout.contentLeft - codeEditDist);
+ let editRect = Rect.fromLeftTopWidthHeight(codeRect.right + codeEditDist, selectionTop, previewEditorWidth, previewEditorHeight);
+ if (!isInsertion2) {
+ editRect = editRect.withMargin(VERTICAL_PADDING2, HORIZONTAL_PADDING2).translateX(HORIZONTAL_PADDING2 + BORDER_WIDTH3);
+ } else {
+ editRect = editRect.withMargin(VERTICAL_PADDING2, HORIZONTAL_PADDING2).translateY(VERTICAL_PADDING2);
+ }
+ return {
+ codeRect,
+ editRect,
+ codeScrollLeft: horizontalScrollOffset,
+ contentLeft: editorLayout.contentLeft,
+ isInsertion: isInsertion2,
+ maxContentWidth,
+ shouldShowShadow: clipped,
+ desiredPreviewEditorScrollLeft,
+ previewEditorWidth
+ };
+ });
+ this._stickyScrollController = StickyScrollController2.get(this._editorObs.editor);
+ this._stickyScrollHeight = this._stickyScrollController ? observableFromEvent(this._stickyScrollController.onDidChangeStickyScrollHeight, () => this._stickyScrollController.stickyScrollWidgetHeight) : constObservable(0);
+ this._shouldOverflow = derived(this, (reader) => {
+ if (!ENABLE_OVERFLOW) {
+ return false;
+ }
+ const range2 = this._edit.read(reader)?.originalLineRange;
+ if (!range2) {
+ return false;
+ }
+ const stickyScrollHeight = this._stickyScrollHeight.read(reader);
+ const top = this._editor.getTopForLineNumber(range2.startLineNumber) - this._editorObs.scrollTop.read(reader);
+ if (top <= stickyScrollHeight) {
+ return false;
+ }
+ const bottom = this._editor.getTopForLineNumber(range2.endLineNumberExclusive) - this._editorObs.scrollTop.read(reader);
+ if (bottom >= this._editorObs.layoutInfo.read(reader).height) {
+ return false;
+ }
+ return true;
+ });
+ this._originalBackgroundColor = observableFromEvent(this, this._themeService.onDidColorThemeChange, () => {
+ return this._themeService.getColorTheme().getColor(originalBackgroundColor) ?? Color.transparent;
+ });
+ this._backgroundSvg = n.svg({
+ transform: "translate(-0.5 -0.5)",
+ style: { overflow: "visible", pointerEvents: "none", position: "absolute" }
+ }, [
+ n.svgElem("path", {
+ class: "rightOfModifiedBackgroundCoverUp",
+ d: derived(this, (reader) => {
+ const layoutInfo = this._previewEditorLayoutInfo.read(reader);
+ if (!layoutInfo) {
+ return void 0;
+ }
+ const originalBackgroundColor2 = this._originalBackgroundColor.read(reader);
+ if (originalBackgroundColor2.isTransparent()) {
+ return void 0;
+ }
+ return new PathBuilder().moveTo(layoutInfo.codeRect.getRightTop()).lineTo(layoutInfo.codeRect.getRightTop().deltaX(1e3)).lineTo(layoutInfo.codeRect.getRightBottom().deltaX(1e3)).lineTo(layoutInfo.codeRect.getRightBottom()).build();
+ }),
+ style: {
+ fill: asCssVariableWithDefault(editorBackground, "transparent")
+ }
+ })
+ ]).keepUpdated(this._store);
+ this._originalOverlay = n.div({
+ style: { pointerEvents: "none", display: this._previewEditorLayoutInfo.map((layoutInfo) => layoutInfo?.isInsertion ? "none" : "block") }
+ }, derived(this, (reader) => {
+ const layoutInfoObs = mapOutFalsy(this._previewEditorLayoutInfo).read(reader);
+ if (!layoutInfoObs) {
+ return void 0;
+ }
+ const separatorWidth = separatorWidthObs.read(reader);
+ const borderStyling = getOriginalBorderColor(this._tabAction).map((bc) => `${BORDER_WIDTH3}px solid ${asCssVariable(bc)}`);
+ const borderStylingSeparator = `${BORDER_WIDTH3 + separatorWidth}px solid ${asCssVariable(editorBackground)}`;
+ const hasBorderLeft = layoutInfoObs.read(reader).codeScrollLeft !== 0;
+ const isModifiedLower = layoutInfoObs.map((layoutInfo) => layoutInfo.codeRect.bottom < layoutInfo.editRect.bottom);
+ const transitionRectSize = BORDER_RADIUS3 * 2 + BORDER_WIDTH3 * 2;
+ const overlayHider = layoutInfoObs.map((layoutInfo) => Rect.fromLeftTopRightBottom(layoutInfo.contentLeft - BORDER_RADIUS3 - BORDER_WIDTH3, layoutInfo.codeRect.top, layoutInfo.contentLeft, layoutInfo.codeRect.bottom + transitionRectSize)).read(reader);
+ const intersectionLine = new OffsetRange(overlayHider.left, Number.MAX_SAFE_INTEGER);
+ const overlayRect = layoutInfoObs.map((layoutInfo) => layoutInfo.codeRect.intersectHorizontal(intersectionLine));
+ const separatorRect = overlayRect.map((overlayRect2) => overlayRect2.withMargin(separatorWidth, 0, separatorWidth, separatorWidth).intersectHorizontal(intersectionLine));
+ const transitionRect = overlayRect.map((overlayRect2) => Rect.fromLeftTopWidthHeight(overlayRect2.right - transitionRectSize + BORDER_WIDTH3, overlayRect2.bottom - BORDER_WIDTH3, transitionRectSize, transitionRectSize).intersectHorizontal(intersectionLine));
+ return [
+ n.div({
+ class: "originalSeparatorSideBySide",
+ style: {
+ ...separatorRect.read(reader).toStyles(),
+ boxSizing: "border-box",
+ borderRadius: `${BORDER_RADIUS3}px 0 0 ${BORDER_RADIUS3}px`,
+ borderTop: borderStylingSeparator,
+ borderBottom: borderStylingSeparator,
+ borderLeft: hasBorderLeft ? "none" : borderStylingSeparator
+ }
+ }),
+ n.div({
+ class: "originalOverlaySideBySide",
+ style: {
+ ...overlayRect.read(reader).toStyles(),
+ boxSizing: "border-box",
+ borderRadius: `${BORDER_RADIUS3}px 0 0 ${BORDER_RADIUS3}px`,
+ borderTop: borderStyling,
+ borderBottom: borderStyling,
+ borderLeft: hasBorderLeft ? "none" : borderStyling,
+ backgroundColor: asCssVariable(originalBackgroundColor)
+ }
+ }),
+ n.div({
+ class: "originalCornerCutoutSideBySide",
+ style: {
+ pointerEvents: "none",
+ display: isModifiedLower.map((isLower2) => isLower2 ? "block" : "none"),
+ ...transitionRect.read(reader).toStyles()
+ }
+ }, [
+ n.div({
+ class: "originalCornerCutoutBackground",
+ style: {
+ position: "absolute",
+ top: "0px",
+ left: "0px",
+ width: "100%",
+ height: "100%",
+ backgroundColor: getEditorBlendedColor(originalBackgroundColor, this._themeService).map((c) => c.toString())
+ }
+ }),
+ n.div({
+ class: "originalCornerCutoutBorder",
+ style: {
+ position: "absolute",
+ top: "0px",
+ left: "0px",
+ width: "100%",
+ height: "100%",
+ boxSizing: "border-box",
+ borderTop: borderStyling,
+ borderRight: borderStyling,
+ borderRadius: `0 100% 0 0`,
+ backgroundColor: asCssVariable(editorBackground)
+ }
+ })
+ ]),
+ n.div({
+ class: "originalOverlaySideBySideHider",
+ style: {
+ ...overlayHider.toStyles(),
+ backgroundColor: asCssVariable(editorBackground)
+ }
+ })
+ ];
+ })).keepUpdated(this._store);
+ this._modifiedOverlay = n.div({
+ style: { pointerEvents: "none" }
+ }, derived(this, (reader) => {
+ const layoutInfoObs = mapOutFalsy(this._previewEditorLayoutInfo).read(reader);
+ if (!layoutInfoObs) {
+ return void 0;
+ }
+ const isModifiedLower = layoutInfoObs.map((layoutInfo) => layoutInfo.codeRect.bottom < layoutInfo.editRect.bottom);
+ const separatorWidth = separatorWidthObs.read(reader);
+ const borderRadius = isModifiedLower.map((isLower2) => `0 ${BORDER_RADIUS3}px ${BORDER_RADIUS3}px ${isLower2 ? BORDER_RADIUS3 : 0}px`);
+ const borderStyling = getEditorBlendedColor(getModifiedBorderColor(this._tabAction), this._themeService).map((c) => `1px solid ${c.toString()}`);
+ const borderStylingSeparator = `${BORDER_WIDTH3 + separatorWidth}px solid ${asCssVariable(editorBackground)}`;
+ const overlayRect = layoutInfoObs.map((layoutInfo) => layoutInfo.editRect.withMargin(0, BORDER_WIDTH3));
+ const separatorRect = overlayRect.map((overlayRect2) => overlayRect2.withMargin(separatorWidth, separatorWidth, separatorWidth, 0));
+ const insertionRect = derived(this, (reader2) => {
+ const overlay = overlayRect.read(reader2);
+ const layoutinfo = layoutInfoObs.read(reader2);
+ if (!layoutinfo.isInsertion || layoutinfo.contentLeft >= overlay.left) {
+ return Rect.fromLeftTopWidthHeight(overlay.left, overlay.top, 0, 0);
+ }
+ return new Rect(layoutinfo.contentLeft, overlay.top, overlay.left, overlay.top + BORDER_WIDTH3 * 2);
+ });
+ return [
+ n.div({
+ class: "modifiedInsertionSideBySide",
+ style: {
+ ...insertionRect.read(reader).toStyles(),
+ backgroundColor: getModifiedBorderColor(this._tabAction).map((c) => asCssVariable(c))
+ }
+ }),
+ n.div({
+ class: "modifiedSeparatorSideBySide",
+ style: {
+ ...separatorRect.read(reader).toStyles(),
+ borderRadius,
+ borderTop: borderStylingSeparator,
+ borderBottom: borderStylingSeparator,
+ borderRight: borderStylingSeparator,
+ boxSizing: "border-box"
+ }
+ }),
+ n.div({
+ class: "modifiedOverlaySideBySide",
+ style: {
+ ...overlayRect.read(reader).toStyles(),
+ borderRadius,
+ border: borderStyling,
+ boxSizing: "border-box",
+ backgroundColor: asCssVariable(modifiedBackgroundColor)
+ }
+ })
+ ];
+ })).keepUpdated(this._store);
+ this._nonOverflowView = n.div({
+ class: "inline-edits-view",
+ style: {
+ position: "absolute",
+ overflow: "visible",
+ top: "0px",
+ left: "0px",
+ display: this._display
+ }
+ }, [
+ this._backgroundSvg,
+ derived(this, (reader) => this._shouldOverflow.read(reader) ? [] : [this._editorContainer, this._originalOverlay, this._modifiedOverlay])
+ ]).keepUpdated(this._store);
+ this._register(this._editorObs.createOverlayWidget({
+ domNode: this._nonOverflowView.element,
+ position: constObservable(null),
+ allowEditorOverflow: false,
+ minContentWidthInPx: derived(this, (reader) => {
+ const x = this._previewEditorLayoutInfo.read(reader)?.maxContentWidth;
+ if (x === void 0) {
+ return 0;
+ }
+ return x;
+ })
+ }));
+ this.previewEditor.setModel(this._previewTextModel);
+ this._register(autorun((reader) => {
+ const layoutInfo = this._previewEditorLayoutInfo.read(reader);
+ if (!layoutInfo) {
+ return;
+ }
+ const editorRect = layoutInfo.editRect.withMargin(-VERTICAL_PADDING2, -HORIZONTAL_PADDING2);
+ this.previewEditor.layout({
+ height: editorRect.height,
+ width: layoutInfo.previewEditorWidth + 15
+ /* Make sure editor does not scroll horizontally */
+ });
+ this._editorContainer.element.style.top = `${editorRect.top}px`;
+ this._editorContainer.element.style.left = `${editorRect.left}px`;
+ this._editorContainer.element.style.width = `${layoutInfo.previewEditorWidth + HORIZONTAL_PADDING2}px`;
+ }));
+ this._register(autorun((reader) => {
+ const layoutInfo = this._previewEditorLayoutInfo.read(reader);
+ if (!layoutInfo) {
+ return;
+ }
+ this._previewEditorObs.editor.setScrollLeft(layoutInfo.desiredPreviewEditorScrollLeft);
+ }));
+ this._updatePreviewEditor.recomputeInitiallyAndOnChange(this._store);
+ }
+};
+InlineEditsSideBySideView = __decorate127([
+ __param121(5, IInstantiationService),
+ __param121(6, IThemeService)
+], InlineEditsSideBySideView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/inlineEditsWordReplacementView.js
+init_dom();
+init_mouseEvent();
+init_event();
+init_lifecycle();
+init_observable();
+init_colorRegistry();
+init_colorUtils();
+init_point();
+init_offsetRange();
+init_language();
+init_lineTokens();
+var __decorate128 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param122 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var BORDER_WIDTH4 = 1;
+var InlineEditsWordReplacementView = class InlineEditsWordReplacementView2 extends Disposable {
+ static {
+ this.MAX_LENGTH = 100;
+ }
+ constructor(_editor, _edit, _tabAction, _languageService) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._tabAction = _tabAction;
+ this._languageService = _languageService;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this._start = this._editor.observePosition(constObservable(this._edit.range.getStartPosition()), this._store);
+ this._end = this._editor.observePosition(constObservable(this._edit.range.getEndPosition()), this._store);
+ this._line = document.createElement("div");
+ this._hoverableElement = observableValue(this, null);
+ this.isHovered = this._hoverableElement.map((e, reader) => e?.didMouseMoveDuringHover.read(reader) ?? false);
+ this._renderTextEffect = derived(this, (_reader) => {
+ const tm = this._editor.model.get();
+ const origLine = tm.getLineContent(this._edit.range.startLineNumber);
+ const edit2 = StringReplacement.replace(new OffsetRange(this._edit.range.startColumn - 1, this._edit.range.endColumn - 1), this._edit.text);
+ const lineToTokenize = edit2.replace(origLine);
+ const t = tm.tokenization.tokenizeLinesAt(this._edit.range.startLineNumber, [lineToTokenize])?.[0];
+ let tokens;
+ if (t) {
+ tokens = TokenArray.fromLineTokens(t).slice(edit2.getRangeAfterReplace()).toLineTokens(this._edit.text, this._languageService.languageIdCodec);
+ } else {
+ tokens = LineTokens.createEmpty(this._edit.text, this._languageService.languageIdCodec);
+ }
+ const res = renderLines(new LineSource([tokens]), RenderOptions.fromEditor(this._editor.editor).withSetWidth(false).withScrollBeyondLastColumn(0), [], this._line, true);
+ this._line.style.width = `${res.minWidthInPx}px`;
+ });
+ const modifiedLineHeight = this._editor.observeLineHeightForPosition(this._edit.range.getStartPosition());
+ this._layout = derived(this, (reader) => {
+ this._renderTextEffect.read(reader);
+ const widgetStart = this._start.read(reader);
+ const widgetEnd = this._end.read(reader);
+ if (!widgetStart || !widgetEnd || widgetStart.x > widgetEnd.x || widgetStart.y > widgetEnd.y) {
+ return void 0;
+ }
+ const lineHeight = modifiedLineHeight.read(reader);
+ const scrollLeft = this._editor.scrollLeft.read(reader);
+ const w = this._editor.getOption(
+ 59
+ /* EditorOption.fontInfo */
+ ).read(reader).typicalHalfwidthCharacterWidth;
+ const modifiedLeftOffset = 3 * w;
+ const modifiedTopOffset = 4;
+ const modifiedOffset = new Point(modifiedLeftOffset, modifiedTopOffset);
+ const originalLine = Rect.fromPoints(widgetStart, widgetEnd).withHeight(lineHeight).translateX(-scrollLeft);
+ const modifiedLine = Rect.fromPointSize(originalLine.getLeftBottom().add(modifiedOffset), new Point(this._edit.text.length * w, originalLine.height));
+ const lowerBackground = modifiedLine.withLeft(originalLine.left);
+ return {
+ originalLine,
+ modifiedLine,
+ lowerBackground,
+ lineHeight
+ };
+ });
+ this.minEditorScrollHeight = derived(this, (reader) => {
+ const layout2 = mapOutFalsy(this._layout).read(reader);
+ if (!layout2) {
+ return 0;
+ }
+ return layout2.read(reader).modifiedLine.bottom + BORDER_WIDTH4 + this._editor.editor.getScrollTop();
+ });
+ this._root = n.div({
+ class: "word-replacement"
+ }, [
+ derived(this, (reader) => {
+ const layout2 = mapOutFalsy(this._layout).read(reader);
+ if (!layout2) {
+ return [];
+ }
+ const originalBorderColor = getOriginalBorderColor(this._tabAction).map((c) => asCssVariable(c)).read(reader);
+ const modifiedBorderColor = getModifiedBorderColor(this._tabAction).map((c) => asCssVariable(c)).read(reader);
+ return [
+ n.div({
+ style: {
+ position: "absolute",
+ ...rectToProps((r) => getEditorValidOverlayRect(this._editor).read(r)),
+ overflow: "hidden",
+ pointerEvents: "none"
+ }
+ }, [
+ n.div({
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).lowerBackground.withMargin(BORDER_WIDTH4, 2 * BORDER_WIDTH4, BORDER_WIDTH4, 0)),
+ background: asCssVariable(editorBackground),
+ //boxShadow: `${asCssVariable(scrollbarShadow)} 0 6px 6px -6px`,
+ cursor: "pointer",
+ pointerEvents: "auto"
+ },
+ onmousedown: (e) => {
+ e.preventDefault();
+ },
+ onmouseup: (e) => this._onDidClick.fire(new StandardMouseEvent(getWindow(e), e)),
+ obsRef: (elem) => {
+ this._hoverableElement.set(elem, void 0);
+ }
+ }),
+ n.div({
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).modifiedLine.withMargin(BORDER_WIDTH4, 2 * BORDER_WIDTH4)),
+ fontFamily: this._editor.getOption(
+ 58
+ /* EditorOption.fontFamily */
+ ),
+ fontSize: this._editor.getOption(
+ 61
+ /* EditorOption.fontSize */
+ ),
+ fontWeight: this._editor.getOption(
+ 62
+ /* EditorOption.fontWeight */
+ ),
+ pointerEvents: "none",
+ boxSizing: "border-box",
+ borderRadius: "4px",
+ border: `${BORDER_WIDTH4}px solid ${modifiedBorderColor}`,
+ background: asCssVariable(modifiedChangedTextOverlayColor),
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ outline: `2px solid ${asCssVariable(editorBackground)}`
+ }
+ }, [this._line]),
+ n.div({
+ style: {
+ position: "absolute",
+ ...rectToProps((reader2) => layout2.read(reader2).originalLine.withMargin(BORDER_WIDTH4)),
+ boxSizing: "border-box",
+ borderRadius: "4px",
+ border: `${BORDER_WIDTH4}px solid ${originalBorderColor}`,
+ background: asCssVariable(originalChangedTextOverlayColor),
+ pointerEvents: "none"
+ }
+ }, []),
+ n.svg({
+ width: 11,
+ height: 14,
+ viewBox: "0 0 11 14",
+ fill: "none",
+ style: {
+ position: "absolute",
+ left: layout2.map((l) => l.modifiedLine.left - 16),
+ top: layout2.map((l) => l.modifiedLine.top + Math.round((l.lineHeight - 14 - 5) / 2))
+ }
+ }, [
+ n.svgElem("path", {
+ d: "M1 0C1 2.98966 1 5.92087 1 8.49952C1 9.60409 1.89543 10.5 3 10.5H10.5",
+ stroke: asCssVariable(editorHoverForeground)
+ }),
+ n.svgElem("path", {
+ d: "M6 7.5L9.99999 10.49998L6 13.5",
+ stroke: asCssVariable(editorHoverForeground)
+ })
+ ])
+ ])
+ ];
+ })
+ ]).keepUpdated(this._store);
+ this._register(this._editor.createOverlayWidget({
+ domNode: this._root.element,
+ minContentWidthInPx: constObservable(0),
+ position: constObservable({ preference: { top: 0, left: 0 } }),
+ allowEditorOverflow: false
+ }));
+ }
+};
+InlineEditsWordReplacementView = __decorate128([
+ __param122(3, ILanguageService)
+], InlineEditsWordReplacementView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViews/originalEditorInlineDiffView.js
+init_event();
+init_lifecycle();
+init_observable();
+init_observableCodeEditor();
+init_offsetRange();
+init_range();
+init_model2();
+init_textModel();
+var OriginalEditorInlineDiffView = class extends Disposable {
+ constructor(_originalEditor, _state, _modifiedTextModel) {
+ super();
+ this._originalEditor = _originalEditor;
+ this._state = _state;
+ this._modifiedTextModel = _modifiedTextModel;
+ this._onDidClick = this._register(new Emitter());
+ this.onDidClick = this._onDidClick.event;
+ this.isHovered = observableCodeEditor(this._originalEditor).isTargetHovered((p) => p.target.type === 6 && p.target.detail.injectedText?.options.attachedData instanceof InlineEditAttachedData && p.target.detail.injectedText.options.attachedData.owner === this, this._store);
+ this._tokenizationFinished = modelTokenizationFinished(this._modifiedTextModel);
+ this._decorations = derived(this, (reader) => {
+ const diff = this._state.read(reader);
+ if (!diff) {
+ return void 0;
+ }
+ const modified = diff.modifiedText;
+ const showInline = diff.mode === "insertionInline";
+ const hasOneInnerChange = diff.diff.length === 1 && diff.diff[0].innerChanges?.length === 1;
+ const showEmptyDecorations = true;
+ const originalDecorations = [];
+ const modifiedDecorations = [];
+ const diffLineAddDecorationBackground2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-line-insert",
+ description: "line-insert",
+ isWholeLine: true,
+ marginClassName: "gutter-insert"
+ });
+ const diffLineDeleteDecorationBackground2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-line-delete",
+ description: "line-delete",
+ isWholeLine: true,
+ marginClassName: "gutter-delete"
+ });
+ const diffWholeLineDeleteDecoration2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-char-delete",
+ description: "char-delete",
+ isWholeLine: false,
+ zIndex: 1
+ // be on top of diff background decoration
+ });
+ const diffWholeLineAddDecoration2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-char-insert",
+ description: "char-insert",
+ isWholeLine: true
+ });
+ const diffAddDecoration2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-char-insert",
+ description: "char-insert",
+ shouldFillLineOnLineBreak: true
+ });
+ const diffAddDecorationEmpty2 = ModelDecorationOptions.register({
+ className: "inlineCompletions-char-insert diff-range-empty",
+ description: "char-insert diff-range-empty"
+ });
+ const NESOriginalBackground = ModelDecorationOptions.register({
+ className: "inlineCompletions-original-lines",
+ description: "inlineCompletions-original-lines",
+ isWholeLine: false,
+ shouldFillLineOnLineBreak: true
+ });
+ const showFullLineDecorations = diff.mode !== "sideBySide" && diff.mode !== "deletion" && diff.mode !== "insertionInline" && diff.mode !== "lineReplacement";
+ const hideEmptyInnerDecorations = diff.mode === "lineReplacement";
+ for (const m of diff.diff) {
+ if (showFullLineDecorations) {
+ if (!m.original.isEmpty) {
+ originalDecorations.push({
+ range: m.original.toInclusiveRange(),
+ options: diffLineDeleteDecorationBackground2
+ });
+ }
+ if (!m.modified.isEmpty) {
+ modifiedDecorations.push({
+ range: m.modified.toInclusiveRange(),
+ options: diffLineAddDecorationBackground2
+ });
+ }
+ }
+ if (m.modified.isEmpty || m.original.isEmpty) {
+ if (!m.original.isEmpty) {
+ originalDecorations.push({ range: m.original.toInclusiveRange(), options: diffWholeLineDeleteDecoration2 });
+ }
+ if (!m.modified.isEmpty) {
+ modifiedDecorations.push({ range: m.modified.toInclusiveRange(), options: diffWholeLineAddDecoration2 });
+ }
+ } else {
+ const useInlineDiff = showInline && allowsTrueInlineDiffRendering2(m);
+ for (const i2 of m.innerChanges || []) {
+ if (m.original.contains(i2.originalRange.startLineNumber) && !(hideEmptyInnerDecorations && i2.originalRange.isEmpty())) {
+ const replacedText = this._originalEditor.getModel()?.getValueInRange(
+ i2.originalRange,
+ 1
+ /* EndOfLinePreference.LF */
+ );
+ originalDecorations.push({
+ range: i2.originalRange,
+ options: {
+ description: "char-delete",
+ shouldFillLineOnLineBreak: false,
+ className: classNames("inlineCompletions-char-delete", i2.originalRange.isSingleLine() && diff.mode === "insertionInline" && "single-line-inline", i2.originalRange.isEmpty() && "empty", (i2.originalRange.isEmpty() && hasOneInnerChange || diff.mode === "deletion" && replacedText === "\n") && showEmptyDecorations && !useInlineDiff && "diff-range-empty"),
+ inlineClassName: useInlineDiff ? classNames("strike-through", "inlineCompletions") : null,
+ zIndex: 1
+ }
+ });
+ }
+ if (m.modified.contains(i2.modifiedRange.startLineNumber)) {
+ modifiedDecorations.push({
+ range: i2.modifiedRange,
+ options: i2.modifiedRange.isEmpty() && showEmptyDecorations && !useInlineDiff && hasOneInnerChange ? diffAddDecorationEmpty2 : diffAddDecoration2
+ });
+ }
+ if (useInlineDiff) {
+ const insertedText = modified.getValueOfRange(i2.modifiedRange);
+ const textSegments = insertedText.length > 3 ? [
+ { text: insertedText.slice(0, 1), extraClasses: ["start"], offsetRange: new OffsetRange(i2.modifiedRange.startColumn - 1, i2.modifiedRange.startColumn) },
+ { text: insertedText.slice(1, -1), extraClasses: [], offsetRange: new OffsetRange(i2.modifiedRange.startColumn, i2.modifiedRange.endColumn - 2) },
+ { text: insertedText.slice(-1), extraClasses: ["end"], offsetRange: new OffsetRange(i2.modifiedRange.endColumn - 2, i2.modifiedRange.endColumn - 1) }
+ ] : [
+ { text: insertedText, extraClasses: ["start", "end"], offsetRange: new OffsetRange(i2.modifiedRange.startColumn - 1, i2.modifiedRange.endColumn) }
+ ];
+ this._tokenizationFinished.read(reader);
+ const lineTokens = this._modifiedTextModel.tokenization.getLineTokens(i2.modifiedRange.startLineNumber);
+ for (const { text: text2, extraClasses, offsetRange } of textSegments) {
+ originalDecorations.push({
+ range: Range.fromPositions(i2.originalRange.getEndPosition()),
+ options: {
+ description: "inserted-text",
+ before: {
+ tokens: lineTokens.getTokensInRange(offsetRange),
+ content: text2,
+ inlineClassName: classNames(
+ "inlineCompletions-char-insert",
+ i2.modifiedRange.isSingleLine() && diff.mode === "insertionInline" && "single-line-inline",
+ ...extraClasses
+ // include extraClasses for additional styling if provided
+ ),
+ cursorStops: InjectedTextCursorStops.None,
+ attachedData: new InlineEditAttachedData(this)
+ },
+ zIndex: 2,
+ showIfCollapsed: true
+ }
+ });
+ }
+ }
+ }
+ }
+ }
+ if (diff.isInDiffEditor) {
+ for (const m of diff.diff) {
+ if (!m.original.isEmpty) {
+ originalDecorations.push({
+ range: m.original.toExclusiveRange(),
+ options: NESOriginalBackground
+ });
+ }
+ }
+ }
+ return { originalDecorations, modifiedDecorations };
+ });
+ this._register(observableCodeEditor(this._originalEditor).setDecorations(this._decorations.map((d) => d?.originalDecorations ?? [])));
+ const modifiedCodeEditor = this._state.map((s) => s?.modifiedCodeEditor);
+ this._register(autorunWithStore((reader, store) => {
+ const e = modifiedCodeEditor.read(reader);
+ if (e) {
+ store.add(observableCodeEditor(e).setDecorations(this._decorations.map((d) => d?.modifiedDecorations ?? [])));
+ }
+ }));
+ this._register(this._originalEditor.onMouseUp((e) => {
+ if (e.target.type !== 6) {
+ return;
+ }
+ const a = e.target.detail.injectedText?.options.attachedData;
+ if (a instanceof InlineEditAttachedData && a.owner === this) {
+ this._onDidClick.fire(e.event);
+ }
+ }));
+ }
+};
+var InlineEditAttachedData = class {
+ constructor(owner) {
+ this.owner = owner;
+ }
+};
+function allowsTrueInlineDiffRendering2(mapping) {
+ if (!mapping.innerChanges) {
+ return false;
+ }
+ return mapping.innerChanges.every((c) => rangeIsSingleLine(c.modifiedRange) && rangeIsSingleLine(c.originalRange));
+}
+var i = 0;
+function modelTokenizationFinished(model) {
+ return observableFromEvent(model.onDidChangeTokens, () => i++);
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.js
+var __decorate129 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param123 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineEditsView_1;
+var InlineEditsView = InlineEditsView_1 = class InlineEditsView2 extends Disposable {
+ constructor(_editor, _host, _model, _ghostTextIndicator, _focusIsInMenu, _instantiationService) {
+ super();
+ this._editor = _editor;
+ this._host = _host;
+ this._model = _model;
+ this._ghostTextIndicator = _ghostTextIndicator;
+ this._focusIsInMenu = _focusIsInMenu;
+ this._instantiationService = _instantiationService;
+ this._editorObs = observableCodeEditor(this._editor);
+ this._tabAction = derived((reader) => this._model.read(reader)?.tabAction.read(reader) ?? InlineEditTabAction.Inactive);
+ this._constructorDone = observableValue(this, false);
+ this._uiState = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model || !this._constructorDone.read(reader)) {
+ return void 0;
+ }
+ const inlineEdit = model.inlineEdit;
+ let mappings = RangeMapping.fromEdit(inlineEdit.edit);
+ let newText = inlineEdit.edit.apply(inlineEdit.originalText);
+ let diff = lineRangeMappingFromRangeMappings(mappings, inlineEdit.originalText, new StringText(newText));
+ let state = this.determineRenderState(model, reader, diff, new StringText(newText));
+ if (!state) {
+ onUnexpectedError(new Error(`unable to determine view: tried to render ${this._previousView?.view}`));
+ return void 0;
+ }
+ if (state.kind === InlineCompletionViewKind.SideBySide) {
+ const indentationAdjustmentEdit = createReindentEdit(newText, inlineEdit.modifiedLineRange, textModel.getOptions().tabSize);
+ newText = indentationAdjustmentEdit.applyToString(newText);
+ mappings = applyEditToModifiedRangeMappings(mappings, indentationAdjustmentEdit);
+ diff = lineRangeMappingFromRangeMappings(mappings, inlineEdit.originalText, new StringText(newText));
+ }
+ this._previewTextModel.setLanguage(this._editor.getModel().getLanguageId());
+ const previousNewText = this._previewTextModel.getValue();
+ if (previousNewText !== newText) {
+ this._previewTextModel.setValue(newText);
+ }
+ if (model.showCollapsed.read(reader) && !this._indicator.read(reader)?.isHoverVisible.read(reader)) {
+ state = { kind: InlineCompletionViewKind.Collapsed, viewData: state.viewData };
+ }
+ model.handleInlineEditShown(state.kind, state.viewData);
+ return {
+ state,
+ diff,
+ edit: inlineEdit,
+ newText,
+ newTextLineCount: inlineEdit.modifiedLineRange.length,
+ isInDiffEditor: model.isInDiffEditor
+ };
+ });
+ this._previewTextModel = this._register(this._instantiationService.createInstance(TextModel, "", this._editor.getModel().getLanguageId(), { ...TextModel.DEFAULT_CREATION_OPTIONS, bracketPairColorizationOptions: { enabled: true, independentColorPoolPerBracketType: false } }, null));
+ this._indicatorCyclicDependencyCircuitBreaker = observableValue(this, false);
+ this._indicator = derived(this, (reader) => {
+ if (!this._indicatorCyclicDependencyCircuitBreaker.read(reader)) {
+ return void 0;
+ }
+ const indicatorDisplayRange = derivedOpts({ owner: this, equalsFn: equalsIfDefined(itemEquals()) }, (reader2) => {
+ const ghostTextIndicator = this._ghostTextIndicator.read(reader2);
+ if (ghostTextIndicator) {
+ return ghostTextIndicator.lineRange;
+ }
+ const state = this._uiState.read(reader2);
+ if (!state) {
+ return void 0;
+ }
+ if (state.state?.kind === "custom") {
+ const range2 = state.state.displayLocation?.range;
+ if (!range2) {
+ throw new BugIndicatingError("custom view should have a range");
+ }
+ return new LineRange(range2.startLineNumber, range2.endLineNumber);
+ }
+ if (state.state?.kind === "insertionMultiLine") {
+ return this._insertion.originalLines.read(reader2);
+ }
+ return state.edit.displayRange;
+ });
+ const modelWithGhostTextSupport = derived(this, (reader2) => {
+ const model = this._model.read(reader2);
+ if (model) {
+ return model;
+ }
+ const ghostTextIndicator = this._ghostTextIndicator.read(reader2);
+ if (ghostTextIndicator) {
+ return ghostTextIndicator.model;
+ }
+ return model;
+ });
+ return reader.store.add(this._instantiationService.createInstance(InlineEditsGutterIndicator, this._editorObs, indicatorDisplayRange, this._gutterIndicatorOffset, modelWithGhostTextSupport, this._inlineEditsIsHovered, this._focusIsInMenu));
+ });
+ this._inlineEditsIsHovered = derived(this, (reader) => {
+ return this._sideBySide.isHovered.read(reader) || this._wordReplacementViews.read(reader).some((v) => v.isHovered.read(reader)) || this._deletion.isHovered.read(reader) || this._inlineDiffView.isHovered.read(reader) || this._lineReplacementView.isHovered.read(reader) || this._insertion.isHovered.read(reader) || this._customView.isHovered.read(reader);
+ });
+ this._gutterIndicatorOffset = derived(this, (reader) => {
+ if (this._uiState.read(reader)?.state?.kind === "insertionMultiLine") {
+ return this._insertion.startLineOffset.read(reader);
+ }
+ const ghostTextIndicator = this._ghostTextIndicator.read(reader);
+ if (ghostTextIndicator) {
+ return getGhostTextTopOffset(ghostTextIndicator, this._editor);
+ }
+ return 0;
+ });
+ this._sideBySide = this._register(this._instantiationService.createInstance(InlineEditsSideBySideView, this._editor, this._model.map((m) => m?.inlineEdit), this._previewTextModel, this._uiState.map((s) => s && s.state?.kind === InlineCompletionViewKind.SideBySide ? {
+ newTextLineCount: s.newTextLineCount,
+ isInDiffEditor: s.isInDiffEditor
+ } : void 0), this._tabAction));
+ this._deletion = this._register(this._instantiationService.createInstance(InlineEditsDeletionView, this._editor, this._model.map((m) => m?.inlineEdit), this._uiState.map((s) => s && s.state?.kind === InlineCompletionViewKind.Deletion ? {
+ originalRange: s.state.originalRange,
+ deletions: s.state.deletions,
+ inDiffEditor: s.isInDiffEditor
+ } : void 0), this._tabAction));
+ this._insertion = this._register(this._instantiationService.createInstance(InlineEditsInsertionView, this._editor, this._uiState.map((s) => s && s.state?.kind === InlineCompletionViewKind.InsertionMultiLine ? {
+ lineNumber: s.state.lineNumber,
+ startColumn: s.state.column,
+ text: s.state.text,
+ inDiffEditor: s.isInDiffEditor
+ } : void 0), this._tabAction));
+ this._inlineDiffViewState = derived(this, (reader) => {
+ const e = this._uiState.read(reader);
+ if (!e || !e.state) {
+ return void 0;
+ }
+ if (e.state.kind === "wordReplacements" || e.state.kind === "insertionMultiLine" || e.state.kind === "collapsed" || e.state.kind === "custom") {
+ return void 0;
+ }
+ return {
+ modifiedText: new StringText(e.newText),
+ diff: e.diff,
+ mode: e.state.kind,
+ modifiedCodeEditor: this._sideBySide.previewEditor,
+ isInDiffEditor: e.isInDiffEditor
+ };
+ });
+ this._inlineCollapsedView = this._register(this._instantiationService.createInstance(InlineEditsCollapsedView, this._editor, this._model.map((m, reader) => this._uiState.read(reader)?.state?.kind === "collapsed" ? m?.inlineEdit : void 0)));
+ this._customView = this._register(this._instantiationService.createInstance(InlineEditsCustomView, this._editor, this._model.map((m, reader) => this._uiState.read(reader)?.state?.kind === "custom" ? m?.displayLocation : void 0), this._tabAction));
+ this._inlineDiffView = this._register(new OriginalEditorInlineDiffView(this._editor, this._inlineDiffViewState, this._previewTextModel));
+ this._wordReplacementViews = mapObservableArrayCached(this, this._uiState.map((s) => s?.state?.kind === "wordReplacements" ? s.state.replacements : []), (e, store) => {
+ return store.add(this._instantiationService.createInstance(InlineEditsWordReplacementView, this._editorObs, e, this._tabAction));
+ });
+ this._lineReplacementView = this._register(this._instantiationService.createInstance(InlineEditsLineReplacementView, this._editorObs, this._uiState.map((s) => s?.state?.kind === InlineCompletionViewKind.LineReplacement ? {
+ originalRange: s.state.originalRange,
+ modifiedRange: s.state.modifiedRange,
+ modifiedLines: s.state.modifiedLines,
+ replacements: s.state.replacements
+ } : void 0), this._uiState.map((s) => s?.isInDiffEditor ?? false), this._tabAction));
+ this._useCodeShifting = this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((s) => s.edits.allowCodeShifting);
+ this._renderSideBySide = this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((s) => s.edits.renderSideBySide);
+ this._register(autorunWithStore((reader, store) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return;
+ }
+ store.add(Event.any(this._sideBySide.onDidClick, this._deletion.onDidClick, this._lineReplacementView.onDidClick, this._insertion.onDidClick, ...this._wordReplacementViews.read(reader).map((w) => w.onDidClick), this._inlineDiffView.onDidClick, this._customView.onDidClick)((e) => {
+ if (this._viewHasBeenShownLongerThan(350)) {
+ e.preventDefault();
+ model.accept();
+ }
+ }));
+ }));
+ this._indicator.recomputeInitiallyAndOnChange(this._store);
+ this._wordReplacementViews.recomputeInitiallyAndOnChange(this._store);
+ this._indicatorCyclicDependencyCircuitBreaker.set(true, void 0);
+ this._register(this._instantiationService.createInstance(InlineEditsOnboardingExperience, this._host, this._model, this._indicator, this._inlineCollapsedView));
+ const minEditorScrollHeight = derived(this, (reader) => {
+ return Math.max(...this._wordReplacementViews.read(reader).map((v) => v.minEditorScrollHeight.read(reader)), this._lineReplacementView.minEditorScrollHeight.read(reader), this._customView.minEditorScrollHeight.read(reader));
+ }).recomputeInitiallyAndOnChange(this._store);
+ const textModel = this._editor.getModel();
+ let viewZoneId;
+ this._register(autorun((reader) => {
+ const minScrollHeight = minEditorScrollHeight.read(reader);
+ this._editor.changeViewZones((accessor) => {
+ const scrollHeight = this._editor.getScrollHeight();
+ const viewZoneHeight = minScrollHeight - scrollHeight + 1;
+ if (viewZoneHeight !== 0 && viewZoneId) {
+ accessor.removeZone(viewZoneId);
+ viewZoneId = void 0;
+ }
+ if (viewZoneHeight <= 0) {
+ return;
+ }
+ viewZoneId = accessor.addZone({
+ afterLineNumber: textModel.getLineCount(),
+ heightInPx: viewZoneHeight,
+ domNode: $("div.minScrollHeightViewZone")
+ });
+ });
+ }));
+ this._constructorDone.set(true, void 0);
+ }
+ getCacheId(model) {
+ return model.inlineEdit.inlineCompletion.identity.id;
+ }
+ determineView(model, reader, diff, newText) {
+ const inlineEdit = model.inlineEdit;
+ const canUseCache = this._previousView?.id === this.getCacheId(model) && !model.displayLocation?.jumpToEdit;
+ const reconsiderViewEditorWidthChange = this._previousView?.editorWidth !== this._editorObs.layoutInfoWidth.read(reader) && (this._previousView?.view === InlineCompletionViewKind.SideBySide || this._previousView?.view === InlineCompletionViewKind.LineReplacement);
+ if (canUseCache && !reconsiderViewEditorWidthChange) {
+ return this._previousView.view;
+ }
+ if (model.inlineEdit.inlineCompletion instanceof InlineEditItem && model.inlineEdit.inlineCompletion.uri) {
+ return InlineCompletionViewKind.Custom;
+ }
+ if (model.displayLocation && !model.inlineEdit.inlineCompletion.identity.jumpedTo.read(reader)) {
+ return InlineCompletionViewKind.Custom;
+ }
+ const numOriginalLines = inlineEdit.originalLineRange.length;
+ const numModifiedLines = inlineEdit.modifiedLineRange.length;
+ const inner = diff.flatMap((d) => d.innerChanges ?? []);
+ const isSingleInnerEdit = inner.length === 1;
+ if (!model.isInDiffEditor) {
+ if (isSingleInnerEdit && this._useCodeShifting.read(reader) !== "never" && isSingleLineInsertion(diff)) {
+ if (isSingleLineInsertionAfterPosition(diff, inlineEdit.cursorPosition)) {
+ return InlineCompletionViewKind.InsertionInline;
+ }
+ return InlineCompletionViewKind.LineReplacement;
+ }
+ if (isDeletion2(inner, inlineEdit, newText)) {
+ return InlineCompletionViewKind.Deletion;
+ }
+ if (isSingleMultiLineInsertion(diff) && this._useCodeShifting.read(reader) === "always") {
+ return InlineCompletionViewKind.InsertionMultiLine;
+ }
+ const allInnerChangesNotTooLong = inner.every((m) => TextLength.ofRange(m.originalRange).columnCount < InlineEditsWordReplacementView.MAX_LENGTH && TextLength.ofRange(m.modifiedRange).columnCount < InlineEditsWordReplacementView.MAX_LENGTH);
+ if (allInnerChangesNotTooLong && isSingleInnerEdit && numOriginalLines === 1 && numModifiedLines === 1) {
+ const modifiedText = inner.map((m) => newText.getValueOfRange(m.modifiedRange));
+ const originalText = inner.map((m) => model.inlineEdit.originalText.getValueOfRange(m.originalRange));
+ if (!modifiedText.some((v) => v.includes(" ")) && !originalText.some((v) => v.includes(" "))) {
+ if (!inner.some((m) => m.originalRange.isEmpty()) || !growEditsUntilWhitespace(inner.map((m) => new TextReplacement(m.originalRange, "")), inlineEdit.originalText).some((e) => e.range.isEmpty() && TextLength.ofRange(e.range).columnCount < InlineEditsWordReplacementView.MAX_LENGTH)) {
+ return InlineCompletionViewKind.WordReplacements;
+ }
+ }
+ }
+ }
+ if (numOriginalLines > 0 && numModifiedLines > 0) {
+ if (numOriginalLines === 1 && numModifiedLines === 1 && !model.isInDiffEditor) {
+ return InlineCompletionViewKind.LineReplacement;
+ }
+ if (this._renderSideBySide.read(reader) !== "never" && InlineEditsSideBySideView.fitsInsideViewport(this._editor, this._previewTextModel, inlineEdit, reader)) {
+ return InlineCompletionViewKind.SideBySide;
+ }
+ return InlineCompletionViewKind.LineReplacement;
+ }
+ if (model.isInDiffEditor) {
+ if (isDeletion2(inner, inlineEdit, newText)) {
+ return InlineCompletionViewKind.Deletion;
+ }
+ if (isSingleMultiLineInsertion(diff) && this._useCodeShifting.read(reader) === "always") {
+ return InlineCompletionViewKind.InsertionMultiLine;
+ }
+ }
+ return InlineCompletionViewKind.SideBySide;
+ }
+ determineRenderState(model, reader, diff, newText) {
+ const inlineEdit = model.inlineEdit;
+ let view = this.determineView(model, reader, diff, newText);
+ if (this._willRenderAboveCursor(reader, inlineEdit, view)) {
+ switch (view) {
+ case InlineCompletionViewKind.LineReplacement:
+ case InlineCompletionViewKind.WordReplacements:
+ view = InlineCompletionViewKind.SideBySide;
+ break;
+ }
+ }
+ this._previousView = { id: this.getCacheId(model), view, editorWidth: this._editor.getLayoutInfo().width, timestamp: Date.now() };
+ const inner = diff.flatMap((d) => d.innerChanges ?? []);
+ const textModel = this._editor.getModel();
+ const stringChanges = inner.map((m) => ({
+ originalRange: m.originalRange,
+ modifiedRange: m.modifiedRange,
+ original: textModel.getValueInRange(m.originalRange),
+ modified: newText.getValueOfRange(m.modifiedRange)
+ }));
+ const cursorPosition = inlineEdit.cursorPosition;
+ const startsWithEOL = stringChanges.length === 0 ? false : stringChanges[0].modified.startsWith(textModel.getEOL());
+ const viewData = {
+ cursorColumnDistance: inlineEdit.edit.replacements.length === 0 ? 0 : inlineEdit.edit.replacements[0].range.getStartPosition().column - cursorPosition.column,
+ cursorLineDistance: inlineEdit.lineEdit.lineRange.startLineNumber - cursorPosition.lineNumber + (startsWithEOL && inlineEdit.lineEdit.lineRange.startLineNumber >= cursorPosition.lineNumber ? 1 : 0),
+ lineCountOriginal: inlineEdit.lineEdit.lineRange.length,
+ lineCountModified: inlineEdit.lineEdit.newLines.length,
+ characterCountOriginal: stringChanges.reduce((acc, r) => acc + r.original.length, 0),
+ characterCountModified: stringChanges.reduce((acc, r) => acc + r.modified.length, 0),
+ disjointReplacements: stringChanges.length,
+ sameShapeReplacements: stringChanges.every((r) => r.original === stringChanges[0].original && r.modified === stringChanges[0].modified)
+ };
+ switch (view) {
+ case InlineCompletionViewKind.InsertionInline:
+ return { kind: InlineCompletionViewKind.InsertionInline, viewData };
+ case InlineCompletionViewKind.SideBySide:
+ return { kind: InlineCompletionViewKind.SideBySide, viewData };
+ case InlineCompletionViewKind.Collapsed:
+ return { kind: InlineCompletionViewKind.Collapsed, viewData };
+ case InlineCompletionViewKind.Custom:
+ return { kind: InlineCompletionViewKind.Custom, displayLocation: model.displayLocation, viewData };
+ }
+ if (view === InlineCompletionViewKind.Deletion) {
+ return {
+ kind: InlineCompletionViewKind.Deletion,
+ originalRange: inlineEdit.originalLineRange,
+ deletions: inner.map((m) => m.originalRange),
+ viewData
+ };
+ }
+ if (view === InlineCompletionViewKind.InsertionMultiLine) {
+ const change = inner[0];
+ return {
+ kind: InlineCompletionViewKind.InsertionMultiLine,
+ lineNumber: change.originalRange.startLineNumber,
+ column: change.originalRange.startColumn,
+ text: newText.getValueOfRange(change.modifiedRange),
+ viewData
+ };
+ }
+ const replacements = stringChanges.map((m) => new TextReplacement(m.originalRange, m.modified));
+ if (replacements.length === 0) {
+ return void 0;
+ }
+ if (view === InlineCompletionViewKind.WordReplacements) {
+ let grownEdits = growEditsToEntireWord(replacements, inlineEdit.originalText);
+ if (grownEdits.some((e) => e.range.isEmpty())) {
+ grownEdits = growEditsUntilWhitespace(replacements, inlineEdit.originalText);
+ }
+ return {
+ kind: InlineCompletionViewKind.WordReplacements,
+ replacements: grownEdits,
+ viewData
+ };
+ }
+ if (view === InlineCompletionViewKind.LineReplacement) {
+ return {
+ kind: InlineCompletionViewKind.LineReplacement,
+ originalRange: inlineEdit.originalLineRange,
+ modifiedRange: inlineEdit.modifiedLineRange,
+ modifiedLines: inlineEdit.modifiedLineRange.mapToLineArray((line) => newText.getLineAt(line)),
+ replacements: inner.map((m) => ({ originalRange: m.originalRange, modifiedRange: m.modifiedRange })),
+ viewData
+ };
+ }
+ return void 0;
+ }
+ _willRenderAboveCursor(reader, inlineEdit, view) {
+ const useCodeShifting = this._useCodeShifting.read(reader);
+ if (useCodeShifting === "always") {
+ return false;
+ }
+ for (const cursorPosition of inlineEdit.multiCursorPositions) {
+ if (view === InlineCompletionViewKind.WordReplacements && cursorPosition.lineNumber === inlineEdit.originalLineRange.startLineNumber + 1) {
+ return true;
+ }
+ if (view === InlineCompletionViewKind.LineReplacement && cursorPosition.lineNumber >= inlineEdit.originalLineRange.endLineNumberExclusive && cursorPosition.lineNumber < inlineEdit.modifiedLineRange.endLineNumberExclusive + inlineEdit.modifiedLineRange.length) {
+ return true;
+ }
+ }
+ return false;
+ }
+ _viewHasBeenShownLongerThan(durationMs) {
+ const viewCreationTime = this._previousView?.timestamp;
+ if (!viewCreationTime) {
+ throw new BugIndicatingError("viewHasBeenShownLongThan called before a view has been shown");
+ }
+ const currentTime = Date.now();
+ return currentTime - viewCreationTime >= durationMs;
+ }
+};
+InlineEditsView = InlineEditsView_1 = __decorate129([
+ __param123(5, IInstantiationService)
+], InlineEditsView);
+function isSingleLineInsertion(diff) {
+ return diff.every((m) => m.innerChanges.every((r) => isWordInsertion(r)));
+ function isWordInsertion(r) {
+ if (!r.originalRange.isEmpty()) {
+ return false;
+ }
+ const isInsertionWithinLine = r.modifiedRange.startLineNumber === r.modifiedRange.endLineNumber;
+ if (!isInsertionWithinLine) {
+ return false;
+ }
+ return true;
+ }
+}
+function isSingleLineInsertionAfterPosition(diff, position) {
+ if (!position) {
+ return false;
+ }
+ if (!isSingleLineInsertion(diff)) {
+ return false;
+ }
+ const pos = position;
+ return diff.every((m) => m.innerChanges.every((r) => isStableWordInsertion(r)));
+ function isStableWordInsertion(r) {
+ const insertPosition = r.originalRange.getStartPosition();
+ if (pos.isBeforeOrEqual(insertPosition)) {
+ return true;
+ }
+ if (insertPosition.lineNumber < pos.lineNumber) {
+ return true;
+ }
+ return false;
+ }
+}
+function isSingleMultiLineInsertion(diff) {
+ const inner = diff.flatMap((d) => d.innerChanges ?? []);
+ if (inner.length !== 1) {
+ return false;
+ }
+ const change = inner[0];
+ if (!change.originalRange.isEmpty()) {
+ return false;
+ }
+ if (change.modifiedRange.startLineNumber === change.modifiedRange.endLineNumber) {
+ return false;
+ }
+ return true;
+}
+function isDeletion2(inner, inlineEdit, newText) {
+ const innerValues = inner.map((m) => ({ original: inlineEdit.originalText.getValueOfRange(m.originalRange), modified: newText.getValueOfRange(m.modifiedRange) }));
+ return innerValues.every(({ original, modified }) => modified.trim() === "" && original.length > 0 && (original.length > modified.length || original.trim() !== ""));
+}
+function growEditsToEntireWord(replacements, originalText) {
+ return _growEdits(replacements, originalText, (char) => /^[a-zA-Z]$/.test(char));
+}
+function growEditsUntilWhitespace(replacements, originalText) {
+ return _growEdits(replacements, originalText, (char) => !/^\s$/.test(char));
+}
+function _growEdits(replacements, originalText, fn) {
+ const result = [];
+ replacements.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
+ for (const edit2 of replacements) {
+ let startIndex = edit2.range.startColumn - 1;
+ let endIndex = edit2.range.endColumn - 2;
+ let prefix = "";
+ let suffix = "";
+ const startLineContent = originalText.getLineAt(edit2.range.startLineNumber);
+ const endLineContent = originalText.getLineAt(edit2.range.endLineNumber);
+ if (isIncluded(startLineContent[startIndex])) {
+ while (isIncluded(startLineContent[startIndex - 1])) {
+ prefix = startLineContent[startIndex - 1] + prefix;
+ startIndex--;
+ }
+ }
+ if (isIncluded(endLineContent[endIndex]) || endIndex < startIndex) {
+ while (isIncluded(endLineContent[endIndex + 1])) {
+ suffix += endLineContent[endIndex + 1];
+ endIndex++;
+ }
+ }
+ let newEdit = new TextReplacement(new Range(edit2.range.startLineNumber, startIndex + 1, edit2.range.endLineNumber, endIndex + 2), prefix + edit2.text + suffix);
+ if (result.length > 0 && Range.areIntersectingOrTouching(result[result.length - 1].range, newEdit.range)) {
+ newEdit = TextReplacement.joinReplacements([result.pop(), newEdit], originalText);
+ }
+ result.push(newEdit);
+ }
+ function isIncluded(c) {
+ if (c === void 0) {
+ return false;
+ }
+ return fn(c);
+ }
+ return result;
+}
+function getGhostTextTopOffset(ghostTextIndicator, editor2) {
+ const replacements = ghostTextIndicator.model.inlineEdit.edit.replacements;
+ if (replacements.length !== 1) {
+ return 0;
+ }
+ const textModel = editor2.getModel();
+ if (!textModel) {
+ return 0;
+ }
+ const EOL = textModel.getEOL();
+ const replacement = replacements[0];
+ if (replacement.range.isEmpty() && replacement.text.startsWith(EOL)) {
+ const lineHeight = editor2.getLineHeightForPosition(replacement.range.getStartPosition());
+ return countPrefixRepeats(replacement.text, EOL) * lineHeight;
+ }
+ return 0;
+}
+function countPrefixRepeats(str, prefix) {
+ if (!prefix.length) {
+ return 0;
+ }
+ let count = 0;
+ let i2 = 0;
+ while (str.startsWith(prefix, i2)) {
+ count++;
+ i2 += prefix.length;
+ }
+ return count;
+}
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsViewProducer.js
+var __decorate130 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param124 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineEditsViewAndDiffProducer = class InlineEditsViewAndDiffProducer2 extends Disposable {
+ static {
+ this.hot = createHotClass(this);
+ }
+ constructor(_editor, _edit, _model, _focusIsInMenu, instantiationService) {
+ super();
+ this._editor = _editor;
+ this._edit = _edit;
+ this._model = _model;
+ this._focusIsInMenu = _focusIsInMenu;
+ this._inlineEdit = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return void 0;
+ }
+ const inlineEdit = this._edit.read(reader);
+ if (!inlineEdit) {
+ return void 0;
+ }
+ const textModel = this._editor.getModel();
+ if (!textModel) {
+ return void 0;
+ }
+ const editOffset = model.inlineEditState.read(void 0)?.inlineCompletion.updatedEdit;
+ if (!editOffset) {
+ return void 0;
+ }
+ const edits = editOffset.replacements.map((e) => {
+ const innerEditRange = Range.fromPositions(textModel.getPositionAt(e.replaceRange.start), textModel.getPositionAt(e.replaceRange.endExclusive));
+ return new TextReplacement(innerEditRange, e.newText);
+ });
+ const diffEdits = new TextEdit(edits);
+ const text2 = new TextModelText(textModel);
+ return new InlineEditWithChanges(text2, diffEdits, model.primaryPosition.read(void 0), model.allPositions.read(void 0), inlineEdit.commands, inlineEdit.inlineCompletion);
+ });
+ this._inlineEditModel = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return void 0;
+ }
+ const edit2 = this._inlineEdit.read(reader);
+ if (!edit2) {
+ return void 0;
+ }
+ const tabAction = derived(this, (reader2) => {
+ if (this._editorObs.isFocused.read(reader2)) {
+ if (model.tabShouldJumpToInlineEdit.read(reader2)) {
+ return InlineEditTabAction.Jump;
+ }
+ if (model.tabShouldAcceptInlineEdit.read(reader2)) {
+ return InlineEditTabAction.Accept;
+ }
+ }
+ return InlineEditTabAction.Inactive;
+ });
+ return new InlineEditModel(model, edit2, tabAction);
+ });
+ this._inlineEditHost = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return void 0;
+ }
+ return new InlineEditHost(model);
+ });
+ this._ghostTextIndicator = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ if (!model) {
+ return void 0;
+ }
+ const state = model.inlineCompletionState.read(reader);
+ if (!state) {
+ return void 0;
+ }
+ const inlineCompletion = state.inlineCompletion;
+ if (!inlineCompletion) {
+ return void 0;
+ }
+ if (!inlineCompletion.showInlineEditMenu) {
+ return void 0;
+ }
+ const lineRange = LineRange.ofLength(state.primaryGhostText.lineNumber, 1);
+ return new GhostTextIndicator(this._editor, model, lineRange, inlineCompletion);
+ });
+ this._editorObs = observableCodeEditor(this._editor);
+ this._register(instantiationService.createInstance(InlineEditsView, this._editor, this._inlineEditHost, this._inlineEditModel, this._ghostTextIndicator, this._focusIsInMenu));
+ }
+};
+InlineEditsViewAndDiffProducer = __decorate130([
+ __param124(4, IInstantiationService)
+], InlineEditsViewAndDiffProducer);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineCompletionsView.js
+var __decorate131 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param125 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineCompletionsView = class InlineCompletionsView2 extends Disposable {
+ constructor(_editor, _model, _focusIsInMenu, _instantiationService) {
+ super();
+ this._editor = _editor;
+ this._model = _model;
+ this._focusIsInMenu = _focusIsInMenu;
+ this._instantiationService = _instantiationService;
+ this._ghostTexts = derived(this, (reader) => {
+ const model = this._model.read(reader);
+ return model?.ghostTexts.read(reader) ?? [];
+ });
+ this._stablizedGhostTexts = convertItemsToStableObservables(this._ghostTexts, this._store);
+ this._editorObs = observableCodeEditor(this._editor);
+ this._ghostTextWidgets = mapObservableArrayCached(this, this._stablizedGhostTexts, (ghostText, store) => derivedDisposable((reader) => this._instantiationService.createInstance(GhostTextView.hot.read(reader), this._editor, {
+ ghostText,
+ warning: this._model.map((m, reader2) => {
+ const warning = m?.warning?.read(reader2);
+ return warning ? { icon: warning.icon } : void 0;
+ }),
+ minReservedLineCount: constObservable(0),
+ targetTextModel: this._model.map((v) => v?.textModel),
+ handleInlineCompletionShown: this._model.map((model, reader2) => {
+ const inlineCompletion = model?.inlineCompletionState.read(reader2)?.inlineCompletion;
+ if (inlineCompletion) {
+ return (viewData) => model.handleInlineSuggestionShown(inlineCompletion, InlineCompletionViewKind.GhostText, viewData);
+ }
+ return () => {
+ };
+ })
+ }, this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((v) => ({ syntaxHighlightingEnabled: v.syntaxHighlightingEnabled })), false, false)).recomputeInitiallyAndOnChange(store)).recomputeInitiallyAndOnChange(this._store);
+ this._inlineEdit = derived(this, (reader) => this._model.read(reader)?.inlineEditState.read(reader)?.inlineEdit);
+ this._everHadInlineEdit = derivedObservableWithCache(this, (reader, last) => last || !!this._inlineEdit.read(reader) || !!this._model.read(reader)?.inlineCompletionState.read(reader)?.inlineCompletion?.showInlineEditMenu);
+ this._inlineEditWidget = derivedDisposable((reader) => {
+ if (!this._everHadInlineEdit.read(reader)) {
+ return void 0;
+ }
+ return this._instantiationService.createInstance(InlineEditsViewAndDiffProducer.hot.read(reader), this._editor, this._inlineEdit, this._model, this._focusIsInMenu);
+ }).recomputeInitiallyAndOnChange(this._store);
+ this._fontFamily = this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((val) => val.fontFamily);
+ this._register(createStyleSheetFromObservable(derived((reader) => {
+ const fontFamily = this._fontFamily.read(reader);
+ return `
+.monaco-editor .ghost-text-decoration,
+.monaco-editor .ghost-text-decoration-preview,
+.monaco-editor .ghost-text {
+ font-family: ${fontFamily};
+}`;
+ })));
+ this._register(new InlineCompletionsHintsWidget(this._editor, this._model, this._instantiationService));
+ }
+ shouldShowHoverAtViewZone(viewZoneId) {
+ return this._ghostTextWidgets.get()[0]?.get().ownsViewZone(viewZoneId) ?? false;
+ }
+};
+InlineCompletionsView = __decorate131([
+ __param125(3, IInstantiationService)
+], InlineCompletionsView);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.js
+var __decorate132 = function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for (var i2 = decorators.length - 1; i2 >= 0; i2--) if (d = decorators[i2]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+var __param126 = function(paramIndex, decorator) {
+ return function(target, key) {
+ decorator(target, key, paramIndex);
+ };
+};
+var InlineCompletionsController_1;
+var InlineCompletionsController = class InlineCompletionsController2 extends Disposable {
+ static {
+ InlineCompletionsController_1 = this;
+ }
+ static {
+ this._instances = /* @__PURE__ */ new Set();
+ }
+ static {
+ this.hot = createHotClass(this);
+ }
+ static {
+ this.ID = "editor.contrib.inlineCompletionsController";
+ }
+ /**
+ * Find the controller in the focused editor or in the outer editor (if applicable)
+ */
+ static getInFocusedEditorOrParent(accessor) {
+ const outerEditor = getOuterEditor(accessor);
+ if (!outerEditor) {
+ return null;
+ }
+ return InlineCompletionsController_1.get(outerEditor);
+ }
+ static get(editor2) {
+ return hotClassGetOriginalInstance(editor2.getContribution(InlineCompletionsController_1.ID));
+ }
+ constructor(editor2, _instantiationService, _contextKeyService, _configurationService, _commandService, _debounceService, _languageFeaturesService, _accessibilitySignalService, _keybindingService, _accessibilityService) {
+ super();
+ this.editor = editor2;
+ this._instantiationService = _instantiationService;
+ this._contextKeyService = _contextKeyService;
+ this._configurationService = _configurationService;
+ this._commandService = _commandService;
+ this._debounceService = _debounceService;
+ this._languageFeaturesService = _languageFeaturesService;
+ this._accessibilitySignalService = _accessibilitySignalService;
+ this._keybindingService = _keybindingService;
+ this._accessibilityService = _accessibilityService;
+ this._editorObs = observableCodeEditor(this.editor);
+ this._positions = derived(this, (reader) => this._editorObs.selections.read(reader)?.map((s) => s.getEndPosition()) ?? [new Position(1, 1)]);
+ this._suggestWidgetAdapter = this._register(new ObservableSuggestWidgetAdapter(this._editorObs, (item) => this.model.get()?.handleSuggestAccepted(item), () => this.model.get()?.selectedInlineCompletion.get()?.getSingleTextEdit()));
+ this._enabledInConfig = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).enabled);
+ this._isScreenReaderEnabled = observableFromEvent(this, this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized());
+ this._editorDictationInProgress = observableFromEvent(this, this._contextKeyService.onDidChangeContext, () => this._contextKeyService.getContext(this.editor.getDomNode()).getValue("editorDictation.inProgress") === true);
+ this._enabled = derived(this, (reader) => this._enabledInConfig.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._editorDictationInProgress.read(reader)));
+ this._debounceValue = this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider, "InlineCompletionsDebounce", { min: 50, max: 50 });
+ this._focusIsInMenu = observableValue(this, false);
+ this._focusIsInEditorOrMenu = derived(this, (reader) => {
+ const editorHasFocus = this._editorObs.isFocused.read(reader);
+ const menuHasFocus = this._focusIsInMenu.read(reader);
+ return editorHasFocus || menuHasFocus;
+ });
+ this._cursorIsInIndentation = derived(this, (reader) => {
+ const cursorPos = this._editorObs.cursorPosition.read(reader);
+ if (cursorPos === null) {
+ return false;
+ }
+ const model = this._editorObs.model.read(reader);
+ if (!model) {
+ return false;
+ }
+ this._editorObs.versionId.read(reader);
+ const indentMaxColumn = model.getLineIndentColumn(cursorPos.lineNumber);
+ return cursorPos.column <= indentMaxColumn;
+ });
+ this.model = derivedDisposable(this, (reader) => {
+ if (this._editorObs.isReadonly.read(reader)) {
+ return void 0;
+ }
+ const textModel = this._editorObs.model.read(reader);
+ if (!textModel) {
+ return void 0;
+ }
+ const model = this._instantiationService.createInstance(InlineCompletionsModel, textModel, this._suggestWidgetAdapter.selectedItem, this._editorObs.versionId, this._positions, this._debounceValue, this._enabled, this.editor);
+ return model;
+ }).recomputeInitiallyAndOnChange(this._store);
+ this._playAccessibilitySignal = observableSignal(this);
+ this._hideInlineEditOnSelectionChange = this._editorObs.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).map((val) => true);
+ this._view = this._register(this._instantiationService.createInstance(InlineCompletionsView, this.editor, this.model, this._focusIsInMenu));
+ InlineCompletionsController_1._instances.add(this);
+ this._register(toDisposable(() => InlineCompletionsController_1._instances.delete(this)));
+ this._register(autorun((reader) => {
+ const model = this.model.read(reader);
+ if (!model) {
+ return;
+ }
+ const state = model.state.read(reader);
+ if (!state) {
+ return;
+ }
+ if (!this._focusIsInEditorOrMenu.read(void 0)) {
+ return;
+ }
+ const nextEditUri = state.kind === "inlineEdit" ? state.nextEditUri : void 0;
+ for (const ctrl of InlineCompletionsController_1._instances) {
+ if (ctrl === this) {
+ continue;
+ } else if (nextEditUri && isEqual(nextEditUri, ctrl.editor.getModel()?.uri)) {
+ ctrl.model.read(void 0)?.trigger();
+ } else {
+ ctrl.reject();
+ }
+ }
+ }));
+ this._register(autorun((reader) => {
+ const model = this.model.read(reader);
+ const uri = this.editor.getModel()?.uri;
+ if (!model || !uri) {
+ return;
+ }
+ reader.store.add(model.onDidAccept(() => {
+ for (const ctrl of InlineCompletionsController_1._instances) {
+ if (ctrl === this) {
+ continue;
+ }
+ const state = ctrl.model.read(void 0)?.state.read(void 0);
+ if (state?.kind === "inlineEdit" && isEqual(state.nextEditUri, uri)) {
+ ctrl.model.read(void 0)?.stop("automatic");
+ }
+ }
+ }));
+ }));
+ this._register(runOnChange(this._editorObs.onDidType, (_value, _changes) => {
+ if (this._enabled.get()) {
+ this.model.get()?.trigger();
+ }
+ }));
+ this._register(runOnChange(this._editorObs.onDidPaste, (_value, _changes) => {
+ if (this._enabled.get()) {
+ this.model.get()?.trigger();
+ }
+ }));
+ const triggerCommands = /* @__PURE__ */ new Set([
+ CoreEditingCommands.Tab.id,
+ CoreEditingCommands.DeleteLeft.id,
+ CoreEditingCommands.DeleteRight.id,
+ inlineSuggestCommitId,
+ "acceptSelectedSuggestion",
+ InsertLineAfterAction.ID,
+ InsertLineBeforeAction.ID,
+ FIND_IDS.NextMatchFindAction,
+ ...TriggerInlineEditCommandsRegistry.getRegisteredCommands()
+ ]);
+ this._register(this._commandService.onDidExecuteCommand((e) => {
+ if (triggerCommands.has(e.commandId) && editor2.hasTextFocus() && this._enabled.get()) {
+ let noDelay = false;
+ if (e.commandId === inlineSuggestCommitId) {
+ noDelay = true;
+ }
+ this._editorObs.forceUpdate((tx) => {
+ this.model.get()?.trigger(tx, { noDelay });
+ });
+ }
+ }));
+ this._register(runOnChange(this._editorObs.selections, (_value, _, changes) => {
+ if (changes.some((e) => e.reason === 3 || e.source === "api")) {
+ if (!this._hideInlineEditOnSelectionChange.get() && this.model.get()?.state.get()?.kind === "inlineEdit") {
+ return;
+ }
+ const m = this.model.get();
+ if (!m) {
+ return;
+ }
+ if (m.state.get()?.kind === "ghostText") {
+ this.model.get()?.stop();
+ }
+ }
+ }));
+ this._register(autorun((reader) => {
+ const isFocused = this._focusIsInEditorOrMenu.read(reader);
+ const model = this.model.read(void 0);
+ if (isFocused) {
+ const state = model?.state.read(void 0);
+ if (!state || state.kind !== "inlineEdit" || !state.nextEditUri) {
+ transaction((tx) => {
+ for (const ctrl of InlineCompletionsController_1._instances) {
+ if (ctrl !== this) {
+ ctrl.model.read(void 0)?.stop("automatic", tx);
+ }
+ }
+ });
+ }
+ return;
+ }
+ if (this._contextKeyService.getContextKeyValue("accessibleViewIsShown") || this._configurationService.getValue("editor.inlineSuggest.keepOnBlur") || editor2.getOption(
+ 71
+ /* EditorOption.inlineSuggest */
+ ).keepOnBlur || InlineSuggestionHintsContentWidget.dropDownVisible) {
+ return;
+ }
+ if (!model) {
+ return;
+ }
+ if (model.state.read(void 0)?.inlineCompletion?.isFromExplicitRequest && model.inlineEditAvailable.read(void 0)) {
+ return;
+ }
+ transaction((tx) => {
+ model.stop("automatic", tx);
+ });
+ }));
+ this._register(autorun((reader) => {
+ const state = this.model.read(reader)?.inlineCompletionState.read(reader);
+ if (state?.suggestItem) {
+ if (state.primaryGhostText.lineCount >= 2) {
+ this._suggestWidgetAdapter.forceRenderingAbove();
+ }
+ } else {
+ this._suggestWidgetAdapter.stopForceRenderingAbove();
+ }
+ }));
+ this._register(toDisposable(() => {
+ this._suggestWidgetAdapter.stopForceRenderingAbove();
+ }));
+ const currentInlineCompletionBySemanticId = derivedObservableWithCache(this, (reader, last) => {
+ const model = this.model.read(reader);
+ const state = model?.state.read(reader);
+ if (this._suggestWidgetAdapter.selectedItem.get()) {
+ return last;
+ }
+ return state?.inlineCompletion?.semanticId;
+ });
+ this._register(runOnChangeWithStore(derived((reader) => {
+ this._playAccessibilitySignal.read(reader);
+ currentInlineCompletionBySemanticId.read(reader);
+ return {};
+ }), async (_value, _, _deltas, store) => {
+ let model = this.model.get();
+ let state = model?.state.get();
+ if (!state || !model) {
+ return;
+ }
+ await timeout(50, cancelOnDispose(store));
+ await waitForState(this._suggestWidgetAdapter.selectedItem, isUndefined, () => false, cancelOnDispose(store));
+ model = this.model.get();
+ state = model?.state.get();
+ if (!state || !model) {
+ return;
+ }
+ const lineText = state.kind === "ghostText" ? model.textModel.getLineContent(state.primaryGhostText.lineNumber) : "";
+ this._accessibilitySignalService.playSignal(state.kind === "ghostText" ? AccessibilitySignal.inlineSuggestion : AccessibilitySignal.nextEditSuggestion);
+ if (this.editor.getOption(
+ 12
+ /* EditorOption.screenReaderAnnounceInlineSuggestion */
+ )) {
+ if (state.kind === "ghostText") {
+ this._provideScreenReaderUpdate(state.primaryGhostText.renderForScreenReader(lineText));
+ } else {
+ this._provideScreenReaderUpdate("");
+ }
+ }
+ }));
+ this._register(this._configurationService.onDidChangeConfiguration((e) => {
+ if (e.affectsConfiguration("accessibility.verbosity.inlineCompletions")) {
+ this.editor.updateOptions({ inlineCompletionsAccessibilityVerbose: this._configurationService.getValue("accessibility.verbosity.inlineCompletions") });
+ }
+ }));
+ this.editor.updateOptions({ inlineCompletionsAccessibilityVerbose: this._configurationService.getValue("accessibility.verbosity.inlineCompletions") });
+ const contextKeySvcObs = new ObservableContextKeyService(this._contextKeyService);
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.cursorInIndentation, this._cursorIsInIndentation));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.hasSelection, (reader) => !this._editorObs.cursorSelection.read(reader)?.isEmpty()));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.cursorAtInlineEdit, this.model.map((m, reader) => m?.inlineEditState?.read(reader)?.cursorAtInlineEdit.read(reader))));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.tabShouldAcceptInlineEdit, this.model.map((m, r) => !!m?.tabShouldAcceptInlineEdit.read(r))));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.tabShouldJumpToInlineEdit, this.model.map((m, r) => !!m?.tabShouldJumpToInlineEdit.read(r))));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.inlineEditVisible, (reader) => this.model.read(reader)?.inlineEditState.read(reader) !== void 0));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.inlineSuggestionHasIndentation, (reader) => this.model.read(reader)?.getIndentationInfo(reader)?.startsWithIndentation));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.inlineSuggestionHasIndentationLessThanTabSize, (reader) => this.model.read(reader)?.getIndentationInfo(reader)?.startsWithIndentationLessThanTabSize));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.suppressSuggestions, (reader) => {
+ const model = this.model.read(reader);
+ const state = model?.inlineCompletionState.read(reader);
+ return state?.primaryGhostText && state?.inlineCompletion ? state.inlineCompletion.source.inlineSuggestions.suppressSuggestions : void 0;
+ }));
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.inlineSuggestionVisible, (reader) => {
+ const model = this.model.read(reader);
+ const state = model?.inlineCompletionState.read(reader);
+ return !!state?.inlineCompletion && state?.primaryGhostText !== void 0 && !state?.primaryGhostText.isEmpty();
+ }));
+ const firstGhostTextPos = derived(this, (reader) => {
+ const model = this.model.read(reader);
+ const state = model?.inlineCompletionState.read(reader);
+ const primaryGhostText = state?.primaryGhostText;
+ if (!primaryGhostText || primaryGhostText.isEmpty()) {
+ return void 0;
+ }
+ const firstPartPos = new Position(primaryGhostText.lineNumber, primaryGhostText.parts[0].column);
+ return firstPartPos;
+ });
+ this._register(contextKeySvcObs.bind(InlineCompletionContextKeys.cursorBeforeGhostText, (reader) => {
+ const firstPartPos = firstGhostTextPos.read(reader);
+ if (!firstPartPos) {
+ return false;
+ }
+ const cursorPos = this._editorObs.cursorPosition.read(reader);
+ if (!cursorPos) {
+ return false;
+ }
+ return firstPartPos.equals(cursorPos);
+ }));
+ this._register(this._instantiationService.createInstance(TextModelChangeRecorder, this.editor));
+ }
+ playAccessibilitySignal(tx) {
+ this._playAccessibilitySignal.trigger(tx);
+ }
+ _provideScreenReaderUpdate(content) {
+ const accessibleViewShowing = this._contextKeyService.getContextKeyValue("accessibleViewIsShown");
+ const accessibleViewKeybinding = this._keybindingService.lookupKeybinding("editor.action.accessibleView");
+ let hint;
+ if (!accessibleViewShowing && accessibleViewKeybinding && this.editor.getOption(
+ 169
+ /* EditorOption.inlineCompletionsAccessibilityVerbose */
+ )) {
+ hint = localize(1204, "Inspect this in the accessible view ({0})", accessibleViewKeybinding.getAriaLabel());
+ }
+ alert(hint ? content + ", " + hint : content);
+ }
+ shouldShowHoverAt(range2) {
+ const ghostText = this.model.get()?.primaryGhostText.get();
+ if (!ghostText) {
+ return false;
+ }
+ return ghostText.parts.some((p) => range2.containsPosition(new Position(ghostText.lineNumber, p.column)));
+ }
+ shouldShowHoverAtViewZone(viewZoneId) {
+ return this._view.shouldShowHoverAtViewZone(viewZoneId);
+ }
+ reject() {
+ transaction((tx) => {
+ const m = this.model.get();
+ if (m) {
+ m.stop("explicitCancel", tx);
+ if (this._focusIsInEditorOrMenu.get()) {
+ for (const ctrl of InlineCompletionsController_1._instances) {
+ if (ctrl !== this) {
+ ctrl.model.get()?.stop("automatic", tx);
+ }
+ }
+ }
+ }
+ });
+ }
+ jump() {
+ const m = this.model.get();
+ if (m) {
+ m.jump();
+ }
+ }
+};
+InlineCompletionsController = InlineCompletionsController_1 = __decorate132([
+ __param126(1, IInstantiationService),
+ __param126(2, IContextKeyService),
+ __param126(3, IConfigurationService),
+ __param126(4, ICommandService),
+ __param126(5, ILanguageFeatureDebounceService),
+ __param126(6, ILanguageFeaturesService),
+ __param126(7, IAccessibilitySignalService),
+ __param126(8, IKeybindingService),
+ __param126(9, IAccessibilityService)
+], InlineCompletionsController);
+
+// node_modules/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/controller/commands.js
+var ShowNextInlineSuggestionAction = class _ShowNextInlineSuggestionAction extends EditorAction {
+ static {
+ this.ID = showNextInlineSuggestionActionId;
+ }
+ constructor() {
+ super({
+ id: _ShowNextInlineSuggestionAction.ID,
+ label: localize2(1183, "Show Next Inline Suggestion"),
+ precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
+ kbOpts: {
+ weight: 100,
+ primary: 512 | 94
+ }
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.get(editor2);
+ controller?.model.get()?.next();
+ }
+};
+var ShowPreviousInlineSuggestionAction = class _ShowPreviousInlineSuggestionAction extends EditorAction {
+ static {
+ this.ID = showPreviousInlineSuggestionActionId;
+ }
+ constructor() {
+ super({
+ id: _ShowPreviousInlineSuggestionAction.ID,
+ label: localize2(1184, "Show Previous Inline Suggestion"),
+ precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
+ kbOpts: {
+ weight: 100,
+ primary: 512 | 92
+ }
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.get(editor2);
+ controller?.model.get()?.previous();
+ }
+};
+var providerIdSchemaUri = "vscode://schemas/inlineCompletionProviderIdArgs";
+function inlineCompletionProviderGetMatcher(provider) {
+ const result = [];
+ if (provider.providerId) {
+ result.push(provider.providerId.toStringWithoutVersion());
+ result.push(provider.providerId.extensionId + ":*");
+ }
+ return result;
+}
+var argsValidator = vUnion(vObj({
+ showNoResultNotification: vOptionalProp(vBoolean()),
+ providerId: vOptionalProp(vWithJsonSchemaRef(providerIdSchemaUri, vString())),
+ explicit: vOptionalProp(vBoolean())
+}), vUndefined());
+var TriggerInlineSuggestionAction = class extends EditorAction {
+ constructor() {
+ super({
+ id: "editor.action.inlineSuggest.trigger",
+ label: localize2(1185, "Trigger Inline Suggestion"),
+ precondition: EditorContextKeys.writable,
+ metadata: {
+ description: localize(1172, "Triggers an inline suggestion in the editor."),
+ args: [{
+ name: "args",
+ description: localize(1173, "Options for triggering inline suggestions."),
+ isOptional: true,
+ schema: argsValidator.getJSONSchema()
+ }]
+ }
+ });
+ }
+ async run(accessor, editor2, args) {
+ const notificationService = accessor.get(INotificationService);
+ const languageFeaturesService = accessor.get(ILanguageFeaturesService);
+ const controller = InlineCompletionsController.get(editor2);
+ const validatedArgs = argsValidator.validateOrThrow(args);
+ const provider = validatedArgs?.providerId ? languageFeaturesService.inlineCompletionsProvider.all(editor2.getModel()).find((p) => inlineCompletionProviderGetMatcher(p).some((m) => m === validatedArgs.providerId)) : void 0;
+ await asyncTransaction(async (tx) => {
+ await controller?.model.get()?.trigger(tx, {
+ provider,
+ explicit: validatedArgs?.explicit ?? true
+ });
+ controller?.playAccessibilitySignal(tx);
+ });
+ if (validatedArgs?.showNoResultNotification) {
+ if (!controller?.model.get()?.state.get()) {
+ notificationService.notify({
+ severity: Severity2.Info,
+ message: localize(1174, "No inline suggestion is available.")
+ });
+ }
+ }
+ }
+};
+var AcceptNextWordOfInlineCompletion = class extends EditorAction {
+ constructor() {
+ super({
+ id: "editor.action.inlineSuggest.acceptNextWord",
+ label: localize2(1186, "Accept Next Word Of Inline Suggestion"),
+ precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
+ kbOpts: {
+ weight: 100 + 1,
+ primary: 2048 | 17,
+ kbExpr: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible, InlineCompletionContextKeys.cursorBeforeGhostText, CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())
+ },
+ menuOpts: [{
+ menuId: MenuId.InlineSuggestionToolbar,
+ title: localize(1175, "Accept Word"),
+ group: "primary",
+ order: 2
+ }]
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.get(editor2);
+ await controller?.model.get()?.acceptNextWord();
+ }
+};
+var AcceptNextLineOfInlineCompletion = class extends EditorAction {
+ constructor() {
+ super({
+ id: "editor.action.inlineSuggest.acceptNextLine",
+ label: localize2(1187, "Accept Next Line Of Inline Suggestion"),
+ precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
+ kbOpts: {
+ weight: 100 + 1
+ },
+ menuOpts: [{
+ menuId: MenuId.InlineSuggestionToolbar,
+ title: localize(1176, "Accept Line"),
+ group: "secondary",
+ order: 2
+ }]
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.get(editor2);
+ await controller?.model.get()?.acceptNextLine();
+ }
+};
+var AcceptInlineCompletion = class extends EditorAction {
+ constructor() {
+ super({
+ id: inlineSuggestCommitId,
+ label: localize2(1188, "Accept Inline Suggestion"),
+ precondition: ContextKeyExpr.or(InlineCompletionContextKeys.inlineSuggestionVisible, InlineCompletionContextKeys.inlineEditVisible),
+ menuOpts: [{
+ menuId: MenuId.InlineSuggestionToolbar,
+ title: localize(1177, "Accept"),
+ group: "primary",
+ order: 2
+ }, {
+ menuId: MenuId.InlineEditsActions,
+ title: localize(1178, "Accept"),
+ group: "primary",
+ order: 2
+ }],
+ kbOpts: [
+ {
+ primary: 2,
+ weight: 200,
+ kbExpr: ContextKeyExpr.or(ContextKeyExpr.and(InlineCompletionContextKeys.inlineSuggestionVisible, EditorContextKeys.tabMovesFocus.toNegated(), Context.Visible.toNegated(), EditorContextKeys.hoverFocused.toNegated(), InlineCompletionContextKeys.hasSelection.toNegated(), InlineCompletionContextKeys.inlineSuggestionHasIndentationLessThanTabSize), ContextKeyExpr.and(InlineCompletionContextKeys.inlineEditVisible, EditorContextKeys.tabMovesFocus.toNegated(), Context.Visible.toNegated(), EditorContextKeys.hoverFocused.toNegated(), InlineCompletionContextKeys.tabShouldAcceptInlineEdit))
+ }
+ ]
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.getInFocusedEditorOrParent(accessor);
+ if (controller) {
+ controller.model.get()?.accept(controller.editor);
+ controller.editor.focus();
+ }
+ }
+};
+KeybindingsRegistry.registerKeybindingRule({
+ id: inlineSuggestCommitId,
+ weight: 202,
+ // greater than jump
+ primary: 2,
+ when: ContextKeyExpr.and(InlineCompletionContextKeys.inInlineEditsPreviewEditor)
+});
+var JumpToNextInlineEdit = class extends EditorAction {
+ constructor() {
+ super({
+ id: jumpToNextInlineEditId,
+ label: localize2(1189, "Jump to next inline edit"),
+ precondition: InlineCompletionContextKeys.inlineEditVisible,
+ menuOpts: [{
+ menuId: MenuId.InlineEditsActions,
+ title: localize(1179, "Jump"),
+ group: "primary",
+ order: 1,
+ when: InlineCompletionContextKeys.cursorAtInlineEdit.toNegated()
+ }],
+ kbOpts: {
+ primary: 2,
+ weight: 201,
+ kbExpr: ContextKeyExpr.and(InlineCompletionContextKeys.inlineEditVisible, EditorContextKeys.tabMovesFocus.toNegated(), Context.Visible.toNegated(), EditorContextKeys.hoverFocused.toNegated(), InlineCompletionContextKeys.tabShouldJumpToInlineEdit)
+ }
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.get(editor2);
+ if (controller) {
+ controller.jump();
+ }
+ }
+};
+var HideInlineCompletion = class _HideInlineCompletion extends EditorAction {
+ static {
+ this.ID = hideInlineCompletionId;
+ }
+ constructor() {
+ super({
+ id: _HideInlineCompletion.ID,
+ label: localize2(1190, "Hide Inline Suggestion"),
+ precondition: ContextKeyExpr.or(InlineCompletionContextKeys.inlineSuggestionVisible, InlineCompletionContextKeys.inlineEditVisible),
+ kbOpts: {
+ weight: 100 + 90,
+ // same as hiding the suggest widget
+ primary: 9
+ },
+ menuOpts: [{
+ menuId: MenuId.InlineEditsActions,
+ title: localize(1180, "Reject"),
+ group: "primary",
+ order: 3
+ }]
+ });
+ }
+ async run(accessor, editor2) {
+ const controller = InlineCompletionsController.getInFocusedEditorOrParent(accessor);
+ transaction((tx) => {
+ controller?.model.get()?.stop("explicitCancel", tx);
+ });
+ controller?.editor.focus();
+ }
+};
+var ToggleInlineCompletionShowCollapsed = class _ToggleInlineCompletionShowCollapsed extends EditorAction {
+ static {
+ this.ID = toggleShowCollapsedId;
+ }
+ constructor() {
+ super({
+ id: _ToggleInlineCompletionShowCollapsed.ID,
+ label: localize2(1191, "Toggle Inline Suggestions Show Collapsed"),
+ precondition: ContextKeyExpr.true()
+ });
+ }
+ async run(accessor, editor2) {
+ const configurationService = accessor.get(IConfigurationService);
+ const showCollapsed = configurationService.getValue("editor.inlineSuggest.edits.showCollapsed");
+ configurationService.updateValue("editor.inlineSuggest.edits.showCollapsed", !showCollapsed);
+ }
+};
+KeybindingsRegistry.registerKeybindingRule({
+ id: HideInlineCompletion.ID,
+ weight: -1,
+ // very weak
+ primary: 9,
+ secondary: [
+ 1024 | 9
+ /* KeyCode.Escape */
+ ],
+ when: ContextKeyExpr.and(InlineCompletionContextKeys.inInlineEditsPreviewEditor)
+});
+var ToggleAlwaysShowInlineSuggestionToolbar = class _ToggleAlwaysShowInlineSuggestionToolbar extends Action2 {
+ static {
+ this.ID = "editor.action.inlineSuggest.toggleAlwaysShowToolbar";
+ }
+ constructor() {
+ super({
+ id: _ToggleAlwaysShowInlineSuggestionToolbar.ID,
+ title: localize(1181, "Always Show Toolbar"),
+ f1: false,
+ precondition: void 0,
+ menu: [{
+ id: MenuId.InlineSuggestionToolbar,
+ group: "secondary",
+ order: 10
+ }],
+ toggled: ContextKeyExpr.equals("config.editor.inlineSuggest.showToolbar", "always")
+ });
+ }
+ async run(accessor) {
+ const configService = accessor.get(IConfigurationService);
+ const currentValue = configService.getValue("editor.inlineSuggest.showToolbar");
+ const newValue = currentValue === "always" ? "onHover" : "always";
+ configService.updateValue("editor.inlineSuggest.showToolbar", newValue);
+ }
+};
+var DevExtractReproSample = class extends EditorAction {
+ constructor() {
+ super({
+ id: "editor.action.inlineSuggest.dev.extractRepro",
+ label: localize(1182, "Developer: Extract Inline Suggest State"),
+ alias: "Developer: Inline Suggest Extract Repro",
+ precondition: ContextKeyExpr.or(InlineCompletionContextKeys.inlineEditVisible, InlineCompletionContextKeys.inlineSuggestionVisible)
+ });
+ }
+ async run(accessor, editor2) {
+ const clipboardService = accessor.get(IClipboardService);
+ const controller = InlineCompletionsController.get(editor2);
+ const m = controller?.model.get();
+ if (!m) {
+ return;
+ }
+ const repro = m.extractReproSample();
+ const inlineCompletionLines = splitLines(JSON.stringify({ inlineCompletion: repro.inlineCompletion }, null, 4));
+ const json = inlineCompletionLines.map((l) => "// " + l).join("\n");
+ const reproStr = `${repro.documentValue}
+
+//