lineEquivalentMatchLines returns the 1-based start line of every contiguous block of contentLines that matches needleLines under eq.
(contentLines, needleLines []string, eq func(a, b string) bool)
| 1281 | // lineEquivalentMatchLines returns the 1-based start line of every |
| 1282 | // contiguous block of contentLines that matches needleLines under eq. |
| 1283 | func lineEquivalentMatchLines(contentLines, needleLines []string, eq func(a, b string) bool) []int { |
| 1284 | if len(needleLines) == 0 || len(needleLines) > len(contentLines) { |
| 1285 | return nil |
| 1286 | } |
| 1287 | var starts []int |
| 1288 | outer: |
| 1289 | for i := 0; i <= len(contentLines)-len(needleLines); i++ { |
| 1290 | for j, n := range needleLines { |
| 1291 | if !eq(contentLines[i+j], n) { |
| 1292 | continue outer |
| 1293 | } |
| 1294 | } |
| 1295 | starts = append(starts, i+1) |
| 1296 | } |
| 1297 | return starts |
| 1298 | } |
| 1299 | |
| 1300 | // formatLineList renders a sorted line list as "12, 47, 89", truncated |
| 1301 | // to maxHintLines entries with " and N more" when more exist. |