Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
moveRight(position, { copy = false } = {}) {
if (this.lineInfo.length === 0)
return new Point();
position = Point.fromObject(position, copy);
let tokenLocator = this.tokenLocatorForPosition(position);
if (!tokenLocator)
return null;
let [ row, tokenIndex, line, token ] = tokenLocator;
// if we're inside the token, or on its left edge
if (position.column < token.outputOffset + token.outputLength) {
// if we're a static token, we can just move inside the token
if (token.type === STATIC_TOKEN) {
position.column += 1;
row === lastRow ||
_.isEqual(this.stackForRow(row), previousStack)
) {
filledRegion = true;
endRow = row;
break;
}
row++;
}
this.validateRow(endRow);
if (!filledRegion) this.invalidateRow(endRow + 1);
this.emitter.emit(
'did-change-highlighting',
Range(Point(startRow, 0), Point(endRow + 1, 0))
);
}
if (this.firstInvalidRow() != null) {
this.tokenizeInBackground();
} else {
this.markTokenizationComplete();
}
}
getFoldableRanges(tabLength) {
const result = [];
let row = 0;
const lineCount = this.buffer.getLineCount();
while (row < lineCount) {
const endRow = this.endRowForFoldAtRow(row, tabLength);
if (endRow != null) {
result.push(Range(Point(row, Infinity), Point(endRow, Infinity)));
}
row++;
}
return result;
}
suggestedIndentForEditedBufferRow(bufferRow, tabLength) {
const line = this.buffer.lineForRow(bufferRow);
const currentIndentLevel = this.indentLevelForLine(line, tabLength);
if (currentIndentLevel === 0) return;
const scopeDescriptor = this.scopeDescriptorForPosition(
new Point(bufferRow, 0)
);
const decreaseIndentRegex = this.decreaseIndentRegexForScopeDescriptor(
scopeDescriptor
);
if (!decreaseIndentRegex) return;
if (!decreaseIndentRegex.testSync(line)) return;
const precedingRow = this.buffer.previousNonBlankRow(bufferRow);
if (precedingRow == null) return;
const precedingLine = this.buffer.lineForRow(precedingRow);
let desiredIndentLevel = this.indentLevelForLine(precedingLine, tabLength);
const increaseIndentRegex = this.increaseIndentRegexForScopeDescriptor(
scopeDescriptor
getCurrentWordBufferRange(options = {}) {
const position = this.getBufferPosition();
const ranges = this.editor.buffer.findAllInRangeSync(
options.wordRegex || this.wordRegExp(options),
new Range(new Point(position.row, 0), new Point(position.row, Infinity))
);
const range = ranges.find(
range =>
range.end.column >= position.column &&
range.start.column <= position.column
);
return range ? Range.fromObject(range) : new Range(position, position);
}
this.openScopeIds = [];
this.closeScopeIds = [];
while (true) {
if (this.tagIndex === this.currentLineTags.length) {
if (this.isAtTagBoundary()) {
break;
} else if (!this.moveToNextLine()) {
return false;
}
} else {
const tag = this.currentLineTags[this.tagIndex];
if (tag >= 0) {
if (this.isAtTagBoundary()) {
break;
} else {
this.position = Point(
this.position.row,
Math.min(
this.currentLineLength,
this.position.column + this.currentLineTags[this.tagIndex]
)
);
}
} else {
const scopeId = fromFirstMateScopeId(tag);
if ((tag & 1) === 0) {
if (this.openScopeIds.length > 0) {
break;
} else {
this.closeScopeIds.push(scopeId);
}
} else {