本文整理汇总了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;
}
示例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);
}
});