##// END OF EJS Templates
fix semicolon detection with no history
Idan Pazi -
Show More
@@ -51,7 +51,7 b' class DisplayHook(Configurable):'
51
51
52 # we need a reference to the user-level namespace
52 # we need a reference to the user-level namespace
53 self.shell = shell
53 self.shell = shell
54
54
55 self._,self.__,self.___ = '','',''
55 self._,self.__,self.___ = '','',''
56
56
57 # these are deliberately global:
57 # these are deliberately global:
@@ -83,15 +83,9 b' class DisplayHook(Configurable):'
83
83
84 def quiet(self):
84 def quiet(self):
85 """Should we silence the display hook because of ';'?"""
85 """Should we silence the display hook because of ';'?"""
86 # do not print output if input ends in ';'
86 if self.exec_result is not None:
87
87 return self.semicolon_at_end_of_expression(self.exec_result.info.raw_cell)
88 try:
88 return False
89 cell = self.shell.history_manager.input_hist_parsed[-1]
90 except IndexError:
91 # some uses of ipshellembed may fail here
92 return False
93
94 return self.semicolon_at_end_of_expression(cell)
95
89
96 @staticmethod
90 @staticmethod
97 def semicolon_at_end_of_expression(expression):
91 def semicolon_at_end_of_expression(expression):
@@ -280,13 +274,12 b' class DisplayHook(Configurable):'
280 cull_count = max(int(sz * self.cull_fraction), 2)
274 cull_count = max(int(sz * self.cull_fraction), 2)
281 warn('Output cache limit (currently {sz} entries) hit.\n'
275 warn('Output cache limit (currently {sz} entries) hit.\n'
282 'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count))
276 'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count))
283
277
284 for i, n in enumerate(sorted(oh)):
278 for i, n in enumerate(sorted(oh)):
285 if i >= cull_count:
279 if i >= cull_count:
286 break
280 break
287 self.shell.user_ns.pop('_%i' % n, None)
281 self.shell.user_ns.pop('_%i' % n, None)
288 oh.pop(n, None)
282 oh.pop(n, None)
289
290
283
291 def flush(self):
284 def flush(self):
292 if not self.do_full_cache:
285 if not self.do_full_cache:
General Comments 0
You need to be logged in to leave comments. Login now