diff options
author | Irina Truong <i.chernyavska@gmail.com> | 2018-07-13 13:24:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 13:24:44 -0700 |
commit | 5491d288fc7ea3a512a69c1da0b27d0d77c107e4 (patch) | |
tree | 1d76e07e0f39c5a50eb5114fca8ba800ce52c8c2 | |
parent | 25fc388426f94ad9941b79d7ac1bd9fbd638d962 (diff) | |
parent | 44d4275eaec8ea58f04115bbbd620d69cc3119c9 (diff) |
Merge pull request #903 from arturbalabanov/render-tabs-with-spaces
Fixes #346: Tab characters are rendered with spaces instead of "^I" when entered in external editor
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog.rst | 2 | ||||
-rw-r--r-- | pgcli/main.py | 15 |
3 files changed, 13 insertions, 5 deletions
@@ -82,6 +82,7 @@ Contributors: * Matthieu Guilbert * Alexandr Korsak * Saif Hakim + * Artur Balabanov Creator: diff --git a/changelog.rst b/changelog.rst index 5dd8512a..412faebc 100644 --- a/changelog.rst +++ b/changelog.rst @@ -25,6 +25,7 @@ Bug Fixes: * Fix ipython magic connection (#891). (Thanks: `Irina Truong`_) * Fix not enough values to unpack. (Thanks: `Matthieu Guilbert`_) * Fix unbound local error when destructive_warning is false. (Thanks: `Matthieu Guilbert`_) +* Render tab characters as 4 spaces instead of `^I`. (Thanks: `Artur Balabanov`_) 1.9.1: ====== @@ -838,3 +839,4 @@ Improvements: .. _`Matthieu Guilbert`: https://github.com/gma2th .. _`Alexandr Korsak`: https://github.com/oivoodoo .. _`Saif Hakim`: https://github.com/saifelse +.. _`Artur Balabanov`: https://github.com/arturbalabanov diff --git a/pgcli/main.py b/pgcli/main.py index e5bc39e4..25c2f5d7 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -35,7 +35,8 @@ from prompt_toolkit.document import Document from prompt_toolkit.filters import Always, HasFocus, IsDone from prompt_toolkit.layout.lexers import PygmentsLexer from prompt_toolkit.layout.processors import (ConditionalProcessor, - HighlightMatchingBracketProcessor) + HighlightMatchingBracketProcessor, + TabsProcessor) from prompt_toolkit.history import FileHistory from prompt_toolkit.auto_suggest import AutoSuggestFromHistory from pygments.lexers.sql import PostgresLexer @@ -682,10 +683,14 @@ class PGCli(object): display_completions_in_columns=self.wider_completion_menu, multiline=True, extra_input_processors=[ - # Highlight matching brackets while editing. - ConditionalProcessor( - processor=HighlightMatchingBracketProcessor(chars='[](){}'), - filter=HasFocus(DEFAULT_BUFFER) & ~IsDone()), + # Highlight matching brackets while editing. + ConditionalProcessor( + processor=HighlightMatchingBracketProcessor( + chars='[](){}'), + filter=HasFocus(DEFAULT_BUFFER) & ~IsDone()), + # Render \t as 4 spaces instead of "^I" + TabsProcessor(get_char1=lambda _: ' ', + get_char2=lambda _: ' '), ]) with self._completer_lock: |