1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 01:36:01 +02:00

Pos was off by one the index is 0-based.

This commit is contained in:
Alain Magloire 2002-12-01 19:11:59 +00:00
parent b57a8e834b
commit 9cac1d33f3

View file

@ -259,14 +259,20 @@ public class CCompletionProcessor implements IContentAssistProcessor {
IRegion region;
String frag = "";
// Move back the pos by one the position is 0-based
if (pos > 0) {
pos--;
}
// First, check if we're on a space or trying to open a struct/union
if (pos > 2) {
if (pos > 1) {
try {
// If we're on a space and the previous character is valid text,
// parse the previous word.
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
pos--;
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
pos--;
// Comment out the dereference code, only useful once we can
// know variable types to go fish back structure members
//if (document.getChar(offset) == '.') {
@ -278,7 +284,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
//}
}
}
} catch (Exception e) {
} catch (BadLocationException e) {
return null;
}
}
@ -288,11 +294,16 @@ public class CCompletionProcessor implements IContentAssistProcessor {
// If we're currently
try {
if (region != null) {
frag = document.get(region.getOffset(), region.getLength());
frag = frag.trim();
if (frag.length() == 0)
// No word is selected...
// No word is selected
if (frag.length() == 0) {
return null;
}
} else {
return null;
}
} catch (BadLocationException x) {
// ignore
return null;