Minor bug in calculating difference between mask characters between old and new field values

A problem was noticed with the calculation of the difference between new and old mask count. This resulted in the caret being placed incorrectly when a mask character was added.

This pull request should fix it.