[SourceKit/CodeFormat] Get 'trailing' indentation to work in more places and fix a bug where multi-line string indentation was modified.

E.g. if/guard condition patterns are column-aligned, but hitting enter after
the ',' below wasn't column-aligning the next empty line:

guard let x = Optional(42),
// No indentation added here after enter

Also the isTargetContext() check takes a start and end token location, but
wasn't accounting for the end location pointing a multiline string, so we
weren't walking into such nodes. This meant we didn't realise the target
location was within a multiline string in some cases, and we ended up
interfering with whitespace in its content.
This commit is contained in:
Nathan Hawes
2020-04-17 09:55:42 -07:00
parent 9e0e611949
commit e01c1a1579
25 changed files with 313 additions and 109 deletions

View File

@@ -0,0 +1,5 @@
class Foo {
func foo(x: Int,
// RUN: %sourcekitd-test -req=format -line=3 -length=1 %s | %FileCheck --strict-whitespace %s
// CHECK: key.sourcetext: " "