From ae454a1bb7c99e88b6a53762b587fac38eb14f45 Mon Sep 17 00:00:00 2001 From: johnfn Date: Fri, 7 Oct 2016 22:53:32 -0700 Subject: [PATCH] isValid() no longer throws errors --- src/motion/position.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/motion/position.ts b/src/motion/position.ts index 09d081a70c8..54ac6137a3e 100644 --- a/src/motion/position.ts +++ b/src/motion/position.ts @@ -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; }