Skip to content

Merge remote-tracking branch 'upstream/main' into wasm32-wasi #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 1, 2024

Conversation

kkebo
Copy link
Owner

@kkebo kkebo commented Sep 1, 2024

No description provided.

@kkebo kkebo self-assigned this Sep 1, 2024
shawnhyam and others added 7 commits September 1, 2024 12:35
Re-indent all lines of a block comment with the current indentation
level. The comment must not have anything other than whitespace
preceding it on the line, and all lines must have at least that level
of whitespace (or be empty).
Change how PrettyPrinter emits StringSegmentSyntax's so that they can be broken up over multiple lines within multiline string literals. This does not change the behavior of single line string literals, which cannot contain newlines. This also does not change interpolations which are still emitted as verbatims and are never line broken by the pretty printer. Line breaking is done exclusively through escaped newlines. A literal containing escaped newlines will remove all escaped newlines and then reinsert them based on line length. Hard newlines are respected by the formatter and will not be moved, even if it causes short lines. Escaped newlines will be reformatted by the pretty printer so that lines ending in an escaped newline are at line length.

Wrapping is implemented by introducing a new newlinebreak behavior `.escaped`. `.escaped` acts very similarly to `.elective` but has slightly different length calculation logic and printing behavior. An escaped newline is printed including it's preceeding whitespace followed by "\\\n". So a break of `.break(_, 2, .escaped)` will print as "  \\\n". Because an escaped line break takes up characters when broken (unlike other breaks), length calculation must be handled differently for `.escaped` breaks.
> This rule removes empty lines after opening braces and before closing braces:
> 
> ```swift
> // original
> 
> struct P {
>             
>     let x: Int
>   
>     let y: Int
>           
> }
> 
> // formatted
> 
> struct P {  
>     let x: Int
>   
>     let y: Int   
> }
> ```
> 
> That's similar to [vertical_whitespace_opening_braces](https://realm.github.io/SwiftLint/vertical_whitespace_opening_braces.html) and [vertical_whitespace_closing_braces](https://realm.github.io/SwiftLint/vertical_whitespace_opening_braces.html).
> 
> It's a style used in official swift projects such as **swift-syntax** and **sourcekit-lsp**.
@kkebo kkebo force-pushed the merge-upstream-main branch from ebdfdb7 to 11b407a Compare September 1, 2024 03:35
@kkebo kkebo merged commit b8e732f into wasm32-wasi Sep 1, 2024
2 checks passed
@kkebo kkebo deleted the merge-upstream-main branch September 1, 2024 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants