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)
106106
107107 // TODO Add a method that takes multiple edits, checks if they are unique and applies them.
108108
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+
109117 public override string ToString ( )
110118 {
111119 return Text ;
@@ -123,10 +131,7 @@ private void ValidateTextEdit(TextEdit textEdit)
123131
124132 private void ValidateTextEditExtent ( TextEdit textEdit )
125133 {
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 ) )
130135 {
131136 throw new ArgumentException ( String . Format (
132137 CultureInfo . CurrentCulture ,
You can’t perform that action at this time.
0 commit comments