-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Description
When swift-format is run with an offset range starting at 1 or greater, the formatter applies general formatting but does not apply any rule-based formatting.
Example
.swift-format:
{
"rules": {
"NoParensAroundConditions": true,
"DoNotUseSemicolons": true
}
}input:
/// Some String....
if (a = 0) { NSLog("print: \(a)");}Environment variable for convenience:
export CODE="/// Some String....\n if (a = 0) { NSLog(\"print: \\(a)\");}"And expected result:
/// Some String....
if a = 0 { NSLog("print: \(a)") }These commands produce the expected result:
echo $CODE | swift-format format - --configuration .swift-format
echo $CODE | swift-format format - --configuration .swift-format --offsets 0:999But the following commands do not:
echo $CODE | swift-format format - --configuration .swift-format --offsets 1:999
echo $CODE | swift-format format - --configuration .swift-format --offsets 0:1 --offsets 1:999Actual output:
/// Some String....
if (a = 0) { NSLog("print: \(a)"); }Although the sliced input beginning at offset 1 still forms valid Swift syntax (// Some String....), rule-based formatting are not applied, while other non-rule formatting is applied correctly.
Metadata
Metadata
Assignees
Labels
No labels