diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2014-11-30 07:32:47 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2014-11-30 07:32:47 +0100 |
| commit | bb3290c6f62a3020b49f4baf1049d1e2c55386df (patch) | |
| tree | d17156445916c5cd2e4df95e6a3812d512f08322 /sqlparse | |
| parent | 223606e484c9bc02db46f83b8cdf288e2a7cafe6 (diff) | |
| download | sqlparse-bb3290c6f62a3020b49f4baf1049d1e2c55386df.tar.gz | |
Fix indentation when using tabs (fixes #146).
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index bf65a4a..4a0b2c7 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -379,7 +379,12 @@ class ReindentFilter: identifiers = list(tlist.get_identifiers()) if len(identifiers) > 1 and not tlist.within(sql.Function): first = list(identifiers[0].flatten())[0] - num_offset = self._get_offset(first) - len(first.value) + if self.char == '\t': + # when using tabs we don't count the actual word length + # in spaces. + num_offset = 1 + else: + num_offset = self._get_offset(first) - len(first.value) self.offset += num_offset for token in identifiers[1:]: tlist.insert_before(token, self.nl()) |
