From: Yilei "Dolee" Yang Date: Wed, 31 Aug 2022 02:52:00 +0000 (-0700) Subject: Add parens around implicit string concatenations where it increases readability ... X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/ba618a307a30a119b4fafe526ebf7d5f092ba981?ds=sidebyside;hp=ba618a307a30a119b4fafe526ebf7d5f092ba981 Add parens around implicit string concatenations where it increases readability (#3162) Adds parentheses around implicit string concatenations when it's inside a list, set, or tuple. Except when it's only element and there's no trailing comma. Looking at the order of the transformers here, we need to "wrap in parens" before string_split runs. So my solution is to introduce a "collaboration" between StringSplitter and StringParenWrapper where the splitter "skips" the split until the wrapper adds the parens (and then the line after the paren is split by StringSplitter) in another pass. I have also considered an alternative approach, where I tried to add a different "string paren wrapper" class, and it runs before string_split. Then I found out it requires a different do_transform implementation than StringParenWrapper.do_transform, since the later assumes it runs after the delimiter_split transform. So I stopped researching that route. Originally function calls were also included in this change, but given missing commas should usually result in a runtime error and the scary amount of changes this cause on downstream code, they were removed in later revisions. ---