當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。