Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6816617

Browse files
committed
less greedy history fetching.
set dirty bit on execute, and refetch all data only if dirty bit is set on 'cursor up'
1 parent 895a607 commit 6816617

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,5 @@ TODO / KNOWN ISSUES:
303303

304304
[ ] run completion for "import <tab>" since ipython supports that.
305305

306+
[ ] implement `get_bipython()` command to inspect bipython as I work on it
307+

bipython/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ def save(self, *args, **kw):
677677
class URWIDRepl(repl.Repl):
678678

679679
_time_between_redraws = .05 # seconds
680+
rl_history_reset = False
680681

681682
def __init__(self, event_loop, palette, interpreter, config):
682683
repl.Repl.__init__(self, interpreter, config)
@@ -1655,7 +1656,7 @@ def handle_input(self, event):
16551656
self.prompt(more)
16561657
# XXX: fetching all history is expensive, but better than nothing
16571658
# for now
1658-
self.rl_history = IPythonHistory(self)
1659+
self.rl_history_reset = True
16591660
elif event == 'ctrl d':
16601661
# ctrl+d on an empty line exits, otherwise deletes
16611662
if self.edit is not None:
@@ -1665,6 +1666,9 @@ def handle_input(self, event):
16651666
self.main_loop.process_input(['delete'])
16661667
elif urwid.command_map[event] == 'cursor up':
16671668
# "back" from bpython.cli
1669+
if self.rl_history_reset:
1670+
self.rl_history = IPythonHistory(self)
1671+
self.rl_history_reset = False
16681672
self.rl_history.enter(self.edit.get_edit_text())
16691673
self.edit.set_edit_text('')
16701674
self.edit.insert_text(self.rl_history.back()) # + "#previous")

0 commit comments

Comments
 (0)