When autoindenting, only insert a tab if the cursor doesn't move due to CodeMirror's indentation

For #5068. This should get rid of the most common case where you can accidentally get extra whitespace at the end of a line.

Note that there's one minor issue remaining with this behavior: if a line is already at the right indent level, you click in the whitespace at the beginning, and you hit TAB, the indentation doesn't change and the cursor moves to the beginning of the text (which is correct), but the file gets marked dirty. I have a [comment](https://github.com/marijnh/CodeMirror/commit/759b3a0e9ab1ce6486341651252d968e417ffe5e#commitcomment-4491348) out to Marijn on this. I don't think it's a showstopper.