(state: State, pointer: Doc.AnsiDoc)
| 50 | const NEWLINE_REGEX = /\r?\n/ |
| 51 | |
| 52 | function renderError(state: State, pointer: Doc.AnsiDoc) { |
| 53 | return Option.match(state.error, { |
| 54 | onNone: () => Doc.empty, |
| 55 | onSome: (error) => { |
| 56 | const errorLines = error.split(NEWLINE_REGEX) |
| 57 | if (Arr.isNonEmptyReadonlyArray(errorLines)) { |
| 58 | const annotateLine = (line: string): Doc.AnsiDoc => |
| 59 | Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red)) |
| 60 | const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space) |
| 61 | const lines = Arr.map(errorLines, (str) => annotateLine(str)) |
| 62 | return Doc.cursorSavePosition.pipe( |
| 63 | Doc.cat(Doc.hardLine), |
| 64 | Doc.cat(prefix), |
| 65 | Doc.cat(Doc.align(Doc.vsep(lines))), |
| 66 | Doc.cat(Doc.cursorRestorePosition) |
| 67 | ) |
| 68 | } |
| 69 | return Doc.empty |
| 70 | } |
| 71 | }) |
| 72 | } |
| 73 | |
| 74 | function renderParts(state: State, submitted: boolean = false) { |
| 75 | return Arr.reduce( |
no test coverage detected
searching dependent graphs…