precise-commits icon indicating copy to clipboard operation
precise-commits copied to clipboard

Code corrupted by format a white-spaces only changes

Open medved-nsk opened this issue 6 years ago • 0 comments

Hi. I faced a code corruption on white-space changes. Cannot say for sure it's caused by precise-commits (the setup include a prettier precise-commits and husky as suggested). Though applying prettier directly on the whole file does work properly.

I made a simple project with example. Basically it reproduced by with the following:

  1. Original snippet
function func01(arg1: number) {
if ( arg1  >  32)  {
   console.log("test3");
     }
    //return (arg1-32);
  }
  1. Then apply patch
 function func01(arg1: number) {
-if ( arg1  >  32)  {
-   console.log("test3");
-     }
+if ( arg1 >  32)  {
+    console.log("test3");
+      }
     //return (arg1-32);
-  }
+    }
  1. Which then make the snippet
function func01(arg1: number) {
if ( arg1 >  32)  {
    console.log("test3");
      }
    //return (arg1-32);
    }
  1. Commit
git add test01.ts
git commit -m "test01 format"
  1. The result
cat test01.ts
function func01(arg1: number) {
                                if (rg1 > 3) {
 c                              onsole.log("test3");
                           }
    //re                            turn (arg1-32);
                              }

Please advise if I missed something in my setup? What else could be checked on my side? Thanks.

medved-nsk avatar Jul 17 '18 07:07 medved-nsk