diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 0ea67b288d0..0c11c88221f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -413,7 +413,8 @@ private: if (Contexts.back().ColonIsForRangeExpr || (Contexts.size() == 1 && !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) || - Contexts.back().ContextKind == tok::l_paren) { + Contexts.back().ContextKind == tok::l_paren || + Contexts.back().ContextKind == tok::l_square) { Tok->Type = TT_JsTypeColon; break; } diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index eb587f27694..3c8c14d2ba8 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -670,5 +670,9 @@ TEST_F(FormatTestJS, OptionalTypes) { "}"); } +TEST_F(FormatTestJS, IndexSignature) { + verifyFormat("var x: {[k: string]: v};"); +} + } // end namespace tooling } // end namespace clang |

