diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-10 13:52:10 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-10 13:52:10 +0200 |
| commit | 54cd5c95d9af7037e1b96a726506ceb5df4f43a5 (patch) | |
| tree | 9052ea14cdc262b7e1866578a95fe58f9752e554 /sqlparse | |
| parent | 0269aced73a295dea0a57c49dd77ff73031fcdd0 (diff) | |
| download | sqlparse-54cd5c95d9af7037e1b96a726506ceb5df4f43a5.tar.gz | |
Add tabs correctly on identifiers offset
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 3bd492b..401c436 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -475,9 +475,21 @@ class ReindentFilter: ignore = False for token in identifiers: if not ignore and not token.ttype: - ws = self._gentabs(offset) - tlist.insert_before(token, sql.Token(T.Whitespace, - ws)) + prev = tlist.token_prev(token, False) + if prev and prev.ttype == T.Whitespace: + value = prev.value + + spaces = 0 + while value and value[-1] == ' ': + value = value[:-1] + spaces += 1 + + value += self._gentabs(spaces + offset) + prev.value = value + else: + ws = sql.Token(T.Whitespace, + self._gentabs(offset)) + tlist.insert_before(token, ws) ignore = token.ttype # Decrease offset the size of the first token |
