PT_137299017 fix and tests (extra space added in front of value completion)

This commit is contained in:
Kris De Volder
2017-01-13 14:56:52 -08:00
parent 72d17c9f46
commit 6c893cfc13
3 changed files with 54 additions and 1 deletions

View File

@@ -149,8 +149,12 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
for (YValueHint value : values) {
double score = FuzzyMatcher.matchScore(query, value.getValue());
if (score!=0 && !value.equals(query)) {
int queryStart = offset-query.length();
DocumentEdits edits = new DocumentEdits(doc.getDocument());
edits.delete(offset-query.length(), offset);
edits.delete(queryStart, offset);
if (!Character.isWhitespace(doc.getChar(queryStart))) {
edits.insert(offset, " ");
}
edits.insert(offset, value.getValue());
completions.add(completionFactory().valueProposal(value.getValue(), query, value.getLabel(), type, score, edits, typeUtil));
}