X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor%2Fcompletion%2FSCLCompletionProposal.java;h=3734513cb6c3588b054e13a03b7cc15d9d4de1b6;hp=4c429e7fdda6ced8d40a94b7f77a9467d42f7aa6;hb=2790c2eced1ae3e229972ede7173dc6831834760;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java index 4c429e7fd..3734513cb 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java @@ -37,8 +37,15 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr private final SCLCompletionType completionType; public SCLCompletionProposal(SCLValue value, int replacementOffset, String prefix) { - this.name = value.getName().name; - this.module = value.getName().module; + String tempName = value.getName().name; + String tempModule = value.getName().module; + int p = tempName.lastIndexOf('.'); + if(p >= 0) { + tempModule = tempModule + "." + tempName.substring(0, p); + tempName = tempName.substring(p+1); + } + this.name = tempName; + this.module = tempModule; this.documentation = value.getDocumentation(); this.content = name + " :: " + value.getType() + " (" + module + ")"; this.replacementOffset = replacementOffset; @@ -159,14 +166,15 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr @Override public boolean validate(IDocument document, int offset, DocumentEvent event) { try { -// System.out.println("replacementOffset : " + replacementOffset); -// System.out.println("offset : " + offset); + String n = getName(); + //System.out.println(n + " (" + n.length() + ") " + replacementOffset + " " + offset); boolean a = offset >= replacementOffset; - boolean b = offset < replacementOffset + getName().length(); + boolean b = offset <= replacementOffset + n.length(); String s = document.get(replacementOffset, offset - replacementOffset); prefix = s; - String d = getName();//.substring(0, offset - prefixStart); - boolean c = d.toLowerCase().startsWith(s.toLowerCase()); + //System.out.println("prefix: " + s + " - " + prefix); + boolean c = n.toLowerCase().startsWith(s.toLowerCase()); + //System.out.println("matches: " + a + " " + b + " " + c); return a && b && c; } catch (BadLocationException x) { //x.printStackTrace();