Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private textToRange(text: string, startPosition: vscode.Position): vscode.Range {
let parts: string[] = text.split("\n");
let addedLines: number = parts.length - 1;
let newStartLine: number = startPosition.line;
let newStartCharacter: number = startPosition.character;
let newEndLine: number = newStartLine + addedLines;
let newEndCharacter: number = parts[parts.length - 1].length;
if (newStartLine === newEndLine) {
newEndCharacter += newStartCharacter;
}
return new vscode.Range(newStartLine, newStartCharacter, newEndLine, newEndCharacter);
}
scrollIntoView(position: Position) {
let range = new Range(position, position);
this.editor.revealRange(range, TextEditorRevealType.InCenter);
}
}
public provideCompletionItems(document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken): Thenable {
let start = new vscode.Position(position.line, 0);
let range = new vscode.Range(start, position);
let text = document.getText(range);
let items = this._parser.getParsingResults(text, document);
return Promise.resolve(items);
}
private findHoverOnEnv(document: vscode.TextDocument | TextDocumentLike, envname: string, startPos: vscode.Position): TexMathEnv | undefined {
const pattern = new RegExp('\\\\end\\{' + utils.escapeRegExp(envname) + '\\}')
const startPos1 = new vscode.Position(startPos.line, startPos.character + envname.length + '\\begin{}'.length)
const endPos = this.findEndPair(document, pattern, startPos1)
if ( endPos ) {
const range = new vscode.Range(startPos, endPos)
return {texString: document.getText(range), range, envname}
}
return undefined
}
createRange(happening: Happening): vscode.Range {
let line = happening.lineIndex || 0;
return new vscode.Range(line, 0, line, 100);
}
}