##// END OF EJS Templates
Small fix and cleanup for exit/quit command filtering.
Fernando Perez -
Show More
@@ -56,6 +56,11 b' class HistoryManager(object):'
56 56 # history update, we populate the user's namespace with these, shifted as
57 57 # necessary.
58 58 _i00, _i, _ii, _iii = '','','',''
59
60 # A set with all forms of the exit command, so that we don't store them in
61 # the history (it's annoying to rewind the first entry and land on an exit
62 # call).
63 _exit_commands = None
59 64
60 65 def __init__(self, shell):
61 66 """Create a new history manager associated with a shell instance.
@@ -91,11 +96,14 b' class HistoryManager(object):'
91 96
92 97 self._i00, self._i, self._ii, self._iii = '','','',''
93 98
99 self._exit_commands = set(['Quit', 'quit', 'Exit', 'exit', '%Quit',
100 '%quit', '%Exit', '%exit'])
101
94 102 # Object is fully initialized, we can now call methods on it.
95 103
96 104 # Fill the history zero entry, user counter starts at 1
97 105 self.store_inputs('\n', '\n')
98
106
99 107 def _init_shadow_hist(self):
100 108 try:
101 109 self.shadow_db = PickleShareDB(os.path.join(
@@ -207,9 +215,11 b' class HistoryManager(object):'
207 215 """
208 216 if source_raw is None:
209 217 source_raw = source
210 # do not store quit/exit commands
211 if source_raw in ['Quit', 'quit', 'Exit', 'exit', '%Quit', '%quit', '%Exit', '%exit']:
218
219 # do not store exit/quit commands
220 if source_raw.strip() in self._exit_commands:
212 221 return
222
213 223 self.input_hist_parsed.append(source.rstrip())
214 224 self.input_hist_raw.append(source_raw.rstrip())
215 225 self.shadow_hist.add(source)
General Comments 0
You need to be logged in to leave comments. Login now