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


TypeScript Position.isBefore方法代码示例

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


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

示例1: _getNextMatch

	private _getNextMatch(after:Position, isRecursed:boolean = false): Range {
		if (this._cannotFind()) {
			return null;
		}

		let findScope = this._decorations.getFindScope();
		let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);

		// ...(----)...|...
		if (searchRange.getEndPosition().isBefore(after)) {
			after = searchRange.getStartPosition();
		}

		// ...|...(----)...
		if (after.isBefore(searchRange.getStartPosition())) {
			after = searchRange.getStartPosition();
		}

		let {lineNumber,column} = after;
		let model = this._editor.getModel();

		let position = new Position(lineNumber, column);

		let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);

		if (nextMatch && nextMatch.isEmpty() && nextMatch.getStartPosition().equals(position)) {
			// Looks like we're stuck at this position, unacceptable!

			let isUsingLineStops = this._state.isRegex && (
				this._state.searchString.indexOf('^') >= 0
				|| this._state.searchString.indexOf('$') >= 0
			);

			if (isUsingLineStops || column === model.getLineMaxColumn(lineNumber)) {
				if (lineNumber === model.getLineCount()) {
					lineNumber = 1;
				} else {
					lineNumber++;
				}
				column = 1;
			} else {
				column++;
			}

			position = new Position(lineNumber, column);
			nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);
		}

		if (!nextMatch) {
			// there is precisely one match and selection is on top of it
			return;
		}

		if (!isRecursed && !searchRange.containsRange(nextMatch)) {
			return this._getNextMatch(nextMatch.getEndPosition(), true);
		}

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

示例2: _moveToPrevMatch

	private _moveToPrevMatch(before:Position, isRecursed:boolean = false): void {
		if (this._cannotFind()) {
			return;
		}

		let findScope = this._decorations.getFindScope();
		let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);

		// ...(----)...|...
		if (searchRange.getEndPosition().isBefore(before)) {
			before = searchRange.getEndPosition();
		}

		// ...|...(----)...
		if (before.isBefore(searchRange.getStartPosition())) {
			before = searchRange.getEndPosition();
		}

		let {lineNumber,column} = before;
		let model = this._editor.getModel();

		let position = new Position(lineNumber, column);

		let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);

		if (prevMatch && prevMatch.isEmpty() && prevMatch.getStartPosition().equals(position)) {
			// Looks like we're stuck at this position, unacceptable!

			let isUsingLineStops = this._state.isRegex && (
				this._state.searchString.indexOf('^') >= 0
				|| this._state.searchString.indexOf('$') >= 0
			);

			if (isUsingLineStops || column === 1) {
				if (lineNumber === 1) {
					lineNumber = model.getLineCount();
				} else {
					lineNumber--;
				}
				column = model.getLineMaxColumn(lineNumber);
			} else {
				column--;
			}

			position = new Position(lineNumber, column);
			prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);
		}

		if (!prevMatch) {
			// there is precisely one match and selection is on top of it
			return;
		}

		if (!isRecursed && !searchRange.containsRange(prevMatch)) {
			return this._moveToPrevMatch(prevMatch.getStartPosition(), true);
		}

		this._setCurrentFindMatch(prevMatch);
	}
开发者ID:GYGit,项目名称:vscode,代码行数:59,代码来源:findModel.ts

示例3: _createRangeFromMarkers

	private static _createRangeFromMarkers(startPosition: Position, endPosition: Position): Range {
		if (endPosition.isBefore(startPosition)) {
			// This tracked range has turned in on itself (end marker before start marker)
			// This can happen in extreme editing conditions where lots of text is removed and lots is added

			// Treat it as a collapsed range
			return new Range(startPosition.lineNumber, startPosition.column, startPosition.lineNumber, startPosition.column);
		}
		return new Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column);
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:10,代码来源:textModelWithDecorations.ts

示例4: _moveToNextMatch

	public _moveToNextMatch(after:Position, isRecursed:boolean = false): void {
		if (this._cannotFind()) {
			return;
		}

		let findScope = this._decorations.getFindScope();
		let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);

		// ...(----)...|...
		if (searchRange.getEndPosition().isBefore(after)) {
			after = searchRange.getStartPosition();
		}

		// ...|...(----)...
		if (after.isBefore(searchRange.getStartPosition())) {
			after = searchRange.getStartPosition();
		}

		let {lineNumber,column} = after;
		let model = this._editor.getModel();

		if (this._state.isRegex) {
			// Force advancing to the next line if searching for ^ or ^$
			if (this._state.searchString === '^' || this._state.searchString === '^$') {
				if (lineNumber === model.getLineCount()) {
					lineNumber = 1;
				} else {
					lineNumber++;
				}
				column = 1;
			}

			// Force advancing to the next line if searching for $ and at the end of the line
			if (this._state.searchString === '$') {
				if (column === model.getLineMaxColumn(lineNumber)) {
					if (lineNumber === model.getLineCount()) {
						lineNumber = 1;
					} else {
						lineNumber++;
					}
					column = 1;
				}
			}
		}

		let position = new Position(lineNumber, column);

		let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);

		if (!nextMatch) {
			// there is precisely one match and selection is on top of it
			return;
		}

		if (!isRecursed && !searchRange.containsRange(nextMatch)) {
			return this._moveToNextMatch(nextMatch.getEndPosition(), true);
		}

		let matchesPosition = this._decorations.setCurrentFindMatch(nextMatch);
		this._state.changeMatchInfo(matchesPosition, this._decorations.getCount());
		this._editor.setSelection(nextMatch);
		this._editor.revealRangeInCenterIfOutsideViewport(nextMatch);
	}
开发者ID:AjuanM,项目名称:vscode,代码行数:63,代码来源:findModel.ts

示例5: _moveToPrevMatch

	private _moveToPrevMatch(before:Position, isRecursed:boolean = false): void {
		if (this._cannotFind()) {
			return;
		}

		let findScope = this._decorations.getFindScope();
		let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), this._state.isReplaceRevealed, findScope);

		// ...(----)...|...
		if (searchRange.getEndPosition().isBefore(before)) {
			before = searchRange.getEndPosition();
		}

		// ...|...(----)...
		if (before.isBefore(searchRange.getStartPosition())) {
			before = searchRange.getEndPosition();
		}

		let {lineNumber,column} = before;
		let model = this._editor.getModel();

		if (this._state.isRegex) {
			// Force advancing to the previous line if searching for $
			if (this._state.searchString === '$') {
				if (lineNumber === 1) {
					lineNumber = model.getLineCount();
				} else {
					lineNumber--;
				}
				column = model.getLineMaxColumn(lineNumber);
			}

			// Force advancing to the previous line if searching for ^ or ^$ and cursor is at the beginning
			if (this._state.searchString === '^' || this._state.searchString === '^$') {
				if (column === 1) {
					if (lineNumber === 1) {
						lineNumber = model.getLineCount();
					} else {
						lineNumber--;
					}
					column = model.getLineMaxColumn(lineNumber);
				}
			}
		}

		let position = new Position(lineNumber, column);

		let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord);
		if (!prevMatch) {
			// there is precisely one match and selection is on top of it
			return;
		}

		if (!isRecursed && !searchRange.containsRange(prevMatch)) {
			return this._moveToPrevMatch(prevMatch.getStartPosition(), true);
		}

		let matchesPosition = this._decorations.setCurrentFindMatch(prevMatch);
		this._state.changeMatchInfo(matchesPosition, this._decorations.getCount());
		this._editor.setSelection(prevMatch);
		this._editor.revealRangeInCenterIfOutsideViewport(prevMatch);
	}
开发者ID:AjuanM,项目名称:vscode,代码行数:62,代码来源:findModel.ts


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