From b3ed4c86a8d8f53925babc015dcfc3e43d3608ea Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 10 Dec 2011 22:21:58 +0100 Subject: [PATCH] Fixed potential NullReferenceException in HeightTree.GetNodeByVisualPosition --- .../AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs index 77272ce29c..47b84b46f3 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs @@ -446,7 +446,8 @@ namespace ICSharpCode.AvalonEdit.Rendering // i.e. at the end of the document, or due to rounding errors in previous loop iterations. // If node.lineNode isn't collapsed, return that. - if (node.lineNode.TotalHeight > 0) + // Also return node.lineNode if there is no previous node that we could return instead. + if (node.lineNode.TotalHeight > 0 || node.left == null) return node; // Otherwise, descend into left (find the last non-collapsed node) node = node.left;