@@ -778,27 +778,23 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
778778
779779 unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces;
780780
781- if (Style.IndentPPDirectives == FormatStyle::PPDIS_Leave &&
782- State.Line ->InPPDirective && Previous.is (tok::hash) &&
783- &Previous == State.Line ->First ) {
784- Spaces += Current.OriginalColumn - Previous.OriginalColumn - 1 ;
785- }
786-
787781 // Indent preprocessor directives after the hash if required.
788782 int PPColumnCorrection = 0 ;
789- if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
790- Previous.is (tok::hash) && State.FirstIndent > 0 &&
791- &Previous == State.Line ->First &&
783+ if (&Previous == State.Line ->First && Previous.is (tok::hash) &&
792784 (State.Line ->Type == LT_PreprocessorDirective ||
793785 State.Line ->Type == LT_ImportStatement)) {
794- Spaces += State.FirstIndent ;
795-
796- // For preprocessor indent with tabs, State.Column will be 1 because of the
797- // hash. This causes second-level indents onward to have an extra space
798- // after the tabs. We avoid this misalignment by subtracting 1 from the
799- // column value passed to replaceWhitespace().
800- if (Style.UseTab != FormatStyle::UT_Never)
801- PPColumnCorrection = -1 ;
786+ if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash) {
787+ Spaces += State.FirstIndent ;
788+
789+ // For preprocessor indent with tabs, State.Column will be 1 because of
790+ // the hash. This causes second-level indents onward to have an extra
791+ // space after the tabs. We avoid this misalignment by subtracting 1 from
792+ // the column value passed to replaceWhitespace().
793+ if (Style.UseTab != FormatStyle::UT_Never)
794+ PPColumnCorrection = -1 ;
795+ } else if (Style.IndentPPDirectives == FormatStyle::PPDIS_Leave) {
796+ Spaces += Current.OriginalColumn - Previous.OriginalColumn - 1 ;
797+ }
802798 }
803799
804800 if (!DryRun) {
0 commit comments