diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2018-05-29 21:19:38 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2018-05-29 21:21:57 +0200 |
commit | 30c52893ea5033516d5b6bc4f4e4faa6d75080e5 (patch) | |
tree | 828dd075022a5daa4996a9568a8f37d6d5b821cc | |
parent | 2da4c401cdc36a596e96f97296e350d5decac74c (diff) |
Bugfix: correctly handle cursor position when clicking on DummyControl.
(Clicking on a DummyControl made the application crash.)
-rw-r--r-- | prompt_toolkit/layout/containers.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/prompt_toolkit/layout/containers.py b/prompt_toolkit/layout/containers.py index 55dc1686..d207b8b5 100644 --- a/prompt_toolkit/layout/containers.py +++ b/prompt_toolkit/layout/containers.py @@ -927,8 +927,14 @@ class WindowRenderInfo(object): of the rendered screen. """ cpos = self.ui_content.cursor_position - y, x = self._rowcol_to_yx[cpos.y, cpos.x] - return Point(x=x - self._x_offset, y=y - self._y_offset) + try: + y, x = self._rowcol_to_yx[cpos.y, cpos.x] + except KeyError: + # For `DummyControl` for instance, the content can be empty, and so + # will `_rowcol_to_yx` be. Return 0/0 by default. + return Point(x=0, y=0) + else: + return Point(x=x - self._x_offset, y=y - self._y_offset) @property def applied_scroll_offsets(self): |