prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.11k stars 717 forks source link

Problem with mouse scroll event #449

Open qweeze opened 7 years ago

qweeze commented 7 years ago

Hi

File "err.py", line 91, in <module>
    document = cli.run()
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 394, in run
    self.eventloop.run(self.input, self.create_eventloop_callbacks())
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/eventloop/posix.py", line 164, in run
    t()
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/eventloop/posix.py", line 83, in read_from_stdin
    inputstream.feed(data)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/terminal/vt100_input.py", line 395, in feed
    self._input_parser.send(c)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/terminal/vt100_input.py", line 304, in _input_parser_generator
    self._call_handler(match, prefix)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/terminal/vt100_input.py", line 337, in _call_handler
    self.feed_key_callback(KeyPress(key, insert_text))
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 1023, in feed_key
    cli.input_processor.process_keys()
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/key_binding/input_processor.py", line 201, in process_keys
    self._process_coroutine.send(key_press)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/key_binding/input_processor.py", line 158, in _process
    self._call_handler(matches[-1], key_sequence=buffer)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/key_binding/input_processor.py", line 228, in _call_handler
    handler.call(event)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/key_binding/registry.py", line 31, in call
    return self.handler(event)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/key_binding/bindings/basic.py", line 309, in _
    event_type=mouse_event))
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 1142, in mouse_handler
    return self._mouse_handler(cli, mouse_event)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 1593, in _mouse_handler
    self._scroll_up(cli)
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 1611, in _scroll_up
    if info.cursor_position.y >= info.window_height - 1 - info.configured_scroll_offsets.bottom:
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 663, in cursor_position
    y, x = self._rowcol_to_yx[cpos.y, cpos.x]
KeyError: (25, 31)

Here's minimal code to reproduce http://pastebin.com/d2VVmrms. It crashes after entering enought text not to fit in window size and then scrolling the window up. There's also a problem with pasting text with Ctrl-Shift-V (like a random google page) - sometimes the scroll breaks and cursor position changes unpredictably/ Is it a bug or am I doing something wrong?

jonathanslenders commented 7 years ago

Thanks very much for reporting. This sounds definitely like a bug.