From 133cbb044cc87dc5193ae35f21b963648feb689d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6nnqvist?= Date: Wed, 19 Apr 2023 14:37:06 -0700 Subject: [PATCH] Fix crash parsing document tree dump as markdown content rdar://108281578 --- .../Parser/BlockDirectiveParser.swift | 4 +--- .../Parsing/BlockDirectiveParserTests.swift | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Sources/Markdown/Parser/BlockDirectiveParser.swift b/Sources/Markdown/Parser/BlockDirectiveParser.swift index 6c21ce45..95d15444 100644 --- a/Sources/Markdown/Parser/BlockDirectiveParser.swift +++ b/Sources/Markdown/Parser/BlockDirectiveParser.swift @@ -190,9 +190,7 @@ struct PendingBlockDirective { let leadingSpacingCount = line.untrimmedText.count - textCount - trailingWhiteSpaceCount - 1 innerIndentationColumnCount = leadingSpacingCount // Should we add a new property for this kind of usage? - let startIndex = line.untrimmedText.startIndex - let endIndex = line.untrimmedText.index(startIndex, offsetBy: leadingSpacingCount) - let newLine = line.untrimmedText.replacingCharacters(in: startIndex..