Atom, Snippets, Tabs and CSON parsing

This morning on the train down from Manchester to Bristol I fired up the Atom editor and noticed that when trying to load a snippets file from my ui5-snippets package, I got an error:

Screen Shot 2015-01-19 at 08.18.19

Between Stafford and Wolverhampton I hacked around with the source, particularly the html.cson file that contained a number of UI5 snippets for HTML files. From where was this error message emanating, and why now?

Well, it seems that a few days ago, in release 0.171.0, Atom had moved from parsing CoffeeScript Object Notation (CSON) with cson, to parsing with cson-safe. CSON is the format in which snippets can be written. Moving to cson-safe meant that the parser was rather stricter and was the source of the “Syntax error on line 4, column 11: Unexpected token” error.

By the time we’d got to Birmingham, I’d figured out what it was: tabs. In wanting to move in the direction of the UI5 coding standards, I’d started moved to tabs for indentation within the UI5 snippets, as you can see in this openui5 starter snippet. While the original cson parser used by Atom was fine with real tabs in the snippet source file, cson-safe didn’t like them.

Switching the tabs to literal “\t” tab representations (i.e. backslash then ‘t’) solved the issue.