From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Wed, 1 Dec 2021 23:05:59 +0000 (-0500) Subject: Treat functions/classes in blocks as if they're nested (GH-2472) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/b0c2bcc9537d238c8a580294ecbc41de465d7f55?hp=b0c2bcc9537d238c8a580294ecbc41de465d7f55 Treat functions/classes in blocks as if they're nested (GH-2472) * Treat functions/classes in blocks as if they're nested One curveball is that we still want two preceding newlines before blocks that are probably logically disconnected. In other words: if condition: def foo(): return "hi" # <- aside: this is the goal of this commit else: def foo(): return "cya" # <- the two newlines spacing here should stay # since this probably isn't related with open("db.json", encoding="utf-8") as f: data = f.read() Unfortunately that means we have to special case specific clause types instead of just being able to just for a colon leaf. The hack used here is to check whether we're adding preceding newlines for a standalone or dependent clause. "Standalone" being a clause that doesn't need another clause to be valid (eg. if) and vice versa. Co-authored-by: Jelle Zijlstra ---