diff options
author | Daniel Jasper <djasper@google.com> | 2017-01-31 13:03:07 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2017-01-31 13:03:07 +0000 |
commit | 24de6fbfdb72a1c06492a922f68b03ed3035c63b (patch) | |
tree | 4ed1444f850b814d3cba105bd0585f93ed1a0bdc /clang/lib/Format/TokenAnnotator.cpp | |
parent | dbaacc75664e9322643b5a43cde6fc5e5e39e1b1 (diff) | |
download | bcm5719-llvm-24de6fbfdb72a1c06492a922f68b03ed3035c63b.tar.gz bcm5719-llvm-24de6fbfdb72a1c06492a922f68b03ed3035c63b.zip |
clang-format: [JS] Properly set scopes inside template strings.
Before:
var f = `aaaaaaaaaaaaa:${aaaaaaa
.aaaaa} aaaaaaaa
aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa`;
After:
var f = `aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa
aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa`;
llvm-svn: 293622
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index e58ca6d803e..2785ca45e70 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1454,7 +1454,9 @@ public: // Consume scopes: (), [], <> and {} if (Current->opensScope()) { - while (Current && !Current->closesScope()) { + // In fragment of a JavaScript template string can look like '}..${' and + // thus close a scope and open a new one at the same time. + while (Current && (!Current->closesScope() || Current->opensScope())) { next(); parse(); } |