Skip to content

Commit d89ea60

Browse files
author
Kapil Borle
committed
Add extension method to test line/column in extent
1 parent f5ea97e commit d89ea60

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/PowerShellEditorServices/Utility/Extensions.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,25 @@ public static int ExtentWitdhComparer(this IScriptExtent extentX, IScriptExtent
101101
return 0;
102102
}
103103
}
104+
105+
public static bool Contains(this IScriptExtent scriptExtent, int line, int column)
106+
{
107+
if (scriptExtent.StartLineNumber > line || scriptExtent.EndLineNumber < line)
108+
{
109+
return false;
110+
}
111+
112+
if (scriptExtent.StartLineNumber == line)
113+
{
114+
return scriptExtent.StartColumnNumber <= column;
115+
}
116+
117+
if (scriptExtent.EndLineNumber == line)
118+
{
119+
return scriptExtent.EndColumnNumber >= column;
120+
}
121+
122+
return true;
123+
}
104124
}
105125
}

0 commit comments

Comments
 (0)