Skip to content

Commit

Permalink
Disable indent rule when using --linerange
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Aug 3, 2020
1 parent 93ee7a1 commit 2458e59
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Rules.swift
Expand Up @@ -1004,6 +1004,14 @@ public struct _FormatRules {
return false
}

// Disable when using range
// TODO: find better solution
if let range = formatter.range, formatter.tokens[0 ..< range.lowerBound].contains(where: {
$0.isStartOfScope && $0 != .startOfScope("//")
}) {
return
}

if formatter.options.fragment,
let firstIndex = formatter.index(of: .nonSpaceOrLinebreak, after: -1),
let indentToken = formatter.token(at: firstIndex - 1), case let .space(string) = indentToken
Expand Down

0 comments on commit 2458e59

Please sign in to comment.