lib/node_mutation.rb in node_mutation-1.15.0 vs lib/node_mutation.rb in node_mutation-1.15.1

- old
+ new

@@ -203,12 +203,18 @@ # module Synvert # class Foobar # end # end def wrap(node, prefix:, suffix:, newline: false) - @actions << InsertAction.new(node, prefix, at: 'beginning').process - @actions << InsertAction.new(node, suffix, at: 'end').process - @actions << IndentAction.new(node).process if newline + if newline + indentation = NodeMutation.adapter.get_start_loc(node).column + @actions << InsertAction.new(node, prefix + "\n" + ' ' * indentation, at: 'beginning').process + @actions << InsertAction.new(node, "\n" + ' ' * indentation + suffix, at: 'end').process + @actions << IndentAction.new(node).process + else + @actions << InsertAction.new(node, prefix, at: 'beginning').process + @actions << InsertAction.new(node, suffix, at: 'end').process + end end # No operation. # @param node [Node] ast node def noop(node)