prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.53k stars 163 forks source link

Error with v2.0.1 (exception 18) #106

Open davidbrochart opened 6 years ago

davidbrochart commented 6 years ago

After installing version 2.0.1 in a clean environment, I get the following error when opening a file and pressing Shift-V:

Unhandled exception in event loop:
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/eventloop/posix.py", line 154, in _run_task
    t()
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/eventloop/context.py", line 115, in new_func
    return func(*a, **kw)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 368, in redraw
    self._redraw()
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 436, in _redraw
    self.renderer.render(self, self.layout)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/renderer.py", line 545, in render
    ), parent_style='', erase_bg=False, z_index=None)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 618, in write_to_screen
    screen, mouse_handlers, write_position, style, erase_bg, z_index)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 288, in write_to_screen
    erase_bg, z_index)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 618, in write_to_screen
    screen, mouse_handlers, write_position, style, erase_bg, z_index)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 547, in write_to_screen
    erase_bg, z_index)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 288, in write_to_screen
    erase_bg, z_index)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1392, in write_to_screen
    draw_func()
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1405, in _write_to_screen_at_index
    left_margin_widths = [self._get_margin_width(m) for m in self.left_margins]
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1405, in <listcomp>
    left_margin_widths = [self._get_margin_width(m) for m in self.left_margins]
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1265, in _get_margin_width
    return self._margin_width_cache.get(key, get_width)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/cache.py", line 37, in get
    value = getter_func()
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1262, in get_width
    return margin.get_width(get_ui_content)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/margins.py", line 130, in get_width
    return self.margin.get_width(ui_content)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/margins.py", line 71, in get_width
    line_count = get_ui_content().line_count
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1259, in get_ui_content
    return self._get_ui_content(width=0, height=0)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1366, in _get_ui_content
    return self._ui_content_cache.get(key, get_content)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/cache.py", line 37, in get
    value = getter_func()
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/containers.py", line 1363, in get_content
    return self.content.create_content(width=width, height=height)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/controls.py", line 657, in create_content
    document.cursor_position_col))
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/controls.py", line 639, in translate_rowcol
    return Point(x=get_processed_line(row).source_to_display(col), y=row)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/controls.py", line 594, in get_processed_line
    processed_line = transform(i, get_line(i))
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/controls.py", line 576, in transform
    width, height))
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/processors.py", line 801, in apply_transformation
    source_to_display, fragments, ti.width, ti.height))
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/processors.py", line 213, in apply_transformation
    to = source_to_display(to)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/processors.py", line 795, in source_to_display
    i = f(i)
  File "/home/david/.local/share/virtualenvs/pyvim-MykrNJRF/lib/python3.6/site-packages/prompt_toolkit/layout/processors.py", line 590, in source_to_display
    return position_mappings[from_position]

Exception 18
Press ENTER to continue... 
jonathanslenders commented 6 years ago

Thanks for reporting @davidbrochart, I'm working on a fix!

jonathanslenders commented 6 years ago

Hi @davidbrochart, this should be fixed in the following prompt_toolkit commit: https://github.com/jonathanslenders/python-prompt-toolkit/commit/5e04f58e70447ecfa83d6f93ec3590d3bafcaec0

If you have time, could you try to upgrade both prompt_toolkit and pyvim to the latest master commit and try again? Thanks a lot!

davidbrochart commented 6 years ago

I tried with latest prompt_toolkit and pyvim and the error is gone, thanks. However I noticed that line selection (Shift-v) doesn't highlight the text.

jonathanslenders commented 6 years ago

Right, that is another bug. Thanks for noticing!

jonathanslenders commented 6 years ago

The line selection issue should be fixed now: https://github.com/jonathanslenders/python-prompt-toolkit/commit/677190f37e064bba83474cae3e277681b3970cfe

davidbrochart commented 6 years ago

Yes it is. Thanks!