UNPKG

alm

Version:

The best IDE for TypeScript

85 lines (84 loc) 4.37 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Selection = monaco.Selection; var ReplaceCommand = /** @class */ (function () { function ReplaceCommand(range, text) { this._range = range; this._text = text; } ReplaceCommand.prototype.getText = function () { return this._text; }; ReplaceCommand.prototype.getRange = function () { return this._range; }; ReplaceCommand.prototype.setRange = function (newRange) { this._range = newRange; }; ReplaceCommand.prototype.getEditOperations = function (model, builder) { builder.addEditOperation(this._range, this._text); }; ReplaceCommand.prototype.computeCursorState = function (model, helper) { var inverseEditOperations = helper.getInverseEditOperations(); var srcRange = inverseEditOperations[0].range; return new Selection(srcRange.endLineNumber, srcRange.endColumn, srcRange.endLineNumber, srcRange.endColumn); }; return ReplaceCommand; }()); exports.ReplaceCommand = ReplaceCommand; var ReplaceCommandWithoutChangingPosition = /** @class */ (function (_super) { __extends(ReplaceCommandWithoutChangingPosition, _super); function ReplaceCommandWithoutChangingPosition(range, text) { return _super.call(this, range, text) || this; } ReplaceCommandWithoutChangingPosition.prototype.computeCursorState = function (model, helper) { var inverseEditOperations = helper.getInverseEditOperations(); var srcRange = inverseEditOperations[0].range; return new Selection(srcRange.startLineNumber, srcRange.startColumn, srcRange.startLineNumber, srcRange.startColumn); }; return ReplaceCommandWithoutChangingPosition; }(ReplaceCommand)); exports.ReplaceCommandWithoutChangingPosition = ReplaceCommandWithoutChangingPosition; var ReplaceCommandWithOffsetCursorState = /** @class */ (function (_super) { __extends(ReplaceCommandWithOffsetCursorState, _super); function ReplaceCommandWithOffsetCursorState(range, text, lineNumberDeltaOffset, columnDeltaOffset) { var _this = _super.call(this, range, text) || this; _this._columnDeltaOffset = columnDeltaOffset; _this._lineNumberDeltaOffset = lineNumberDeltaOffset; return _this; } ReplaceCommandWithOffsetCursorState.prototype.computeCursorState = function (model, helper) { var inverseEditOperations = helper.getInverseEditOperations(); var srcRange = inverseEditOperations[0].range; return new Selection(srcRange.endLineNumber + this._lineNumberDeltaOffset, srcRange.endColumn + this._columnDeltaOffset, srcRange.endLineNumber + this._lineNumberDeltaOffset, srcRange.endColumn + this._columnDeltaOffset); }; return ReplaceCommandWithOffsetCursorState; }(ReplaceCommand)); exports.ReplaceCommandWithOffsetCursorState = ReplaceCommandWithOffsetCursorState; var ReplaceCommandThatPreservesSelection = /** @class */ (function (_super) { __extends(ReplaceCommandThatPreservesSelection, _super); function ReplaceCommandThatPreservesSelection(editRange, text, initialSelection) { var _this = _super.call(this, editRange, text) || this; _this._initialSelection = initialSelection; return _this; } ReplaceCommandThatPreservesSelection.prototype.getEditOperations = function (model, builder) { _super.prototype.getEditOperations.call(this, model, builder); this._selectionId = builder.trackSelection(this._initialSelection); }; ReplaceCommandThatPreservesSelection.prototype.computeCursorState = function (model, helper) { return helper.getTrackedSelection(this._selectionId); }; return ReplaceCommandThatPreservesSelection; }(ReplaceCommand)); exports.ReplaceCommandThatPreservesSelection = ReplaceCommandThatPreservesSelection;