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


TypeScript Range.intersectRanges方法代码示例

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


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

示例1: _getSearchRange

	private static _getSearchRange(model:editorCommon.IModel, searchOnlyEditableRange:boolean, findScope:Range): Range {
		let searchRange:Range;

		if (searchOnlyEditableRange) {
			searchRange = model.getEditableRange();
		} else {
			searchRange = model.getFullModelRange();
		}

		// If we have set now or before a find scope, use it for computing the search range
		if (findScope) {
			searchRange = searchRange.intersectRanges(findScope);
		}

		return searchRange;
	}
开发者ID:GYGit,项目名称:vscode,代码行数:16,代码来源:findModel.ts

示例2: 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/core/range.Range.intersectRanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。