diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2009-05-03 21:56:03 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2009-05-03 21:56:03 +0200 |
| commit | 235864a1fcc5d871d584dcd8eeeeaded4f6572c9 (patch) | |
| tree | 33edf119e17ca166981af2811f967e15c10a44fe /sqlparse | |
| parent | 5ee6aed6aef8f8ffeeef67e3909bf8a72e9213b8 (diff) | |
| download | sqlparse-235864a1fcc5d871d584dcd8eeeeaded4f6572c9.tar.gz | |
Avoid duplicate linebreaks when reformatting (targets issue3).
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 695b298..91258ff 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -171,8 +171,12 @@ class ReindentFilter(Filter): if prev and prev.is_whitespace(): tlist.tokens.pop(tlist.token_index(prev)) offset += 1 - nl = self.nl() - tlist.insert_before(token, nl) + if prev and (str(prev).endswith('\n') + or str(prev).endswith('\r')): + nl = tlist.token_next(token) + else: + nl = self.nl() + tlist.insert_before(token, nl) token = tlist.token_next_match(tlist.token_index(nl)+offset, T.Keyword, split_words, regex=True) |
