diff options
author | Georgy Frolov <gosha@fro.lv> | 2021-02-23 01:54:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 14:54:23 -0800 |
commit | 30212c6fc68ccf19d794530819cda8e6d4edf74c (patch) | |
tree | 441675bc043e4cc2bb901fde07a6ad36811b6452 | |
parent | 9ca545d8803a57f25330a157b7b3f4f21ec7ad84 (diff) |
fixed unknown symbol REPLACE_SINGLE in prompt_toolkit < 3.0.6 (#1246)
* fixed unknown symbol REPLACE_SINGLE in prompt_toolkit < 3.0.6
* changelog
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/pgtoolbar.py | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/changelog.rst b/changelog.rst index 6ae26ca5..18640252 100644 --- a/changelog.rst +++ b/changelog.rst @@ -11,6 +11,7 @@ Bug fixes: ---------- * Fix issue where `syntax_style` config value would not have any effect. (#1212) +* Fix crash because of not found `InputMode.REPLACE_SINGLE` with prompt-toolkit < 3.0.6 3.1.0 ===== diff --git a/pgcli/pgtoolbar.py b/pgcli/pgtoolbar.py index f4289a1a..441a733d 100644 --- a/pgcli/pgtoolbar.py +++ b/pgcli/pgtoolbar.py @@ -1,15 +1,20 @@ +from packaging.version import parse as parse_version + +import prompt_toolkit from prompt_toolkit.key_binding.vi_state import InputMode from prompt_toolkit.application import get_app def _get_vi_mode(): - return { + modes = { InputMode.INSERT: "I", InputMode.NAVIGATION: "N", InputMode.REPLACE: "R", - InputMode.REPLACE_SINGLE: "R", InputMode.INSERT_MULTIPLE: "M", - }[get_app().vi_state.input_mode] + } + if parse_version(prompt_toolkit.__version__) >= parse_version("3.0.6"): + modes[InputMode.REPLACE_SINGLE] = "R" + return modes[get_app().vi_state.input_mode] def create_toolbar_tokens_func(pgcli): |