diff --git a/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java b/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java index c49fbbc82..2b7b6bec3 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java @@ -110,7 +110,6 @@ public class AssetCompletionProvider implements CompletionProvider { completionResultSet.finish(); return; } - AssetType type = determineType(document, caretOffset); String filter = null; int startOffset = caretOffset - 1; try { @@ -118,7 +117,12 @@ public class AssetCompletionProvider implements CompletionProvider { final int lineStartOffset = getRowFirstNonWhite(bDoc, caretOffset); final char[] line = bDoc.getText(lineStartOffset, caretOffset - lineStartOffset).toCharArray(); final int whiteOffset = indexOfInsertion(line); - filter = new String(line, whiteOffset + 1, line.length - whiteOffset - 1); + int end = line.length - whiteOffset - 1; + if (end < 0) { + completionResultSet.finish(); + return; + } + filter = new String(line, whiteOffset + 1, end); if (whiteOffset > 0) { startOffset = lineStartOffset + whiteOffset + 1; } else { @@ -128,6 +132,7 @@ public class AssetCompletionProvider implements CompletionProvider { Exceptions.printStackTrace(ex); } logger.log(Level.FINE, "Searching with filter {0}", filter); + AssetType type = determineType(document, caretOffset); switch (type) { case Model: for (String string : manager.getModels()) {