jskinner / DefaultPackages

Old bug tracker for Sublime Text's "Default Packages", e.g. bad syntax highlighting
http://web.archive.org/web/20150524043750/https://www.sublimetext.com/forum/viewtopic.php?f=2&t=12095
26 stars 2 forks source link

Wrong highlighting of Tcl with quotes and unmatched braces inside curly braces #131

Closed d-led closed 8 years ago

d-led commented 9 years ago

Summary

Tcl quotes and braces rules are somewhat exotic. The syntax highlighter is confusing the syntactic elements in certain constellations, i.e. expects quoted characters, where no quoting of special characters is possible, such as within curly braces { " }.

Example

set ok1 {["]"]}
set ok2 {["][]"]}
set not_ok {["]["]}
puts $ok1            ;# ["]"]
puts $ok2            ;# ["][]"]
puts $not_ok         ;# ["]["]

Wrong highlighting

sublime_tcl_syntax

Note the highlighting after not_ok. The puts lines should be highlighted normally as commands (functions)

Sublime Version

3Dev, Build 3086

Analysis

I haven't investigated further, but the confusion is probably easy to make: the contents within top-level single quotes is not subject to escapes. Thus,

puts {\"]["]}
puts {\"][\"]}

prints

\"]["]
\"][\"]

and is highlighted as follows (wrong starting from the last curly brace on the first line):

highlighting2

wbond commented 8 years ago

This was fixed in build 3096

d-led commented 8 years ago

image

wbond commented 8 years ago

My apologizes, someone added a test for that with the commit, but I missed the fact that they didn't actually fix it. I'll work on getting that corrected now.

wbond commented 8 years ago

Should be fixed by https://github.com/sublimehq/Packages/commit/f89329688ca5076ad02ea4c9710f5c21bacf17b5, which will be part of dev build 3112.

d-led commented 8 years ago

ok!

d-led commented 8 years ago

image yay, looks good!

d-led commented 8 years ago

hm.. curly braces should probably not be highlighted as strings, as "everything is a string" image

it should be rather: image

working example: http://ideone.com/7KsnMz

FichteFoll commented 8 years ago

@d-led could you open that as a new issue please?

d-led commented 8 years ago

ok

FichteFoll commented 8 years ago

Thank you.

d-led commented 8 years ago

you're welcome and thanks in return