Corrected issue where some line numbers were set to 0 #6

This commit is contained in:
KevinMarquette
2017-02-06 21:12:38 -08:00
parent 417b0ce4ad
commit 068d1e129d

View File

@@ -11,12 +11,23 @@ class MonitoredScript
MonitoredScript() MonitoredScript()
{ {
$this.Line =New-Object 'System.Collections.Generic.List[ScriptLine]' $this.Line = New-Object 'System.Collections.Generic.List[ScriptLine]'
} }
[int] SetScript([string]$Path) [int] SetScript([string]$Path)
{ {
Get-Content -Path $Path | %{ $this.Line.Add( [ScriptLine]@{text=$_;path=$path})} $lineNumber = 0
foreach($command in (Get-Content -Path $Path))
{
$this.Line.Add(
[ScriptLine]@{
Text = $command
Path = $path
LineNumber = $lineNumber
}
)
$lineNumber++
}
$this.LinesOfCode = $this.Line.Count $this.LinesOfCode = $this.Line.Count
return $this.LinesOfCode return $this.LinesOfCode
} }
@@ -26,7 +37,6 @@ class MonitoredScript
# Line numbers start at 1 but the array starts at 0 # Line numbers start at 1 but the array starts at 0
$lineNumber = $node.Breakpoint.Line - 1 $lineNumber = $node.Breakpoint.Line - 1
$record = $this.Line[$lineNumber] $record = $this.Line[$lineNumber]
$record.LineNumber = $lineNumber
if($this.lastNode) if($this.lastNode)
{ {