diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 250d70a..267b73a 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -142,7 +142,7 @@ def find_next_indent(code): tokens.pop() if not tokens: return 0 - if tokens[-1].type in {tokenize.DEDENT, tokenize.NEWLINE, tokenize.COMMENT}: + while (tokens[-1].type in {tokenize.DEDENT, tokenize.NEWLINE, tokenize.COMMENT}): tokens.pop() if tokens[-1].type == INCOMPLETE_STRING: diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index f064efa..54e85c0 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -629,6 +629,9 @@ indentation_samples = [ ' 1,', 5), ('b = """123', 0), ('', 0), + ('def f():\n pass', 0), + ('class Bar:\n def f():\n pass', 4), + ('class Bar:\n def f():\n raise', 4), ] def test_find_next_indent():