Permalink
Browse files

defensive

  • Loading branch information...
1 parent b73f0ea commit 34c0423846fb3b9ad5587c3c30c7d0a02ce208d9 @JPMoresmau committed Dec 21, 2009
@@ -69,11 +69,13 @@ private Position createPosition( final int startLine, final int endLine ) {
Position result = null;
try {
int start = document.getLineOffset( startLine -1 );
- int end = document.getLineOffset( endLine -1)
- + document.getLineLength( endLine -1);
+ int endLine2=Math.min( document.getNumberOfLines()-1, endLine -1 );
+ int end = document.getLineOffset( endLine2)
+ + document.getLineLength( endLine2);
result = new Position( start, end - start );
} catch( final BadLocationException badlox ) {
// ignored
+ System.err.println(startLine+","+endLine);
badlox.printStackTrace();
}
return result;

0 comments on commit 34c0423

Please sign in to comment.