Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -517,8 +517,13 @@ } else if (Limit != 0 && !Line.startsWith(tok::kw_namespace) && !startsExternCBlock(Line)) { // We don't merge short records. - FormatToken *RecordTok = - Line.First->is(tok::kw_typedef) ? Line.First->Next : Line.First; + FormatToken *RecordTok = Line.First; + // Skip record modifiers. + while (RecordTok->Next && + RecordTok->isOneOf(tok::kw_typedef, tok::kw_export, + Keywords.kw_declare, Keywords.kw_abstract, + tok::kw_default)) + RecordTok = RecordTok->Next; if (RecordTok && RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct, Keywords.kw_interface)) Index: cfe/trunk/unittests/Format/FormatTestJS.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1674,9 +1674,15 @@ " x: number;\n" " y: string;\n" "}"); - verifyFormat("export class X { y: number; }"); - verifyFormat("export abstract class X { y: number; }"); - verifyFormat("export default class X { y: number }"); + verifyFormat("export class X {\n" + " y: number;\n" + "}"); + verifyFormat("export abstract class X {\n" + " y: number;\n" + "}"); + verifyFormat("export default class X {\n" + " y: number\n" + "}"); verifyFormat("export default function() {\n return 1;\n}"); verifyFormat("export var x = 12;"); verifyFormat("class C {}\n" @@ -1698,7 +1704,9 @@ "];"); verifyFormat("export default [];"); verifyFormat("export default () => {};"); - verifyFormat("export interface Foo { foo: number; }\n" + verifyFormat("export interface Foo {\n" + " foo: number;\n" + "}\n" "export class Bar {\n" " blah(): string {\n" " return this.blah;\n"