I noticed this bug a few months ago in Manjaro, and couldn't find the
surce of the bug. It happened both in Mousepad and Gedit (using XFCE).
I moved back to Debian testing (also XFCE) for that other reasons, and
didn't have that bug. Until this week.
The length of an 8-character tab is not always 8. Sometimes it's around
8.5 (visually), causing wrong results. Changing the length of the
indent (sometimes) fixes the problem, and sometimes it doesn't.
Debian Bullseye (11, testing)