##// END OF EJS Templates
Small fix and cleanup for exit/quit command filtering.
Fernando Perez -
Show More
@@ -57,6 +57,11 b' class HistoryManager(object):'
57 # necessary.
57 # necessary.
58 _i00, _i, _ii, _iii = '','','',''
58 _i00, _i, _ii, _iii = '','','',''
59
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
64
60 def __init__(self, shell):
65 def __init__(self, shell):
61 """Create a new history manager associated with a shell instance.
66 """Create a new history manager associated with a shell instance.
62 """
67 """
@@ -91,6 +96,9 b' class HistoryManager(object):'
91
96
92 self._i00, self._i, self._ii, self._iii = '','','',''
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 # Object is fully initialized, we can now call methods on it.
102 # Object is fully initialized, we can now call methods on it.
95
103
96 # Fill the history zero entry, user counter starts at 1
104 # Fill the history zero entry, user counter starts at 1
@@ -207,9 +215,11 b' class HistoryManager(object):'
207 """
215 """
208 if source_raw is None:
216 if source_raw is None:
209 source_raw = source
217 source_raw = source
210 # do not store quit/exit commands
218
211 if source_raw in ['Quit', 'quit', 'Exit', 'exit', '%Quit', '%quit', '%Exit', '%exit']:
219 # do not store exit/quit commands
220 if source_raw.strip() in self._exit_commands:
212 return
221 return
222
213 self.input_hist_parsed.append(source.rstrip())
223 self.input_hist_parsed.append(source.rstrip())
214 self.input_hist_raw.append(source_raw.rstrip())
224 self.input_hist_raw.append(source_raw.rstrip())
215 self.shadow_hist.add(source)
225 self.shadow_hist.add(source)
General Comments 0
You need to be logged in to leave comments. Login now