[TxMt] Re: TM (1.5.10) - auto translation of CR to LF on save?
mailinglist at textmate.org
Sat Jan 7 22:50:20 UTC 2012
On 07/01/2012, at 04.25, Eric Hall wrote:
> […] I'm thinking TextMate should not alter line terminating characters
The problem is that there are 3 ways a file can be line-terminated (ignoring unicode and messed up files):
Ideally TM would see what was used during load, and then when you create new lines, insert that into the file — but as you can imagine, that would make a lot of code far more complex, if it had to “abstract” identifying and inserting of newlines while working with text, so instead TM will convert the newlines to LF on load and back to whatever was used on save, and all code can then safely assume buffer uses LF.
Initially TM would test the newlines used and then only convert those, but a few users then had issues with stray CR or CRLF which were skipped — so it was deemed better to just convert all types to LF and convert back to the one with highest frequency.
2.0 does a slightly better job, e.g. running in Terminal: `printf 'foo\r\nbar\n'|mate` results in a literal <CR> shown. There’s still some room for improvement (and will probably eventually throw up a warning if it looks like the file is “messed up”).
More information about the textmate