##// END OF EJS Templates
fix trailing whitespace from reseting indentation
Paul Ivanov -
Show More
@@ -434,7 +434,7 b' class InputSplitter(object):'
434 #print 'Full dedent in text',self.source # dbg
434 #print 'Full dedent in text',self.source # dbg
435 full_dedent = True
435 full_dedent = True
436
436
437 if line[-1] == ':':
437 if line.rstrip()[-1] == ':':
438 indent_spaces += 4
438 indent_spaces += 4
439 elif dedent_re.match(line):
439 elif dedent_re.match(line):
440 indent_spaces -= 4
440 indent_spaces -= 4
@@ -200,6 +200,21 b' class InputSplitterTestCase(unittest.TestCase):'
200 isp.push("if 1:")
200 isp.push("if 1:")
201 isp.push(" x = (1+\n 2)")
201 isp.push(" x = (1+\n 2)")
202 self.assertEqual(isp.indent_spaces, 4)
202 self.assertEqual(isp.indent_spaces, 4)
203
204 def test_indent4(self):
205 # In cell mode, inputs must be fed in whole blocks, so skip this test
206 if self.isp.input_mode == 'cell': return
207
208 isp = self.isp
209 # whitespace after ':' should not screw up indent level
210 isp.push('if 1: \n x=1')
211 self.assertEqual(isp.indent_spaces, 4)
212 isp.push('y=2\n')
213 self.assertEqual(isp.indent_spaces, 0)
214 isp.push('if 1:\t\n x=1')
215 self.assertEqual(isp.indent_spaces, 4)
216 isp.push('y=2\n')
217 self.assertEqual(isp.indent_spaces, 0)
203
218
204 def test_dedent_pass(self):
219 def test_dedent_pass(self):
205 isp = self.isp # shorthand
220 isp = self.isp # shorthand
General Comments 0
You need to be logged in to leave comments. Login now