本文整理匯總了TypeScript中vs/editor/common/core/range.Range.equalsRange方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Range.equalsRange方法的具體用法?TypeScript Range.equalsRange怎麽用?TypeScript Range.equalsRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/core/range.Range
的用法示例。
在下文中一共展示了Range.equalsRange方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: onLineMappingChanged
public onLineMappingChanged(emit:(eventType:string, payload:any)=>void): void {
var decorations = this.decorations,
d:IViewModelDecoration,
i:number,
newRange:EditorCommon.IEditorRange,
somethingChanged:boolean = false,
inlineDecorationsChanged = false,
len:number;
for (i = 0, len = decorations.length; i < len; i++) {
d = decorations[i];
newRange = this.converter.convertModelRangeToViewRange(d.modelRange, d.options.isWholeLine);
if (!inlineDecorationsChanged && d.options.inlineClassName && !Range.equalsRange(newRange, d.range)) {
inlineDecorationsChanged = true;
}
if (!somethingChanged && !Range.equalsRange(newRange, d.range)) {
somethingChanged = true;
}
d.range = newRange;
}
if (somethingChanged) {
this._clearCachedModelDecorationsResolver();
this.decorations.sort(ViewModelDecorations.compareDecorations);
var newEvent:EditorCommon.IViewDecorationsChangedEvent = {
inlineDecorationsChanged: inlineDecorationsChanged
};
emit(EditorCommon.ViewEventNames.DecorationsChangedEvent, newEvent);
}
}
示例2: _findMatchesInLine
private static _findMatchesInLine(searchRegex: RegExp, text: string, lineNumber: number, deltaOffset: number, counter: number, result: FindMatch[], captureMatches: boolean, limitResultCount: number): number {
let m: RegExpExecArray;
// Reset regex to search from the beginning
searchRegex.lastIndex = 0;
do {
m = searchRegex.exec(text);
if (m) {
const range = new Range(lineNumber, m.index + 1 + deltaOffset, lineNumber, m.index + 1 + m[0].length + deltaOffset);
if (result.length > 0 && range.equalsRange(result[result.length - 1].range)) {
// Exit early if the regex matches the same range
return counter;
}
result.push(createFindMatch(range, m, captureMatches));
counter++;
if (counter >= limitResultCount) {
return counter;
}
if (m.index + m[0].length === text.length) {
// Reached the end of the line
return counter;
}
}
} while (m);
return counter;
}
示例3: setCurrentFindMatch
public setCurrentFindMatch(nextMatch:Range): number {
let newCurrentDecorationId: string = null;
let matchPosition = 0;
if (nextMatch) {
for (let i = 0, len = this._decorations.length; i < len; i++) {
let range = this._editor.getModel().getDecorationRange(this._decorations[i]);
if (nextMatch.equalsRange(range)) {
newCurrentDecorationId = this._decorations[i];
matchPosition = (i + 1);
break;
}
}
}
if (this._highlightedDecorationId !== null || newCurrentDecorationId !== null) {
this._editor.changeDecorations((changeAccessor: editorCommon.IModelDecorationsChangeAccessor) => {
if (this._highlightedDecorationId !== null) {
changeAccessor.changeDecorationOptions(this._highlightedDecorationId, FindDecorations.createFindMatchDecorationOptions(false));
this._highlightedDecorationId = null;
}
if (newCurrentDecorationId !== null) {
this._highlightedDecorationId = newCurrentDecorationId;
changeAccessor.changeDecorationOptions(this._highlightedDecorationId, FindDecorations.createFindMatchDecorationOptions(true));
}
});
}
return matchPosition;
}
示例4: _assertCheck
function _assertCheck(checker:lint.SimpleStyleRuleChecker, sourceFile:ts.SourceFile, numbers:number[]):void {
var expected:EditorCommon.IRange[] = [];
for(var i = 0, len = numbers.length; i < len - 1; i+=2) {
expected.push({
startLineNumber: 1,
startColumn: 1 + numbers[i],
endLineNumber: 1,
endColumn: 1 + numbers[i] + numbers[i + 1]
});
}
var actual = checker.check(sourceFile);
assert.equal(actual.length, expected.length);
if(actual.length !== expected.length) {
assert.ok(false, String(actual));
return;
}
while(actual.length > 0) {
var _expected = expected.pop(),
_actual = actual.pop().range;
assert.ok(Range.equalsRange(_expected, _actual), JSON.stringify(_expected) + JSON.stringify(_actual));
}
}
示例5: equals
public equals(other: SingleCursorState) {
return (
this.selectionStartLeftoverVisibleColumns === other.selectionStartLeftoverVisibleColumns
&& this.leftoverVisibleColumns === other.leftoverVisibleColumns
&& this.position.equals(other.position)
&& this.selectionStart.equalsRange(other.selectionStart)
);
}
示例6:
thisModel.onDidChangeDecorations((e) => {
listenerCalled++;
assert.equal(e.ids.length, 1);
assert.equal(e.addedOrChangedDecorations.length, 1);
assert.ok(Range.equalsRange(e.addedOrChangedDecorations[0].range, {
startLineNumber: 1,
startColumn: 8,
endLineNumber: 3,
endColumn: 2
}));
assert.ok(Range.equalsRange(e.oldRanges[decId], {
startLineNumber: 1,
startColumn: 2,
endLineNumber: 3,
endColumn: 2
}));
assert.equal(e.removedDecorations.length, 0);
});
示例7: getCurrentMatchesPosition
public getCurrentMatchesPosition(desiredRange:Range): number {
for (let i = 0, len = this._decorations.length; i < len; i++) {
let range = this._editor.getModel().getDecorationRange(this._decorations[i]);
if (desiredRange.equalsRange(range)) {
return (i + 1);
}
}
return 1;
}
示例8: getDecorationsViewportData
public getDecorationsViewportData(viewRange: Range): IDecorationsViewportData {
let cacheIsValid = (this._cachedModelDecorationsResolver !== null);
cacheIsValid = cacheIsValid && (viewRange.equalsRange(this._cachedModelDecorationsResolverViewRange));
if (!cacheIsValid) {
this._cachedModelDecorationsResolver = this._getDecorationsViewportData(viewRange);
this._cachedModelDecorationsResolverViewRange = viewRange;
}
return this._cachedModelDecorationsResolver!;
}
示例9:
thisModel.addListener(EditorCommon.EventType.ModelDecorationsChanged, (e) => {
listenerCalled++;
assert.equal(e.ids.length, 1);
assert.equal(e.addedOrChangedDecorations.length, 1);
assert.ok(Range.equalsRange(e.addedOrChangedDecorations[0].range, {
startLineNumber: 1,
startColumn: 8,
endLineNumber: 3,
endColumn: 2
}));
assert.ok(Range.equalsRange(e.oldRanges[decId], {
startLineNumber: 1,
startColumn: 2,
endLineNumber: 3,
endColumn: 2
}));
assert.equal(e.removedDecorations.length, 0);
});
示例10: _findLastMatchInLine
private _findLastMatchInLine(searchRegex:RegExp, text:string, lineNumber:number): EditorCommon.IEditorRange {
let bestResult: EditorCommon.IEditorRange = null;
let m:RegExpExecArray;
while ((m = searchRegex.exec(text))) {
let result = new Range(lineNumber, m.index + 1, lineNumber, m.index + 1 + m[0].length);
if (result.equalsRange(bestResult)) {
break;
}
bestResult = result;
}
return bestResult;
}