Skip to content

Commit

Permalink
Allow goToLine to work backwards (#79348)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Aug 26, 2019
2 parents 8b96058 + 3faed6b commit c157da1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ class GotoLineEntry extends EditorQuickOpenEntry {

private parseInput(line: string) {
const numbers = line.split(/,|:|#/).map(part => parseInt(part, 10)).filter(part => !isNaN(part));
this.line = numbers[0];
const endLine = this.getMaxLineNumber() + 1;

this.column = numbers[1];
this.line = numbers[0] > 0 ? numbers[0] : endLine + numbers[0];
}

getLabel(): string {
Expand All @@ -113,7 +115,7 @@ class GotoLineEntry extends EditorQuickOpenEntry {
}

private invalidRange(maxLineNumber: number = this.getMaxLineNumber()): boolean {
return !this.line || !types.isNumber(this.line) || (maxLineNumber > 0 && types.isNumber(this.line) && this.line > maxLineNumber);
return !this.line || !types.isNumber(this.line) || (maxLineNumber > 0 && types.isNumber(this.line) && this.line > maxLineNumber) || this.line < 0;
}

private getMaxLineNumber(): number {
Expand Down

0 comments on commit c157da1

Please sign in to comment.