Skip to content

AssertionError cursor_position is None #1119

Open
@jaraco

Description

@jaraco

I use xonsh as my shell with prompt-toolkit 3.0.4. Occasionally, I'll be typing in the prompt and get this traceback:

Unhandled exception in event loop:
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/eventloop/utils.py", line 72, in schedule
    func()
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 456, in redraw
    self._redraw()
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
    self.context.run(run_in_context)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
    self.renderer.render(self, self.layout)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 568, in render
    layout.container.preferred_height(size.columns, size.rows).preferred,
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 324, in preferred_height
    dimensions = [
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 325, in <listcomp>
    c.preferred_height(width, max_available_height) for c in self._all_children
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 792, in preferred_height
    return self.content.preferred_height(width, max_available_height)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 324, in preferred_height
    dimensions = [
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 325, in <listcomp>
    c.preferred_height(width, max_available_height) for c in self._all_children
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 2595, in preferred_height
    return self.content.preferred_height(width, max_available_height)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 1620, in preferred_height
    return self._merge_dimensions(
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 1648, in _merge_dimensions
    preferred = get_preferred()
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/containers.py", line 1613, in preferred_content_height
    return self.content.preferred_height(
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/controls.py", line 639, in preferred_height
    content = self.create_content(width, height=1)  # Pass a dummy '1' as height.
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/layout/controls.py", line 761, in create_content
    document = buffer.document
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/buffer.py", line 524, in document
    return self._document_cache[
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/cache.py", line 98, in __missing__
    result = self.get_value(*key)
  File "/Users/jaraco/.local/pipx/venvs/xonsh/lib/python3.8/site-packages/prompt_toolkit/document.py", line 98, in __init__
    assert cursor_position is None or cursor_position <= len(text), AssertionError(

Exception cursor_position=9, len_text=4
Press ENTER to continue...                                                                                                                                                
~ $ cd ~/p/che

Sometimes, I hit enter and the error repeats. Other times, I hit Enter and can continue.

I've just updated to prompt_toolkit==3.0.5. I'll report back here if the issue repeats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions