Skip to content

Commit

Permalink
Allow goToLine to work backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
jmannanc committed Aug 25, 2019
1 parent b6a4220 commit 33e53ee
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 @@ -114,7 +116,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 33e53ee

Please sign in to comment.