|
|
@@ -14,11 +14,15 @@ func getLocation(linePairs [][]int, start int, end int) Location {
|
|
|
var (
|
|
|
prevNewLine int
|
|
|
location Location
|
|
|
+ lineSet bool
|
|
|
+ _lineNum int
|
|
|
)
|
|
|
|
|
|
for lineNum, pair := range linePairs {
|
|
|
+ _lineNum = lineNum
|
|
|
newLineByteIndex := pair[0]
|
|
|
if prevNewLine <= start && start < newLineByteIndex {
|
|
|
+ lineSet = true
|
|
|
location.startLine = lineNum
|
|
|
location.endLine = lineNum
|
|
|
location.startColumn = (start - prevNewLine) + 1 // +1 because counting starts at 1
|
|
|
@@ -30,9 +34,17 @@ func getLocation(linePairs [][]int, start int, end int) Location {
|
|
|
location.endColumn = (end - prevNewLine)
|
|
|
location.endLineIndex = newLineByteIndex
|
|
|
}
|
|
|
-
|
|
|
prevNewLine = pair[0]
|
|
|
}
|
|
|
|
|
|
+ if !lineSet {
|
|
|
+ // if lines never get set then that means the secret is most likely
|
|
|
+ // on the last line of the diff output and the diff output does not have
|
|
|
+ // a newline
|
|
|
+ location.startColumn = (start - prevNewLine) + 1 // +1 because counting starts at 1
|
|
|
+ location.endColumn = (end - prevNewLine)
|
|
|
+ location.startLine = _lineNum + 1
|
|
|
+ location.endLine = _lineNum + 1
|
|
|
+ }
|
|
|
return location
|
|
|
}
|