Show More
@@ -428,18 +428,22 b' class InputSplitter(object):' | |||||
428 | return True |
|
428 | return True | |
429 |
|
429 | |||
430 | # If we already have complete input and we're flush left, the answer |
|
430 | # If we already have complete input and we're flush left, the answer | |
431 |
# depends. In line mode, |
|
431 | # depends. In line mode, if there hasn't been any indentation, | |
432 | # check how many blocks the input so far compiles into, because if |
|
432 | # that's it. If we've come back from some indentation, we need | |
433 | # there's already more than one full independent block of input, then |
|
433 | # the blank final line to finish. | |
434 | # the client has entered full 'cell' mode and is feeding lines that |
|
434 | # In cell mode, we need to check how many blocks the input so far | |
435 | # each is complete. In this case we should then keep accepting. |
|
435 | # compiles into, because if there's already more than one full | |
436 | # The Qt terminal-like console does precisely this, to provide the |
|
436 | # independent block of input, then the client has entered full | |
437 | # convenience of terminal-like input of single expressions, but |
|
437 | # 'cell' mode and is feeding lines that each is complete. In this | |
438 | # allowing the user (with a separate keystroke) to switch to 'cell' |
|
438 | # case we should then keep accepting. The Qt terminal-like console | |
439 | # mode and type multiple expressions in one shot. |
|
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 | if self.indent_spaces==0: |
|
443 | if self.indent_spaces==0: | |
441 | if self.input_mode=='line': |
|
444 | if self.input_mode=='line': | |
442 | return False |
|
445 | if not self._full_dedent: | |
|
446 | return False | |||
443 | else: |
|
447 | else: | |
444 | nblocks = len(split_blocks(''.join(self._buffer))) |
|
448 | nblocks = len(split_blocks(''.join(self._buffer))) | |
445 | if nblocks==1: |
|
449 | if nblocks==1: |
@@ -259,6 +259,17 b' class InputSplitterTestCase(unittest.TestCase):' | |||||
259 | self.assertTrue(isp.push_accepts_more()) |
|
259 | self.assertTrue(isp.push_accepts_more()) | |
260 | isp.push('') |
|
260 | isp.push('') | |
261 | self.assertFalse(isp.push_accepts_more()) |
|
261 | self.assertFalse(isp.push_accepts_more()) | |
|
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()) | |||
262 |
|
273 | |||
263 | def test_continuation(self): |
|
274 | def test_continuation(self): | |
264 | isp = self.isp |
|
275 | isp = self.isp |
General Comments 0
You need to be logged in to leave comments.
Login now