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:
parent
b57a8e834b
commit
9cac1d33f3
1 changed files with 18 additions and 7 deletions
|
@ -258,15 +258,21 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
private ICCompletionProposal[] evalProposals(IDocument document, int pos, int length) {
|
private ICCompletionProposal[] evalProposals(IDocument document, int pos, int length) {
|
||||||
IRegion region;
|
IRegion region;
|
||||||
String frag = "";
|
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
|
// First, check if we're on a space or trying to open a struct/union
|
||||||
if (pos > 2) {
|
if (pos > 1) {
|
||||||
try {
|
try {
|
||||||
// If we're on a space and the previous character is valid text,
|
// If we're on a space and the previous character is valid text,
|
||||||
// parse the previous word.
|
// parse the previous word.
|
||||||
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
|
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
|
||||||
pos--;
|
pos--;
|
||||||
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
|
if (!Character.isJavaIdentifierPart(document.getChar(pos))) {
|
||||||
|
pos--;
|
||||||
// Comment out the dereference code, only useful once we can
|
// Comment out the dereference code, only useful once we can
|
||||||
// know variable types to go fish back structure members
|
// know variable types to go fish back structure members
|
||||||
//if (document.getChar(offset) == '.') {
|
//if (document.getChar(offset) == '.') {
|
||||||
|
@ -278,7 +284,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (BadLocationException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,11 +294,16 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
// If we're currently
|
// If we're currently
|
||||||
try {
|
try {
|
||||||
frag = document.get(region.getOffset(), region.getLength());
|
if (region != null) {
|
||||||
frag = frag.trim();
|
frag = document.get(region.getOffset(), region.getLength());
|
||||||
if (frag.length() == 0)
|
frag = frag.trim();
|
||||||
// No word is selected...
|
// No word is selected
|
||||||
|
if (frag.length() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
// ignore
|
// ignore
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue