prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Can't type literal tab with prompt_toolkit
  In bash or zsh I would typically type `Ctl-V TAB` to insert a literal tab, however, when using prompt_tookitas my shell type this simply tries to do tab completion and there doesn't seem to be a way to create a literal tab.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `xonsh/prompt_toolkit_key_bindings.py`
  Content:
  ```
  1 """Key bindings for prompt_toolkit xonsh shell."""
  2 import builtins
  3 
  4 from prompt_toolkit.filters import Filter
  5 from prompt_toolkit.keys import Keys
  6 
  7 
  8 class TabShouldInsertIndentFilter(Filter):
  9     """
  10     Filter that is intended to check if <Tab> should insert indent instead of
  11     starting autocompletion.
  12     It basically just checks if there are only whitespaces before the cursor -
  13     if so indent should be inserted, otherwise autocompletion.
  14     """
  15     def __call__(self, cli):
  16         before_cursor = cli.current_buffer.document.current_line_before_cursor
  17 
  18         return bool(before_cursor.isspace())
  19 
  20 
  21 def load_xonsh_bindings(key_bindings_manager):
  22     """
  23     Load custom key bindings.
  24     """
  25     handle = key_bindings_manager.registry.add_binding
  26     env = builtins.__xonsh_env__
  27 
  28     @handle(Keys.Tab, filter=TabShouldInsertIndentFilter())
  29     def _(event):
  30         """
  31         If there are only whitespaces before current cursor position insert
  32         indent instead of autocompleting.
  33         """
  34         event.cli.current_buffer.insert_text(env.get('INDENT'))
  35
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/xonsh/prompt_toolkit_key_bindings.py b/xonsh/prompt_toolkit_key_bindings.py
  --- a/xonsh/prompt_toolkit_key_bindings.py
  +++ b/xonsh/prompt_toolkit_key_bindings.py
  @@ -32,3 +32,11 @@
           indent instead of autocompleting.
           """
           event.cli.current_buffer.insert_text(env.get('INDENT'))
  +
  +    @handle(Keys.BackTab)
  +    def insert_literal_tab(event):
  +        """
  +        Insert literal tab on Shift+Tab instead of autocompleting
  +        """
  +        event.cli.current_buffer.insert_text(env.get('INDENT'))
  +
  
verification_info: {"golden_diff": "diff --git a/xonsh/prompt_toolkit_key_bindings.py b/xonsh/prompt_toolkit_key_bindings.py\n--- a/xonsh/prompt_toolkit_key_bindings.py\n+++ b/xonsh/prompt_toolkit_key_bindings.py\n@@ -32,3 +32,11 @@\n         indent instead of autocompleting.\n         \"\"\"\n         event.cli.current_buffer.insert_text(env.get('INDENT'))\n+\n+    @handle(Keys.BackTab)\n+    def insert_literal_tab(event):\n+        \"\"\"\n+        Insert literal tab on Shift+Tab instead of autocompleting\n+        \"\"\"\n+        event.cli.current_buffer.insert_text(env.get('INDENT'))\n+\n", "issue": "Can't type literal tab with prompt_toolkit\nIn bash or zsh I would typically type `Ctl-V TAB` to insert a literal tab, however, when using prompt_tookitas my shell type this simply tries to do tab completion and there doesn't seem to be a way to create a literal tab.\n\n", "before_files": [{"content": "\"\"\"Key bindings for prompt_toolkit xonsh shell.\"\"\"\nimport builtins\n\nfrom prompt_toolkit.filters import Filter\nfrom prompt_toolkit.keys import Keys\n\n\nclass TabShouldInsertIndentFilter(Filter):\n    \"\"\"\n    Filter that is intended to check if <Tab> should insert indent instead of\n    starting autocompletion.\n    It basically just checks if there are only whitespaces before the cursor -\n    if so indent should be inserted, otherwise autocompletion.\n    \"\"\"\n    def __call__(self, cli):\n        before_cursor = cli.current_buffer.document.current_line_before_cursor\n\n        return bool(before_cursor.isspace())\n\n\ndef load_xonsh_bindings(key_bindings_manager):\n    \"\"\"\n    Load custom key bindings.\n    \"\"\"\n    handle = key_bindings_manager.registry.add_binding\n    env = builtins.__xonsh_env__\n\n    @handle(Keys.Tab, filter=TabShouldInsertIndentFilter())\n    def _(event):\n        \"\"\"\n        If there are only whitespaces before current cursor position insert\n        indent instead of autocompleting.\n        \"\"\"\n        event.cli.current_buffer.insert_text(env.get('INDENT'))\n", "path": "xonsh/prompt_toolkit_key_bindings.py"}], "after_files": [{"content": "\"\"\"Key bindings for prompt_toolkit xonsh shell.\"\"\"\nimport builtins\n\nfrom prompt_toolkit.filters import Filter\nfrom prompt_toolkit.keys import Keys\n\n\nclass TabShouldInsertIndentFilter(Filter):\n    \"\"\"\n    Filter that is intended to check if <Tab> should insert indent instead of\n    starting autocompletion.\n    It basically just checks if there are only whitespaces before the cursor -\n    if so indent should be inserted, otherwise autocompletion.\n    \"\"\"\n    def __call__(self, cli):\n        before_cursor = cli.current_buffer.document.current_line_before_cursor\n\n        return bool(before_cursor.isspace())\n\n\ndef load_xonsh_bindings(key_bindings_manager):\n    \"\"\"\n    Load custom key bindings.\n    \"\"\"\n    handle = key_bindings_manager.registry.add_binding\n    env = builtins.__xonsh_env__\n\n    @handle(Keys.Tab, filter=TabShouldInsertIndentFilter())\n    def _(event):\n        \"\"\"\n        If there are only whitespaces before current cursor position insert\n        indent instead of autocompleting.\n        \"\"\"\n        event.cli.current_buffer.insert_text(env.get('INDENT'))\n\n    @handle(Keys.BackTab)\n    def insert_literal_tab(event):\n        \"\"\"\n        Insert literal tab on Shift+Tab instead of autocompleting\n        \"\"\"\n        event.cli.current_buffer.insert_text(env.get('INDENT'))\n\n", "path": "xonsh/prompt_toolkit_key_bindings.py"}]}