matchConsecutive scans sideLines for a consecutive run matching all targetLines.
(sideLines []indexedLine, targetLines []string)
| 149 | |
| 150 | // matchConsecutive scans sideLines for a consecutive run matching all targetLines. |
| 151 | func matchConsecutive(sideLines []indexedLine, targetLines []string) (startLine, endLine int, found bool) { |
| 152 | if len(targetLines) == 0 || len(sideLines) < len(targetLines) { |
| 153 | return 0, 0, false |
| 154 | } |
| 155 | for i := 0; i <= len(sideLines)-len(targetLines); i++ { |
| 156 | matched := true |
| 157 | for j, target := range targetLines { |
| 158 | if sideLines[i+j].content != target { |
| 159 | matched = false |
| 160 | break |
| 161 | } |
| 162 | } |
| 163 | if matched { |
| 164 | return sideLines[i].lineNum, sideLines[i+len(targetLines)-1].lineNum, true |
| 165 | } |
| 166 | } |
| 167 | return 0, 0, false |
| 168 | } |
| 169 | |
| 170 | // resolveFromFileContent scans the new file content line-by-line for consecutive |
| 171 | // matches of the normalized existing_code. |
no outgoing calls