Skip to content

Commit b27827f

Browse files
committed
Better handle_backspace
1 parent 06977b5 commit b27827f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bogo/core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,15 @@ def handle_backspace(converted_string, raw_sequence):
507507
deleted_char = converted_string[-1]
508508
converted_string = converted_string[:-1]
509509

510-
index = raw_sequence.rfind(deleted_char)
511-
raw_sequence = raw_sequence[:-2] if index < 0 else \
512-
raw_sequence[:index] + \
513-
raw_sequence[(index + 1):]
510+
_accent = accent.get_accent_char(deleted_char)
511+
_mark = mark.get_mark_char(deleted_char)
512+
513+
if _mark and _accent:
514+
raw_sequence = raw_sequence[:-3]
515+
elif _mark or _accent:
516+
raw_sequence = raw_sequence[:-2]
517+
else:
518+
index = raw_sequence.rfind(deleted_char)
519+
raw_sequence = raw_sequence[:index] + raw_sequence[(index + 1):]
514520

515521
return converted_string, raw_sequence

0 commit comments

Comments
 (0)