Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4603a22
basic parentheses and quote closing on key events
samuelgregorovic Oct 6, 2021
594a468
basic pair deletion for common pairs
samuelgregorovic Oct 6, 2021
691def4
jump behind closing paren/quote on TAB
samuelgregorovic Oct 6, 2021
ee98f16
jump on tab even with content in parens
samuelgregorovic Oct 30, 2021
a59daed
move cursor on closing paren ovrwrite
samuelgregorovic Oct 30, 2021
9206403
removed quotes completion + fixed bad cursor bug
samuelgregorovic Oct 30, 2021
82a32e6
nested tabbing/ovewriting brackets working
samuelgregorovic Oct 30, 2021
e00f87b
fixed backspace event when cursor on closing paren
samuelgregorovic Oct 30, 2021
a902deb
added quote completion + autocomplete compatibility
samuelgregorovic Oct 30, 2021
c11b5fc
added cmd argument + update manpage help
samuelgregorovic Oct 30, 2021
a55830c
added config option + updated sample config
samuelgregorovic Oct 30, 2021
49c98df
obey config option + docstrings
samuelgregorovic Oct 30, 2021
aa321b1
update and document on_tab method
samuelgregorovic Oct 30, 2021
05dc36d
added comment
samuelgregorovic Oct 30, 2021
dc9d176
removed cmd argument
samuelgregorovic Oct 30, 2021
a34140a
removed unnecessary __class__ call + fix bad function call
samuelgregorovic Nov 2, 2021
5d302a5
removed unnecessary manpage entry
samuelgregorovic Nov 2, 2021
192663c
moved CHARACTER_PAIR_MAP to __init__ + 0 index fix
samuelgregorovic Nov 2, 2021
66c317b
moved cursor_on_closing_char_pair to line.py
samuelgregorovic Nov 2, 2021
a23843b
moved CHARACTER_PAIR_MAP to line.py
samuelgregorovic Nov 2, 2021
41750bf
fix overwriting quotes
samuelgregorovic Nov 2, 2021
6138b7a
fix autoclose quotes bug
samuelgregorovic Nov 2, 2021
8be9bbb
autocomplete enabled only before closing params or space
samuelgregorovic Nov 2, 2021
73782de
fix matching history entries
samuelgregorovic Nov 2, 2021
f3f03e2
basic tests without history
samuelgregorovic Nov 3, 2021
81bc622
added quote test
samuelgregorovic Nov 3, 2021
f33cf55
renamed add_to_search to narrow_search
samuelgregorovic Nov 3, 2021
66d34cf
changed default config value to False
samuelgregorovic Nov 3, 2021
d14207d
fixed test DRY problem with helper method
samuelgregorovic Nov 3, 2021
100735d
fixed insert_char_pair_start docstring
samuelgregorovic Nov 3, 2021
2c683fc
fix bad behavior of reverse-incremental search
samuelgregorovic Nov 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed backspace event when cursor on closing paren
  • Loading branch information
samuelgregorovic committed Oct 30, 2021
commit e00f87b6e34070907d5355860337e0565293cea2
15 changes: 11 additions & 4 deletions bpython/curtsiesfrontend/manual_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,18 @@ def delete(cursor_offset, line):

def cursor_on_closing_char_pair(cursor_offset, line):
closing_char_map = {"(": ")", "{": "}", "[": "]"}
on_closing_char, pair_close = False, False
if line is None:
return False
return on_closing_char, pair_close
if cursor_offset < len(line):
cur_char = line[cursor_offset]
prev_char = line[cursor_offset - 1]
Comment thread
samuelgregorovic marked this conversation as resolved.
Resolved
if cur_char in closing_char_map.values():
return True
return False
on_closing_char = True
if prev_char in closing_char_map:
if closing_char_map[prev_char] == cur_char:
pair_close = True
return on_closing_char, pair_close


@edit_keys.on("<BACKSPACE>")
Expand All @@ -256,7 +260,10 @@ def backspace(cursor_offset, line):
cursor_offset - to_delete,
line[: cursor_offset - to_delete] + line[cursor_offset:],
)
if cursor_on_closing_char_pair(cursor_offset, line):
on_closing_char, pair_close = cursor_on_closing_char_pair(
cursor_offset, line
)
if on_closing_char and pair_close:
return (
cursor_offset - 1,
line[: cursor_offset - 1] + line[cursor_offset + 1 :],
Expand Down
5 changes: 4 additions & 1 deletion bpython/curtsiesfrontend/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,10 @@ def only_whitespace_left_of_cursor():
self._cursor_offset, self._current_line = cursor_and_line
# using _current_line so we don't trigger a completion reset
self.list_win_visible = True
if cursor_on_closing_char_pair(self._cursor_offset, self._current_line):
on_closing_char, _ = cursor_on_closing_char_pair(
self._cursor_offset, self._current_line
)
if on_closing_char:
self._cursor_offset += 1

def on_control_d(self):
Expand Down