Commit 12ef56d7 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Only match a placeholder when both [] brackets are present.

Suppose format string:

 ls_format = %s [%T]

The result would be:

 Test todo item [just now

The final bracket is missing, because it was matched as part of the
placeholder.

This change will only match the closing bracket when the opening bracket
is also present.
parent f2779f19
......@@ -200,10 +200,10 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
repl = getter(p_todo)
pattern = (r'(?P<start>.*)'
r'%(?P<before>{{.+?}})?'
r'\[?(?P<placeholder>{})\]?'
r'(?P<placeholder>{ph}|\[{ph}\])'
r'(?P<after>{{.+?}})?'
r'(?P<whitespace>\s)*'
r'(?P<end>.*)').format(placeholder)
r'(?P<end>.*)').format(ph=placeholder)
match = re.match(pattern, p_todo_str)
if match:
if repl == '':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment