Sublime Text Syntax Def (YAML) incorrectly handles brackets inside match string
- comment: foo
name: foo2
match: "\\["
- comment: bar
name: bar2
match: "."
the open bracket here causes the close quote to not be recognized, and the remainder of the file is stuck in the meta.value.yaml-tmlanguge string.regexp.set scopes. I think the problem is that meta.value.yaml-tmlanguage includes source.oniregexp which tries to parse the contents of the quotes as an oni regex, but it's actually got one more level of YAML string escapes on top of it. \\[ as a YAML string represents \[ as a regex which represents a literal [. The YAML escaping step seems to be skipped in the syntax recognition.
Yeah, I was lazy with that and didn't bother with double-escaped regular expressions, which is required in double-quoted strings.
However, you practically never want to use double-quoted strings in YAML anyway, because
- Most strings don't need quoting at all. Yours doesn't, for example. And neither does your second.
- Single-quoted strings have way better escape mechanisms, especially für regular expressions, in that you only need to escape a single-quote inside a string and nothing else -- especially no back-slashes.
So yeah, while this is indeed a bug, I'm very much on the "won't fix" side here because it's just not worth it imo. We might want to mention that in the docs too.
In other news, all syntax definitions in this package need a new pass and deserve to be using the new shiny .sublime-syntax format. From scratch. Problem is it's still only available for the dev channel.
OK, thanks for the response. I'll try to use single or non-quoted strings when I can figure out how to escape them
Closing in favor of #67.
Reopening since I'm probably not going to rewrite these syntaxes (a lot of effort for legacy tech). I will revisit this later and re-consider whether I find fixing this worth it or not.
Actually... I just realized that I already dismissed this in the new syntax for .sublime-syntax files as well because using single-quoted strings is simply superior over double-quoted, since I don't have to mess with string annoying escape sequences there.
So my recommendation will be to use single quotes for all YAML strings that cannot be plain, but I might fix this small issue just to not blow up.
Closing as wontfix. I don't see myself (or anyone else) coming back to this and I also haven't seen a tmLanguage-YAML file in the wild for a while.