@@ -248,6 +248,8 @@ def smarter_request_refresh():
248
248
self .current_match = None
249
249
self .list_win_visible = False
250
250
251
+ self .original_modules = sys .modules .keys ()
252
+
251
253
self .width = None # will both be set by a window resize event
252
254
self .height = None
253
255
@@ -404,6 +406,9 @@ def process_event(self, e):
404
406
self .on_tab ()
405
407
elif e in ("KEY_BTAB" ,): # shift-tab
406
408
self .on_tab (back = True )
409
+ elif e in ("KEY_F(6)" ,):
410
+ self .clear_modules_and_reevaluate ()
411
+ self .update_completion ()
407
412
elif e in key_dispatch [self .config .undo_key ]: #ctrl-r for undo
408
413
self .undo ()
409
414
self .update_completion ()
@@ -509,6 +514,14 @@ def send_session_to_external_editor(self, filename=None):
509
514
self .current_line = lines [- 1 ][4 :]
510
515
self .cursor_offset = len (self .current_line )
511
516
517
+ def clear_modules_and_reevaluate (self ):
518
+ cursor , line = self .cursor_offset , self .current_line
519
+ for modname in sys .modules .keys ():
520
+ if modname not in self .original_modules :
521
+ del sys .modules [modname ]
522
+ self .reevaluate (insert_into_history = True )
523
+ self .cursor_offset , self .current_line = cursor , line
524
+
512
525
## Handler Helpers
513
526
def add_normal_character (self , char ):
514
527
if len (char ) > 1 or is_nop (char ):
0 commit comments