##// END OF EJS Templates
Require blank line to end input cell immediately after dedenting....
Thomas Kluyver -
Show More
@@ -428,17 +428,21 b' class InputSplitter(object):'
428 428 return True
429 429
430 430 # If we already have complete input and we're flush left, the answer
431 # depends. In line mode, we're done. But in cell mode, we need to
432 # check how many blocks the input so far compiles into, because if
433 # there's already more than one full independent block of input, then
434 # the client has entered full 'cell' mode and is feeding lines that
435 # each is complete. In this case we should then keep accepting.
436 # The Qt terminal-like console does precisely this, to provide the
437 # convenience of terminal-like input of single expressions, but
438 # allowing the user (with a separate keystroke) to switch to 'cell'
439 # mode and type multiple expressions in one shot.
431 # depends. In line mode, if there hasn't been any indentation,
432 # that's it. If we've come back from some indentation, we need
433 # the blank final line to finish.
434 # In cell mode, we need to check how many blocks the input so far
435 # compiles into, because if there's already more than one full
436 # independent block of input, then the client has entered full
437 # 'cell' mode and is feeding lines that each is complete. In this
438 # case we should then keep accepting. The Qt terminal-like console
439 # does precisely this, to provide the convenience of terminal-like
440 # input of single expressions, but allowing the user (with a
441 # separate keystroke) to switch to 'cell' mode and type multiple
442 # expressions in one shot.
440 443 if self.indent_spaces==0:
441 444 if self.input_mode=='line':
445 if not self._full_dedent:
442 446 return False
443 447 else:
444 448 nblocks = len(split_blocks(''.join(self._buffer)))
@@ -260,6 +260,17 b' class InputSplitterTestCase(unittest.TestCase):'
260 260 isp.push('')
261 261 self.assertFalse(isp.push_accepts_more())
262 262
263 def test_push_accepts_more5(self):
264 # In cell mode, inputs must be fed in whole blocks, so skip this test
265 if self.isp.input_mode == 'cell': return
266
267 isp = self.isp
268 isp.push('try:')
269 isp.push(' a = 5')
270 isp.push('except:')
271 isp.push(' raise')
272 self.assertTrue(isp.push_accepts_more())
273
263 274 def test_continuation(self):
264 275 isp = self.isp
265 276 isp.push("import os, \\")
General Comments 0
You need to be logged in to leave comments. Login now