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


TypeScript IModel.getLineMaxColumn方法代码示例

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


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

示例1: _cursorMoveMessage

	private static _cursorMoveMessage(source: string, model: IModel, oldPosition: Position, newPosition: Position): string {

		if (source === 'moveWordCommand') {
			return model.getValueInRange(new Range(oldPosition.lineNumber, oldPosition.column, newPosition.lineNumber, newPosition.column));
		}

		const oldLineNumber = oldPosition.lineNumber;
		const oldColumn = oldPosition.column;
		const newLineNumber = newPosition.lineNumber;
		const newColumn = newPosition.column;

		// check going down via right arrow
		if (newLineNumber === oldLineNumber + 1 && newColumn === 1 && oldColumn === model.getLineMaxColumn(oldLineNumber)) {
			return this._cursorCharMessage(model, newPosition);
		}

		// check going up via up arrow
		if (newLineNumber === oldLineNumber - 1 && newColumn === model.getLineMaxColumn(newLineNumber) && oldColumn === 1) {
			return this._cursorCharMessage(model, newPosition);
		}

		const lineCount = model.getLineCount();
		if (oldLineNumber !== newLineNumber) {
			if (newLineNumber === lineCount) {
				// Last line does not have an EOL
				return model.getLineContent(newLineNumber);
			}
			return model.getLineContent(newLineNumber) + model.getEOL();
		}

		return this._cursorCharMessage(model, newPosition);
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:32,代码来源:accGenerator.ts

示例2: getLinesRangeWithOneSurroundingNewline

function getLinesRangeWithOneSurroundingNewline(model: IModel, startLine: number, endLine: number): Range {
	let startColumn = 1;
	let endColumn = model.getLineMaxColumn(endLine);
	if (endLine < model.getLineCount()) {
		endLine++;
		endColumn = 1;
	} else if (startLine > 1) {
		startLine--;
		startColumn = model.getLineMaxColumn(startLine);
	}

	return new Range(startLine, startColumn, endLine, endColumn);
}
开发者ID:diarmaidm,项目名称:vscode,代码行数:13,代码来源:stageRanges.ts

示例3: applyChangesToModel

export function applyChangesToModel(original: IModel, modified: IModel, changes: IChange[]): string {
	sortChanges(changes);
	var result = '';
	var positionInOriginal = 1;

	for (var i = 0; i < changes.length; ++i) {
		// We have to update orginalStartLineNumber for insertions, their start line is always one line behind.
		var originalStartLineUpdated = isInsertion(changes[i]) ? changes[i].originalStartLineNumber + 1 : changes[i].originalStartLineNumber;
		if (positionInOriginal < originalStartLineUpdated) {
			result = appendValueFromRange(result, original,
				new Range(positionInOriginal, 1, originalStartLineUpdated - 1, original.getLineMaxColumn(originalStartLineUpdated - 1)));
			positionInOriginal = originalStartLineUpdated;
		}

		if (!isDeletion(changes[i])) {
			result = appendValueFromRange(result, modified,
				new Range(changes[i].modifiedStartLineNumber, 1, changes[i].modifiedEndLineNumber, modified.getLineMaxColumn(changes[i].modifiedEndLineNumber)));
		}
		// Update position in the original file where we continue to concatanate.
		// Only update position if it was not an insertion.
		if (!isInsertion(changes[i])) {
			positionInOriginal = changes[i].originalEndLineNumber + 1;
		}
	}

	// Append the last chunk after all the changes.
	if (positionInOriginal <= original.getLineCount()) {
		result = appendValueFromRange(result, original,
			new Range(positionInOriginal, 1, original.getLineCount(), original.getLineMaxColumn(original.getLineCount())));
	}

	return result;
}
开发者ID:diarmaidm,项目名称:vscode,代码行数:33,代码来源:stageRanges.ts

示例4: _delete

	protected _delete(wordSeparators: WordCharacterClassifier, model: IModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
		let r = WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
		if (r) {
			return r;
		}
		const lineCount = model.getLineCount();
		const maxColumn = model.getLineMaxColumn(lineCount);
		return new Range(lineCount, maxColumn, lineCount, maxColumn);
	}
开发者ID:Chan-PH,项目名称:vscode,代码行数:9,代码来源:wordOperations.ts

示例5: _cursorCharMessage

	private static _cursorCharMessage(model: IModel, position: Position): string {
		const lineNumber = position.lineNumber;
		const column = position.column;

		const maxLineColumn = model.getLineMaxColumn(lineNumber);
		if (column === maxLineColumn) {
			const lineCount = model.getLineCount();
			if (lineNumber === lineCount) {
				// At the end of the file
				return '';
			}
			return model.getEOL();
		}
		return model.getLineContent(lineNumber).charAt(column - 1);
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:15,代码来源:accGenerator.ts

示例6: getDeleteOperation

	return changes.map((change, i) => {
		if (isInsertion(change)) {
			// Delete inserted range
			return getDeleteOperation(change);
		} else if (isDeletion(change)) {
			// Get the original lines and insert at the deleted position
			const value = original.getValueInRange(getLinesRangeWithOneSurroundingNewline(original, change.originalStartLineNumber, change.originalEndLineNumber));
			return EditOperation.insert(new Position(change.modifiedStartLineNumber + 1, 1), value);
		} else if (change.isCompletelySelected) {
			// If the entire change is selected, then revert the whole thing.
			const value = original.getValueInRange(new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber + 1, 1));
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber + 1, 1), value);
		} else {
			// If only a portion is selected, replace with the matching lines - e.g. if lines 2-4 are selected, replace with lines 2-4 from the original model (if they exist)
			const copyOffset = change.modifiedStartLineNumber - change.fullModifiedStartLineNumber;
			const numLinesToCopy = change.modifiedEndLineNumber - change.modifiedStartLineNumber;
			const copyStartLine = change.originalStartLineNumber + copyOffset;
			const copyEndLine = Math.min(copyStartLine + numLinesToCopy, original.getLineCount());
			if (copyStartLine > copyEndLine) {
				return getDeleteOperation(change);
			}

			// Compute the range to copy, and intersect with the full original range to validate
			const originalRange = new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber, original.getLineMaxColumn(change.originalEndLineNumber));
			const rangeToCopy = originalRange.intersectRanges(
				new Range(copyStartLine, 1, copyEndLine, original.getLineMaxColumn(copyEndLine)));

			// No intersection, so delete the added text
			if (!rangeToCopy) {
				return getDeleteOperation(change);
			}

			const value = original.getValueInRange(rangeToCopy);
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber, modified.getLineMaxColumn(change.modifiedEndLineNumber)), value);
		}
	});
开发者ID:diarmaidm,项目名称:vscode,代码行数:36,代码来源:stageRanges.ts


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