Improve handling of snippet indentations containing no tabs

This commit is contained in:
nsingh
2017-10-04 15:59:05 -07:00
parent cff34afdd5
commit 4eddb50e63
2 changed files with 11 additions and 3 deletions

View File

@@ -42,7 +42,13 @@ public class JavaSnippetBuilder{
DocumentEdits edit = new DocumentEdits(doc);
String snippet = createSnippet(template);
String indentedSnippet = indentUtil.applyIndentation(snippet, indentUtil.getReferenceIndent(query.getStart(), doc)) ;
String referenceIndent = indentUtil.getReferenceIndent(query.getStart(), doc);
if (!referenceIndent.contains("\t")) {
snippet = indentUtil.covertTabsToSpace(snippet);
}
String indentedSnippet = indentUtil.applyIndentation(snippet, referenceIndent);
edit.replace(query.getStart(), query.getEnd(), indentedSnippet);
return edit;
}