diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2018-06-03 22:27:41 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2018-06-03 22:27:43 +0200 |
commit | 677190f37e064bba83474cae3e277681b3970cfe (patch) | |
tree | bb36c942e5700d57ca987e038ecde3d6acd7b182 | |
parent | 5e04f58e70447ecfa83d6f93ec3590d3bafcaec0 (diff) |
Bugfix in TabsProcessor: handle situations when the cursor is at the end of the line.
This fixes a bug in the selection, when TabsProcessor is used. (For
pyvim, for instance.)
-rw-r--r-- | prompt_toolkit/layout/processors.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/prompt_toolkit/layout/processors.py b/prompt_toolkit/layout/processors.py index ccc7b1ec..f5e5ab26 100644 --- a/prompt_toolkit/layout/processors.py +++ b/prompt_toolkit/layout/processors.py @@ -589,13 +589,13 @@ class TabsProcessor(Processor): pos += 1 position_mappings[len(fragments)] = pos + # Add `pos+1` to mapping, because the cursor can be right after the + # line as well. + position_mappings[len(fragments) + 1] = pos + 1 def source_to_display(from_position): " Maps original cursor position to the new one. " - try: - return position_mappings[from_position] - except KeyError: - return 0 + return position_mappings[from_position] def display_to_source(display_pos): " Maps display cursor position to the original one. " |