Skip to content

Commit

Permalink
isValid() no longer throws errors
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfn committed Oct 8, 2016
1 parent 0741038 commit ae454a1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/motion/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,19 @@ export class Position extends vscode.Position {
}

public isValid(): boolean {
// line
let lineCount = TextEditor.getLineCount() || 1;
if (this.line >= lineCount) {
return false;
}
try {
// line
let lineCount = TextEditor.getLineCount() || 1;
if (this.line >= lineCount) {
return false;
}

// char
let charCount = Position.getLineLength(this.line);
if (this.character > charCount + 1) {
// char
let charCount = Position.getLineLength(this.line);
if (this.character > charCount + 1) {
return false;
}
} catch (e) {
return false;
}

Expand Down

0 comments on commit ae454a1

Please sign in to comment.