mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When the multi-line string is unterminated, the indentation of a line
will be the same as the first previous line that had contents, unless
that line is the line containing the start quotes. In that case the
indentation will be:
- the same as the start quote indentation, if the quotes are the only
contents on the line, or
- an extra indentation level to the start quote line otherwise
Lines within a terminated multi-line string or lines with content will
only ever be indented if their current indentation is invalid (ie. their
indentation level is less than that of their end quotes).
This rule is to prevent any signficant (and possibly unintended)
whitespace being added to existing strings during a whole file/range
format - Xcode does not remove whitespace from whitespace-only lines by
default. This could be improved if the reformat was sent the actual
range rather than a line at a time. Different indentation could then be
chosen if the range was in fact a single line.
Resolves rdar://32181422
32 lines
1.1 KiB
Swift
32 lines
1.1 KiB
Swift
// RUN: %sourcekitd-test -req=format -line=24 %s >%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=25 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=26 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=27 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=28 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=29 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=30 %s >>%t.response
|
|
// RUN: %sourcekitd-test -req=format -line=31 %s >>%t.response
|
|
|
|
// RUN: %FileCheck --strict-whitespace %s <%t.response
|
|
|
|
// The end quotes are ignored as it would be impossible to know whether
|
|
// they are part of the interpolation or another string, etc.
|
|
// CHECK: key.sourcetext: " "
|
|
// CHECK: key.sourcetext: " this is line1"
|
|
// CHECK: key.sourcetext: ""
|
|
// CHECK: key.sourcetext: "this is line2"
|
|
// CHECK: key.sourcetext: " "
|
|
// CHECK: key.sourcetext: " and this is a line with trailing interpolation \\(1 +"
|
|
// CHECK: key.sourcetext: " "
|
|
// CHECK: key.sourcetext: " \"\"\""
|
|
|
|
let s1 = """
|
|
|
|
this is line1
|
|
|
|
this is line2
|
|
|
|
and this is a line with trailing interpolation \(1 +
|
|
|
|
"""
|