On Sunday, July 28, 2019 at 4:03:37 PM UTC-5, Edward K. Ream wrote:
[improving] Leo's existing beautify commands so they follow black's
> line-breaking strategy [should] be relatively straightforward. This would
> be a major departure for Leo's beautify commands.
>
A quick prototype of Leo's token-based beautify code reveals no gotchas:
- The code will need a new token type, say 'optional-line-end', in addition
to the existing 'line-end' token. 'optional-line-end' represents a newline
within one or more open (unmatched) parens or square/curly brackets.
'line-end' tokens represent newlines outside such unmatched parens or
brackets.
- The new code might even avoid some nasty logic involving backslash
newlines. Black generally deletes backslash newlines.
- The prototype code scans back through the output_tokens list looking for
the previous 'line-end' or 'file-start' token. Instead, the revised code
will likely remember the position of the previous 'line-end' or
'file-start' token.
- Calculating the length of one or more lines is easy:
len(''.join([z.to_string() for z in self.code_list[i:]]))
where i is the start of the lines.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/3bf54932-6cca-497e-84c2-ea81d760ea5c%40googlegroups.com.