mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Formatter: Improve indent handling
This commit is contained in:
parent
fcba91def2
commit
1f999c3405
1 changed files with 4 additions and 6 deletions
|
@ -32,15 +32,13 @@ class Format:
|
|||
tokenized_str = ""
|
||||
for index, item in enumerate(tokens):
|
||||
if item.type != tokenizer.TokenType.WHITESPACE:
|
||||
tokenized_str += str(item)
|
||||
if str(item) in opening_tokens:
|
||||
indent_levels += 1
|
||||
|
||||
try:
|
||||
if str(tokens[index + 1]) in closing_tokens:
|
||||
elif str(item) in closing_tokens:
|
||||
tokenized_str = tokenized_str[:-2]
|
||||
indent_levels -= 1
|
||||
except:
|
||||
pass
|
||||
|
||||
tokenized_str += str(item)
|
||||
|
||||
if str(item) in newline_after + closing_tokens + opening_tokens:
|
||||
tokenized_str += "\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue