The platform-specific line.separator property was breaking autoindent on
Windows. The code was expecting \r\ns to separate lines, but the text area
already coerces everything to \n, so this was deleting the last character
of the previous line rather than a \r.
There is one complication, though: If you open a file that some other
editor created with \r\n line endings, they will be in the text area. So,
at least on Windows and I assume also on other platforms, we can have a
mix of \ns and \r\ns in the same file. The changed code checks for \r\n at
each specific line break removes 1 or 2 characters accordingly.
Also, I removed the inserting of platform-specific line endings by the
code pane (like when it is making everything read-only and the cursor
needs a line to sit on). This will just make a mix of \r\ns and \ns on
Windows, since we would be sticking in \r\ns while Java puts in \ns.
The platform-specific line.separator property was breaking autoindent on Windows. The code was expecting \r\ns to separate lines, but the text area already coerces everything to \n, so this was deleting the last character of the previous line rather than a \r.
There is one complication, though: If you open a file that some other editor created with \r\n line endings, they will be in the text area. So, at least on Windows and I assume also on other platforms, we can have a mix of \ns and \r\ns in the same file. The changed code checks for \r\n at each specific line break removes 1 or 2 characters accordingly.
Also, I removed the inserting of platform-specific line endings by the code pane (like when it is making everything read-only and the cursor needs a line to sit on). This will just make a mix of \r\ns and \ns on Windows, since we would be sticking in \r\ns while Java puts in \ns.