Skip to content
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

Multiline guard indentation #77

Open
keith opened this issue Jan 9, 2016 · 0 comments
Open

Multiline guard indentation #77

keith opened this issue Jan 9, 2016 · 0 comments

Comments

@keith
Copy link
Owner

keith commented Jan 9, 2016

Currently there's a problem with multiline guards (and if lets) where the cases on their own lines will not be indented correctly. See an example here:

guard let path = NSBundle.mainBundle().pathForResource(imageName, ofType: "png"),
let data = NSData(contentsOfFile: path),
let data = NSData(contentsOfFile: path) else
{
}

This is a hard problem. We can't only rely on the line above, or matching brackets/parens as we are everywhere else. Instead I guess we'll have to match multiple lines above, and find a guard/if. This will also have to handle the valid cases for closures in the statements such as:

guard let foo = bar.map({ $0.whatever }),
    let ugh = vim.syntaxfiles {

I took a stab at this by matching a line ending with a comma above the current line, and the current line having an = with:

previous =~ ",$" && line =~ '\v^s*(\w|\s)+\='

But this doesn't handle where clauses, or statements that are over more than 2 lines.

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

No branches or pull requests

1 participant