fix completion in an empty custom-file-type file (EA-93679 - IOOBE: SegmentArrayWithData.getSegmentData)

This commit is contained in:
peter
2017-02-16 18:18:56 +01:00
parent ad9ea4d7ed
commit ee786f4696
2 changed files with 8 additions and 0 deletions
@@ -42,6 +42,12 @@ public class CustomFileTypeCompletionTest extends LightCompletionTestCase {
testByCount(0, new String[] { null });
}
public void testEmptyFile() throws Throwable {
configureFromFileText("a.cs", "<caret>");
complete();
testByCount(1, "abstract", "x");
}
public void testPlainTextSubstitution() throws IOException {
FileTypeManagerEx.getInstanceEx().registerFileType(MockLanguageFileType.INSTANCE, "xxx");
try {
@@ -71,6 +71,8 @@ public class CustomFileTypeCompletionContributor extends CompletionContributor i
private static boolean inCommentOrLiteral(CompletionParameters parameters) {
HighlighterIterator iterator = ((EditorEx)parameters.getEditor()).getHighlighter().createIterator(parameters.getOffset());
if (iterator.atEnd()) return false;
IElementType elementType = iterator.getTokenType();
if (elementType == CustomHighlighterTokenType.WHITESPACE) {
iterator.retreat();