diff --git a/bpython/curtsiesfrontend/manual_readline.py b/bpython/curtsiesfrontend/manual_readline.py index 24a1b9a27..a919df14d 100644 --- a/bpython/curtsiesfrontend/manual_readline.py +++ b/bpython/curtsiesfrontend/manual_readline.py @@ -280,8 +280,10 @@ def yank_prev_killed_text(cursor_offset, line, cut_buffer): @edit_keys.on(config='transpose_chars_key') def transpose_character_before_cursor(cursor_offset, line): - if cursor_offset == 0: + if cursor_offset < 2: return cursor_offset, line + if cursor_offset == len(line): + return cursor_offset, line[:-2] + line[-1] + line[-2] return (min(len(line), cursor_offset + 1), line[:cursor_offset - 1] + (line[cursor_offset] if len(line) > cursor_offset else '') + diff --git a/bpython/test/test_manual_readline.py b/bpython/test/test_manual_readline.py index f1e24b780..3c25e3bb5 100644 --- a/bpython/test/test_manual_readline.py +++ b/bpython/test/test_manual_readline.py @@ -207,9 +207,15 @@ def test_transpose_empty_line(self): def test_transpose_first_character(self): self.assertEquals(transpose_character_before_cursor(0, 'a'), - transpose_character_before_cursor(0, 'a')) + (0, 'a')) self.assertEquals(transpose_character_before_cursor(0, 'as'), - transpose_character_before_cursor(0, 'as')) + (0, 'as')) + + def test_transpose_end_of_line(self): + self.assertEquals(transpose_character_before_cursor(1, 'a'), + (1, 'a')) + self.assertEquals(transpose_character_before_cursor(2, 'as'), + (2, 'sa')) def test_transpose_word_before_cursor(self): pass pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy