MarkdownDocument.FindClosestLine throws ArgumentOutOfRangeException sometimes #23

Closed
opened 2026-01-29 14:21:11 +00:00 by claunia · 1 comment
Owner

Originally created by @madskristensen on GitHub (Jun 21, 2016).

I assume it's when the line number passed into the method exceeds the line count of the MarkdownDocument. There is no way to determine the line count of the document in the API though. In MarkdownEditor I've put a try/catch block around it for now.

Here's the callstack:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
   at Markdig.Syntax.ContainerBlock.get_Item(Int32 index)
   at Markdig.Syntax.BlockExtensions.FindClosestBlock(Block rootBlock, Int32 line)
   at Markdig.Syntax.BlockExtensions.FindClosestBlock(Block rootBlock, Int32 line)
   at Markdig.Syntax.BlockExtensions.FindClosestLine(MarkdownDocument root, Int32 line)
   at MarkdownEditor.Browser.UpdatePosition(Int32 line) in C:\Users\username\Documents\GitHub\MarkdownEditor\src\Margin\Browser.cs:line 121

It may be when the line contains pipe tables, but I'm not sure it's related.

Originally created by @madskristensen on GitHub (Jun 21, 2016). I assume it's when the line number passed into the method exceeds the line count of the MarkdownDocument. There is no way to determine the line count of the document in the API though. In MarkdownEditor I've put a try/catch block around it for now. Here's the callstack: ``` System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index at Markdig.Syntax.ContainerBlock.get_Item(Int32 index) at Markdig.Syntax.BlockExtensions.FindClosestBlock(Block rootBlock, Int32 line) at Markdig.Syntax.BlockExtensions.FindClosestBlock(Block rootBlock, Int32 line) at Markdig.Syntax.BlockExtensions.FindClosestLine(MarkdownDocument root, Int32 line) at MarkdownEditor.Browser.UpdatePosition(Int32 line) in C:\Users\username\Documents\GitHub\MarkdownEditor\src\Margin\Browser.cs:line 121 ``` It may be when the line contains pipe tables, but I'm not sure it's related.
claunia added the bug label 2026-01-29 14:21:11 +00:00
Author
Owner

@xoofx commented on GitHub (Jun 22, 2016):

This is fixed by commit 8220f0fa56

@xoofx commented on GitHub (Jun 22, 2016): This is fixed by commit 8220f0fa567adf0f2001a1224d084fd4329cd3e2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#23