Fix PT-137722057 extra space in name completion directly after a '-'

This commit is contained in:
Kris De Volder
2017-01-16 09:55:46 -08:00
parent f47020af5e
commit 46eee65b9a
4 changed files with 182 additions and 14 deletions

View File

@@ -74,6 +74,9 @@ public abstract class AbstractYamlAssistContext implements YamlAssistContext {
return "";
}
}
} else if (node.getNodeType()==SNodeType.SEQ) {
//Careful, don't include the '-' at start of the node as part of the prefix.
return prefixfinder.getPrefix(doc.getDocument(), offset, node.getStart()+1);
// } else if (node.getNodeType()==SNodeType.RAW) {
// TODO: Handle this as we could be in a value that's on the next line instead of right behind the node
}

View File

@@ -91,6 +91,10 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
//property not yet defined
YType YType = p.getType();
edits.delete(queryOffset, query);
if (queryOffset>0 && !Character.isWhitespace(doc.getChar(queryOffset-1))) {
//See https://www.pivotaltracker.com/story/show/137722057
edits.insert(queryOffset, " ");
}
edits.createPathInPlace(contextNode, relativePath, queryOffset, appendTextFor(YType));
proposals.add(completionFactory().beanProperty(doc.getDocument(),
contextPath.toPropString(), getType(),

View File

@@ -707,7 +707,11 @@ public class YamlStructureParser {
}
public boolean isInValue(int offset) {
return offset>=getStart()+2 //"- ".length()
int len = getNodeEnd() - getStart();
//Careful, generally a seq node starts with a "- ". But... there's a special case
// if the node text is only lenght 1. Thne its just a "-" alone (no space).
int dashLen = len==1 ? 1 : 2;
return offset>=getStart()+dashLen
&& offset <= getTreeEnd();
}
}