gopatch icon indicating copy to clipboard operation
gopatch copied to clipboard

Add an option to disable automatic code formatting

Open tchung1118 opened this issue 1 year ago • 1 comments

Currently when you use the following patch:

@@
var x expression
@@
-x.Enabled(true)
+x.Enabled()

This automatically reformats the expression matched to x, and that could make a lot of unwanted changes. For example, if the original code looks like this:

a.Foo().Bar(bar)
    .Baz(baz)
    .Enabled(true)

The resulting code after applying the patch becomes a one-liner:

a.Foo().Bar(bar).Baz(baz).Enabled()

Adding an option to disable the automatic formatting of code when applying patches could be nice for cases like this. For example, with that option, the resulting code would look like this:

a.Foo().Bar(bar)
    .Baz(baz)
    .Enabled()

tchung1118 avatar Jul 11 '23 19:07 tchung1118

It is necessary to reduce unnecessary diff generation ​

lhanjian avatar Feb 21 '24 09:02 lhanjian