diff --git a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringLexer.java b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringLexer.java index fdf8adb4ddb2..e76d00aadf96 100644 --- a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringLexer.java +++ b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringLexer.java @@ -42,21 +42,18 @@ public class PyDocstringLexer extends PythonIndentingLexer { indent = 0; while (getBaseTokenType() != null && ourIgnoreSet.contains(getBaseTokenType())) advanceBase(); - while (getBaseTokenType() != null && PyTokenTypes.WHITESPACE_OR_LINEBREAK.contains(getBaseTokenType())) { + while (getBaseTokenType() != null && PyTokenTypes.WHITESPACE.contains(getBaseTokenType())) { if (getBaseTokenType() == PyTokenTypes.TAB) { indent = ((indent / 8) + 1) * 8; } else if (getBaseTokenType() == PyTokenTypes.SPACE) { indent++; } - else if (getBaseTokenType() == PyTokenTypes.LINE_BREAK) { - indent = 0; - } advanceBase(); } if (getBaseTokenType() == null) { return 0; } - return indent - 1; + return indent > 0? indent - 1 : indent; } } diff --git a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringParsingContext.java b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringParsingContext.java index 3eaace6768d2..6f196d41855c 100644 --- a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringParsingContext.java +++ b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringParsingContext.java @@ -58,6 +58,11 @@ public class PyDocstringParsingContext extends ParsingContext { IElementType type = myBuilder.getTokenType(); if (type == PyDocstringTokenTypes.WELCOME) { // >>> case myBuilder.advanceLexer(); + while (myBuilder.getTokenType() == PyTokenTypes.STATEMENT_BREAK || myBuilder.getTokenType() == PyDocstringTokenTypes.WELCOME) { + myBuilder.advanceLexer(); + } + if (myBuilder.getTokenType() == PyTokenTypes.INDENT) + myBuilder.advanceLexer(); } super.parseStatement(scope); }