X Tutup
Skip to content

Commit 7b19699

Browse files
add config option for single_undo_time
1 parent babd41f commit 7b19699

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

bpython/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def loadini(struct, configfile):
5353
'hist_length': 100,
5454
'hist_duplicates': True,
5555
'paste_time': 0.02,
56+
'single_undo_time': 1.0,
5657
'syntax': True,
5758
'tab_length': 4,
5859
'pastebin_confirm': True,
@@ -141,6 +142,7 @@ def get_key_no_doublebind(command):
141142
struct.syntax = config.getboolean('general', 'syntax')
142143
struct.arg_spec = config.getboolean('general', 'arg_spec')
143144
struct.paste_time = config.getfloat('general', 'paste_time')
145+
struct.single_undo_time = config.getfloat('general', 'single_undo_time')
144146
struct.highlight_show_source = config.getboolean('general',
145147
'highlight_show_source')
146148
struct.hist_file = config.get('general', 'hist_file')

bpython/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ def insert_into_history(self, s):
825825

826826
def prompt_undo(self):
827827
"""Returns how many lines to undo, 0 means don't undo"""
828-
self.config.single_undo_time = 1
829-
if self.interp.timer.estimate() < self.config.single_undo_time:
828+
if (self.config.single_undo_time < 0 or
829+
self.interp.timer.estimate() < self.config.single_undo_time):
830830
return 1
831831
est = self.interp.timer.estimate()
832832
n = self.interact.file_prompt(

bpython/sample-config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
# bpython’s behalf. If unset, bpython uploads pastes to bpaste.net. (default: )
4949
#pastebin_helper = gist.py
5050

51+
# How long an undo must be expected to take before prompting for how
52+
# many lines should be undone. Set to -1 to never prompt, or 0 to
53+
# always prompt.
54+
# single_undo_time = 1.0
55+
5156
[keyboard]
5257

5358
# All key bindings are shown commented out with their default binding

doc/sphinx/source/configuration-options.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ following helper program can be used to create `gists
120120
121121
.. versionadded:: 0.12
122122

123+
124+
single_undo_time
125+
^^^^^^^^^^^^^^^^
126+
Time duration an undo must be predicted to take before prompting
127+
to undo multiple lines at once. Use -1 to never prompt, or 0 to always prompt.
128+
(default: 1.0)
129+
130+
.. versionadded:: 0.14
131+
123132
.. _configuration_color_scheme:
124133

125134
color_scheme

0 commit comments

Comments
 (0)
X Tutup