Fix IndexOutOfBoundsException from GithubValueParser
This commit is contained in:
@@ -125,6 +125,19 @@ public class DocumentRegion implements CharSequence, IRegion {
|
||||
throw new IndexOutOfBoundsException(""+offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Like charAt, but doesn't IndexOutOfBoundsException. Instead it
|
||||
* return (char)0.
|
||||
*/
|
||||
public char safeCharAt(int offset) {
|
||||
try {
|
||||
return charAt(offset);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether this range contains a given (absolute) offset.
|
||||
|
||||
@@ -89,7 +89,7 @@ public class GithubValueParsers {
|
||||
for (String expectedPrefix : GithubRepoContentAssistant.URI_PREFIXES) {
|
||||
int lastChar = expectedPrefix.length()-1;
|
||||
if (str.startsWith(expectedPrefix.substring(0, lastChar))) {
|
||||
char actualSeparator = str.charAt(lastChar);
|
||||
char actualSeparator = str.safeCharAt(lastChar);
|
||||
char expectedSeparator = expectedPrefix.charAt(lastChar);
|
||||
if (actualSeparator==expectedSeparator) {
|
||||
return expectedPrefix;
|
||||
|
||||
Reference in New Issue
Block a user