当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript PrefixSumComputer.removeValues方法代码示例

本文整理汇总了TypeScript中vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer.removeValues方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PrefixSumComputer.removeValues方法的具体用法?TypeScript PrefixSumComputer.removeValues怎么用?TypeScript PrefixSumComputer.removeValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer的用法示例。


在下文中一共展示了PrefixSumComputer.removeValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _acceptDeleteRange

	private _acceptDeleteRange(range: IRange): void {

		if (range.startLineNumber === range.endLineNumber) {
			if (range.startColumn === range.endColumn) {
				// Nothing to delete
				return;
			}
			// Delete text on the affected line
			this._setLineText(range.startLineNumber - 1,
				this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
				+ this._lines[range.startLineNumber - 1].substring(range.endColumn - 1)
			);
			return;
		}

		// Take remaining text on last line and append it to remaining text on first line
		this._setLineText(range.startLineNumber - 1,
			this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
			+ this._lines[range.endLineNumber - 1].substring(range.endColumn - 1)
		);

		// Delete middle lines
		this._lines.splice(range.startLineNumber, range.endLineNumber - range.startLineNumber);
		if (this._lineStarts) {
			// update prefix sum
			this._lineStarts.removeValues(range.startLineNumber, range.endLineNumber - range.startLineNumber);
		}
	}
开发者ID:13572293130,项目名称:vscode,代码行数:28,代码来源:mirrorModel2.ts

示例2: onModelLinesDeleted

	public onModelLinesDeleted(versionId: number, fromLineNumber: number, toLineNumber: number, emit: (evenType: string, payload: any) => void): void {
		if (versionId <= this._validModelVersionId) {
			return;
		}
		this._validModelVersionId = versionId;

		var outputFromLineNumber = (fromLineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(fromLineNumber - 2) + 1);
		var outputToLineNumber = this.prefixSumComputer.getAccumulatedValue(toLineNumber - 1);

		this.lines.splice(fromLineNumber - 1, toLineNumber - fromLineNumber + 1);
		this.prefixSumComputer.removeValues(fromLineNumber - 1, toLineNumber - fromLineNumber + 1);

		var e:editorCommon.IViewLinesDeletedEvent = {
			fromLineNumber: outputFromLineNumber,
			toLineNumber: outputToLineNumber
		};
		emit(editorCommon.ViewEventNames.LinesDeletedEvent, e);
	}
开发者ID:pieandcakes,项目名称:vscode,代码行数:18,代码来源:splitLinesCollection.ts

示例3: _doApplyEdits

	private _doApplyEdits(operations: IValidatedEditOperation[]): IInternalModelContentChange[] {

		// Sort operations descending
		operations.sort(LinesTextBuffer._sortOpsDescending);

		let contentChanges: IInternalModelContentChange[] = [];

		for (let i = 0, len = operations.length; i < len; i++) {
			const op = operations[i];

			const startLineNumber = op.range.startLineNumber;
			const startColumn = op.range.startColumn;
			const endLineNumber = op.range.endLineNumber;
			const endColumn = op.range.endColumn;

			if (startLineNumber === endLineNumber && startColumn === endColumn && (!op.lines || op.lines.length === 0)) {
				// no-op
				continue;
			}

			const deletingLinesCnt = endLineNumber - startLineNumber;
			const insertingLinesCnt = (op.lines ? op.lines.length - 1 : 0);
			const editingLinesCnt = Math.min(deletingLinesCnt, insertingLinesCnt);

			for (let j = editingLinesCnt; j >= 0; j--) {
				const editLineNumber = startLineNumber + j;
				let editText = (op.lines ? op.lines[j] : '');

				if (editLineNumber === startLineNumber || editLineNumber === endLineNumber) {
					const editStartColumn = (editLineNumber === startLineNumber ? startColumn : 1);
					const editEndColumn = (editLineNumber === endLineNumber ? endColumn : this.getLineLength(editLineNumber) + 1);

					editText = (
						this._lines[editLineNumber - 1].substring(0, editStartColumn - 1)
						+ editText
						+ this._lines[editLineNumber - 1].substring(editEndColumn - 1)
					);
				}

				this._setLineContent(editLineNumber, editText);
			}

			if (editingLinesCnt < deletingLinesCnt) {
				// Must delete some lines

				const spliceStartLineNumber = startLineNumber + editingLinesCnt;
				const endLineRemains = this._lines[endLineNumber - 1].substring(endColumn - 1);

				// Reconstruct first line
				this._setLineContent(spliceStartLineNumber, this._lines[spliceStartLineNumber - 1] + endLineRemains);

				this._lines.splice(spliceStartLineNumber, endLineNumber - spliceStartLineNumber);
				this._lineStarts.removeValues(spliceStartLineNumber, endLineNumber - spliceStartLineNumber);
			}

			if (editingLinesCnt < insertingLinesCnt) {
				// Must insert some lines

				const spliceLineNumber = startLineNumber + editingLinesCnt;
				let spliceColumn = (spliceLineNumber === startLineNumber ? startColumn : 1);
				if (op.lines) {
					spliceColumn += op.lines[editingLinesCnt].length;
				}

				// Split last line
				const leftoverLine = this._lines[spliceLineNumber - 1].substring(spliceColumn - 1);

				this._setLineContent(spliceLineNumber, this._lines[spliceLineNumber - 1].substring(0, spliceColumn - 1));

				// Lines in the middle
				let newLines: string[] = new Array<string>(insertingLinesCnt - editingLinesCnt);
				let newLinesLengths = new Uint32Array(insertingLinesCnt - editingLinesCnt);
				for (let j = editingLinesCnt + 1; j <= insertingLinesCnt; j++) {
					newLines[j - editingLinesCnt - 1] = op.lines[j];
					newLinesLengths[j - editingLinesCnt - 1] = op.lines[j].length + this._EOL.length;
				}
				newLines[newLines.length - 1] += leftoverLine;
				newLinesLengths[newLines.length - 1] += leftoverLine.length;
				this._lines = arrays.arrayInsert(this._lines, startLineNumber + editingLinesCnt, newLines);
				this._lineStarts.insertValues(startLineNumber + editingLinesCnt, newLinesLengths);
			}

			const contentChangeRange = new Range(startLineNumber, startColumn, endLineNumber, endColumn);
			const text = (op.lines ? op.lines.join(this.getEOL()) : '');
			contentChanges.push({
				range: contentChangeRange,
				rangeLength: op.rangeLength,
				text: text,
				rangeOffset: op.rangeOffset,
				forceMoveMarkers: op.forceMoveMarkers
			});
		}

		return contentChanges;
	}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:95,代码来源:linesTextBuffer.ts


注:本文中的vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer.removeValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。