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