@@ -787,23 +787,21 @@ void FormatTokenLexer::handleTableGenMultilineString() {
787
787
MultiLineString->TokenText = Text;
788
788
resetLexer (SourceMgr.getFileOffset (
789
789
Lex->getSourceLocation (Lex->getBufferLocation () - 2 + Text.size ())));
790
- // Set ColumnWidth and LastLineColumnWidth.
791
790
auto FirstLineText = Text;
792
791
auto FirstBreak = Text.find (' \n ' );
792
+ // Set ColumnWidth and LastLineColumnWidth when it has multiple lines.
793
793
if (FirstBreak != StringRef::npos) {
794
794
MultiLineString->IsMultiline = true ;
795
795
FirstLineText = Text.substr (0 , FirstBreak + 1 );
796
+ // LastLineColumnWidth holds the width of the last line.
797
+ auto LastBreak = Text.rfind (' \n ' );
798
+ MultiLineString->LastLineColumnWidth = encoding::columnWidthWithTabs (
799
+ Text.substr (LastBreak + 1 ), MultiLineString->OriginalColumn ,
800
+ Style.TabWidth , Encoding);
796
801
}
797
802
// ColumnWidth holds only the width of the first line.
798
803
MultiLineString->ColumnWidth = encoding::columnWidthWithTabs (
799
804
FirstLineText, MultiLineString->OriginalColumn , Style.TabWidth , Encoding);
800
- auto LastBreak = Text.rfind (' \n ' );
801
- if (LastBreak != StringRef::npos) {
802
- // Set LastLineColumnWidth if it has multiple lines.
803
- MultiLineString->LastLineColumnWidth = encoding::columnWidthWithTabs (
804
- Text.substr (LastBreak + 1 , Text.size ()),
805
- MultiLineString->OriginalColumn , Style.TabWidth , Encoding);
806
- }
807
805
}
808
806
809
807
void FormatTokenLexer::handleTemplateStrings () {
0 commit comments