File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ public EditableText ApplyEdit(TextEdit textEdit)
106
106
107
107
// TODO Add a method that takes multiple edits, checks if they are unique and applies them.
108
108
109
+ public bool IsValidRange ( Range range )
110
+ {
111
+ return range . Start . Line <= Lines . Length
112
+ && range . End . Line <= Lines . Length
113
+ && range . Start . Column <= Lines [ range . Start . Line - 1 ] . Length
114
+ && range . End . Column <= Lines [ range . End . Line - 1 ] . Length + 1 ;
115
+ }
116
+
109
117
public override string ToString ( )
110
118
{
111
119
return Text ;
@@ -123,10 +131,7 @@ private void ValidateTextEdit(TextEdit textEdit)
123
131
124
132
private void ValidateTextEditExtent ( TextEdit textEdit )
125
133
{
126
- if ( textEdit . StartLineNumber > Lines . Length
127
- || textEdit . EndLineNumber > Lines . Length
128
- || textEdit . StartColumnNumber > Lines [ textEdit . StartLineNumber - 1 ] . Length
129
- || textEdit . EndColumnNumber > Lines [ textEdit . EndLineNumber - 1 ] . Length + 1 )
134
+ if ( IsValidRange ( textEdit ) )
130
135
{
131
136
throw new ArgumentException ( String . Format (
132
137
CultureInfo . CurrentCulture ,
You can’t perform that action at this time.
0 commit comments