(lines, presetName)
| 4549 | } |
| 4550 | |
| 4551 | function resolveTimelineSection(lines, presetName) { |
| 4552 | const isCustom = presetName === 'custom'; |
| 4553 | let sectionStart = -1; |
| 4554 | let sectionIndent = 0; |
| 4555 | |
| 4556 | if (isCustom) { |
| 4557 | for (let i = 0; i < lines.length; i++) { |
| 4558 | if (/^custom:\s*/.test(lines[i])) { |
| 4559 | sectionStart = i; |
| 4560 | sectionIndent = 0; |
| 4561 | break; |
| 4562 | } |
| 4563 | } |
| 4564 | } else { |
| 4565 | let inPresets = false; |
| 4566 | for (let i = 0; i < lines.length; i++) { |
| 4567 | const line = lines[i]; |
| 4568 | if (/^presets:\s*/.test(line)) { |
| 4569 | inPresets = true; |
| 4570 | continue; |
| 4571 | } |
| 4572 | if (inPresets && /^\S/.test(line) && !line.startsWith('#')) { |
| 4573 | break; |
| 4574 | } |
| 4575 | if (inPresets) { |
| 4576 | const m = line.match(/^(\s+)(\S+):\s*/); |
| 4577 | if (m && m[2] === presetName) { |
| 4578 | sectionStart = i; |
| 4579 | sectionIndent = m[1].length; |
| 4580 | break; |
| 4581 | } |
| 4582 | } |
| 4583 | } |
| 4584 | } |
| 4585 | |
| 4586 | if (sectionStart < 0) return null; |
| 4587 | |
| 4588 | let sectionEnd = lines.length; |
| 4589 | for (let i = sectionStart + 1; i < lines.length; i++) { |
| 4590 | const line = lines[i]; |
| 4591 | if (line.trim() === '' || line.trim().startsWith('#')) continue; |
| 4592 | const indent = line.search(/\S/); |
| 4593 | if (indent <= sectionIndent) { |
| 4594 | sectionEnd = i; |
| 4595 | break; |
| 4596 | } |
| 4597 | } |
| 4598 | |
| 4599 | return { sectionStart, sectionEnd, sectionIndent }; |
| 4600 | } |
| 4601 | |
| 4602 | function resolveTimelineTarget(lines, presetName, periodKey) { |
| 4603 | const section = resolveTimelineSection(lines, presetName); |
no outgoing calls
no test coverage detected