Skip to content

Commit 82de2a7

Browse files
author
Kapil Borle
committed
Add null check for range parameter in IsValidRange
1 parent b395f92 commit 82de2a7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Engine/EditableText.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,27 @@ public EditableText ApplyEdit(TextEdit textEdit)
106106

107107
// TODO Add a method that takes multiple edits, checks if they are unique and applies them.
108108

109+
/// <summary>
110+
/// Checks if the range falls within the bounds of the text.
111+
/// </summary>
112+
/// <param name="range"></param>
113+
/// <returns></returns>
109114
public bool IsValidRange(Range range)
110115
{
116+
if (range == null)
117+
{
118+
throw new ArgumentNullException(nameof(range));
119+
}
120+
111121
return range.Start.Line <= Lines.Length
112122
&& range.End.Line <= Lines.Length
113123
&& range.Start.Column <= Lines[range.Start.Line - 1].Length
114124
&& range.End.Column <= Lines[range.End.Line - 1].Length + 1;
115125
}
116126

127+
/// <summary>
128+
/// Returns the text representation of the object.
129+
/// </summary>
117130
public override string ToString()
118131
{
119132
return Text;

0 commit comments

Comments
 (0)