It is because diff is syntax agnostic. You might be able to get away with this hack in some cases but that complicates algorithm and will break in some other cases (how about nested brackets? Multiple brackets on one line?). Once you want to handle this properly you need syntax aware diff algorithm and some resources are linked in this discussion.