* Checks if the hunk exactly fits on the provided location
(hunk, toPos)
| 787 | |
| 788 | |
| 789 | function hunkFits(hunk, toPos) { |
| 790 | for (var j = 0; j < hunk.lines.length; j++) { |
| 791 | var line = hunk.lines[j], |
| 792 | operation = line.length > 0 ? line[0] : ' ', |
| 793 | content = line.length > 0 ? line.substr(1) : line; |
| 794 | |
| 795 | if (operation === ' ' || operation === '-') { |
| 796 | // Context sanity check |
| 797 | if (!compareLine(toPos + 1, lines[toPos], operation, content)) { |
| 798 | errorCount++; |
| 799 | |
| 800 | if (errorCount > fuzzFactor) { |
| 801 | return false; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | toPos++; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | return true; |
| 810 | } // Search best fit offsets for each hunk based on the previous ones |
| 811 | |
| 812 | |
| 813 | for (var i = 0; i < hunks.length; i++) { |