If you use the find bar to search for a TAB character ('\t'
) and then close ST to save the session, the resulting JSON is invalid. Parsing Session.sublime_session using JSON.parse from Node.js 4.x.x fails. This failed because there was an unescaped tab character in a string literal.
From the JSON specification:
Insignificant whitespace is allowed before or after any token. The whitespace characters are: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020). Whitespace is not allowed within any token, except that space is allowed in strings.
Whatever ST uses to write JSON files seems to be able to produce non-spec compliant JSON.
Why am I concerned? I developed an npm package that is able to clean workspaces that no longer exist from the Sublime.sublime_session file. It no longer works if the JSON can’t be parsed.