summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/SortJavaScriptImports.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/SortJavaScriptImports.cpp')
-rw-r--r--clang/lib/Format/SortJavaScriptImports.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp
index 42089c522ec..93cda491402 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -293,14 +293,19 @@ private:
// of the import that immediately follows them by using the previously
// set Start.
Start = Line->First->Tok.getLocation();
- if (!Current)
- continue; // Only comments on this line.
+ if (!Current) {
+ // Only comments on this line. Could be the first non-import line.
+ FirstNonImportLine = Line;
+ continue;
+ }
JsModuleReference Reference;
Reference.Range.setBegin(Start);
if (!parseModuleReference(Keywords, Reference)) {
- FirstNonImportLine = Line;
+ if (!FirstNonImportLine)
+ FirstNonImportLine = Line; // if no comment before.
break;
}
+ FirstNonImportLine = nullptr;
AnyImportAffected = AnyImportAffected || Line->Affected;
Reference.Range.setEnd(LineEnd->Tok.getEndLoc());
DEBUG({
OpenPOWER on IntegriCloud