@@ -780,19 +780,21 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
780
780
781
781
// Indent preprocessor directives after the hash if required.
782
782
int PPColumnCorrection = 0 ;
783
- if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
784
- Previous.is (tok::hash) && State.FirstIndent > 0 &&
785
- &Previous == State.Line ->First &&
783
+ if (&Previous == State.Line ->First && Previous.is (tok::hash) &&
786
784
(State.Line ->Type == LT_PreprocessorDirective ||
787
785
State.Line ->Type == LT_ImportStatement)) {
788
- Spaces += State.FirstIndent ;
789
-
790
- // For preprocessor indent with tabs, State.Column will be 1 because of the
791
- // hash. This causes second-level indents onward to have an extra space
792
- // after the tabs. We avoid this misalignment by subtracting 1 from the
793
- // column value passed to replaceWhitespace().
794
- if (Style.UseTab != FormatStyle::UT_Never)
795
- 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
+ }
796
798
}
797
799
798
800
if (!DryRun) {
0 commit comments