YamlScalarTextEvaluator<YAMLScalarListImpl> () { return new YAMLBlockScalarTextEvaluator<>(this) { @Override protected @NotNull String getRangesJoiner(@NotNull CharSequence text, @NotNull List<TextRange> contentRanges, int indexBefore) { return ""; } @Override public @NotNull String getTextValue(@Nullable TextRange rangeInHost) { String value = super.getTextValue(rangeInHost); if (!StringUtil.isEmptyOrSpaces(value) && getChompingIndicator() == ChompingIndicator.KEEP && isEnding(rangeInHost)) { value += "\n"; } return value; } @Override protected boolean shouldIncludeEolInRange(ASTNode child) { if (getChompingIndicator() == ChompingIndicator.KEEP) return true; if (isEol(child) && isEolOrNull(child.getTreeNext()) && !(YAMLTokenTypes.INDENT.equals(ObjectUtils.doIfNotNull(child.getTreePrev(), ASTNode::getElementType)) && myHost.getLinesNodes().size() <= 2)) { return false; } ASTNode next = TreeUtil.findSibling(child.getTreeNext(), NON_SPACE_VALUES); if (isEol(next) && isEolOrNull(TreeUtil.findSibling(next.getTreeNext(), NON_SPACE_VALUES)) && getChompingIndicator() == ChompingIndicator.STRIP) { return false; } return true; } private final TokenSet NON_SPACE_VALUES = TokenSet.orSet(YAMLElementTypes.SCALAR_VALUES, YAMLElementTypes.EOL_ELEMENTS); }; }