當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Range.equalsRange方法代碼示例

本文整理匯總了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);
		}
	}
開發者ID:ErickWendel,項目名稱:vscode,代碼行數:30,代碼來源:viewModelDecorations.ts

示例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;
	}
開發者ID:fs814,項目名稱:vscode,代碼行數:25,代碼來源:textModelSearch.ts

示例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;
	}
開發者ID:AjuanM,項目名稱:vscode,代碼行數:29,代碼來源:findDecorations.ts

示例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));
	}
}
開發者ID:578723746,項目名稱:vscode,代碼行數:29,代碼來源:lint.test.ts

示例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)
		);
	}
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:8,代碼來源:cursorCommon.ts

示例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);
		});
開發者ID:1Hgm,項目名稱:vscode,代碼行數:18,代碼來源:modelDecorations.test.ts

示例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;
	}
開發者ID:GYGit,項目名稱:vscode,代碼行數:9,代碼來源:findDecorations.ts

示例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!;
	}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:9,代碼來源:viewModelDecorations.ts

示例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);
		});
開發者ID:ErickWendel,項目名稱:vscode,代碼行數:18,代碼來源:modelDecorations.test.ts

示例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;
	}
開發者ID:ErickWendel,項目名稱:vscode,代碼行數:12,代碼來源:textModel.ts


注:本文中的vs/editor/common/core/range.Range.equalsRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。