From 4c0d717841bbcbc6ee17afaf6f9ff0380df6f782 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Mon, 14 May 2018 10:16:45 +0300 Subject: [PATCH] Fixed SCLCompletionProposal.validate to allow complete matches as well This fixes a case where the SCL module editor stops showing content proposals once they fully match with the typed word, which is really annoying. gitlab #3 Change-Id: I7b1119bff4cb08063a838a441a628a785344220b (cherry picked from commit 2790c2eced1ae3e229972ede7173dc6831834760) --- .../ui/editor/completion/SCLCompletionProposal.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 11749a4b2..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 @@ -166,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(); -- 2.47.1