mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
cleaner if and avoid exception
This commit is contained in:
parent
89bb5c4e39
commit
e0866df6bb
1 changed files with 11 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
|||
"""Completer implementation to use with prompt_toolkit."""
|
||||
import os
|
||||
import builtins
|
||||
import prompt_toolkit
|
||||
import xonsh
|
||||
|
||||
from prompt_toolkit.layout.dimension import LayoutDimension
|
||||
from prompt_toolkit.completion import Completer, Completion
|
||||
|
@ -42,6 +42,10 @@ class PromptToolkitCompleter(Completer):
|
|||
|
||||
def reserve_space(self):
|
||||
cli = builtins.__xonsh_shell__.shell.prompter.cli
|
||||
if xonsh.shell.prompt_toolkit_version().startswith("1.0"):
|
||||
# This is the layout for ptk 1.0
|
||||
window = cli.application.layout.children[0].content.children[1]
|
||||
else:
|
||||
#TODO remove after next prompt_toolkit release
|
||||
try:
|
||||
#old layout to be removed at next ptk release
|
||||
|
@ -50,10 +54,6 @@ class PromptToolkitCompleter(Completer):
|
|||
#new layout to become default
|
||||
window = cli.application.layout.children[1].content
|
||||
|
||||
# This is the layout for ptk 1.0
|
||||
if prompt_toolkit.__version__.startswith("1."):
|
||||
window = cli.application.layout.children[0].content.children[1]
|
||||
|
||||
if window and window.render_info:
|
||||
h = window.render_info.content_height
|
||||
r = builtins.__xonsh_env__.get('COMPLETIONS_MENU_ROWS')
|
||||
|
|
Loading…
Add table
Reference in a new issue