(trail: WireTrail)
| 64 | * meant it to say. |
| 65 | */ |
| 66 | export function trailDecay(trail: WireTrail): TrailDecay | null { |
| 67 | const missing = trail.hops.filter((hop) => hop.status === 'missing'); |
| 68 | const ambiguous = trail.hops.filter((hop) => hop.status === 'ambiguous'); |
| 69 | const moved = trail.hops.filter((hop) => hop.status === 'moved'); |
| 70 | |
| 71 | if (missing.length > 0) { |
| 72 | return { |
| 73 | tone: 'warn', |
| 74 | text: |
| 75 | `${plural(missing.length, 'hop')} moved or renamed since this was saved — ` + |
| 76 | `${nameList(missing)} no longer in the index.`, |
| 77 | }; |
| 78 | } |
| 79 | if (ambiguous.length > 0) { |
| 80 | return { |
| 81 | tone: 'warn', |
| 82 | text: `${nameList(ambiguous)} now ${ambiguous.length === 1 ? 'names' : 'name'} more than one symbol — showing the closest match.`, |
| 83 | }; |
| 84 | } |
| 85 | if (moved.length > 0) { |
| 86 | return { |
| 87 | tone: 'note', |
| 88 | text: `${nameList(moved)} moved to another file since this was saved.`, |
| 89 | }; |
| 90 | } |
| 91 | return null; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * How much of the trail can actually be opened, or null when all of it can. |
no test coverage detected