Index: lib/Format/SortJavaScriptImports.cpp =================================================================== --- lib/Format/SortJavaScriptImports.cpp +++ lib/Format/SortJavaScriptImports.cpp @@ -413,7 +413,7 @@ nextToken(); if (Current->is(tok::r_brace)) break; - if (Current->isNot(tok::identifier)) + if (Current->isNot(tok::identifier) && Current->isNot(tok::kw_default)) return false; JsImportedSymbol Symbol; @@ -425,7 +425,7 @@ if (Current->is(Keywords.kw_as)) { nextToken(); - if (Current->isNot(tok::identifier)) + if (Current->isNot(tok::identifier) && Current->isNot(tok::kw_default)) return false; Symbol.Alias = Current->TokenText; nextToken(); Index: unittests/Format/SortImportsTestJS.cpp =================================================================== --- unittests/Format/SortImportsTestJS.cpp +++ unittests/Format/SortImportsTestJS.cpp @@ -300,6 +300,14 @@ "1;"); } +TEST_F(SortImportsTestJS, SortDefaultImports) { + // Reproduces issue where multi-line import was not parsed correctly. + verifySort("import {A} from 'a';\n" + "import {default as B} from 'b';\n", + "import {default as B} from 'b';\n" + "import {A} from 'a';\n"); +} + } // end namespace } // end namespace format } // end namespace clang