(host: SlashCommandHost)
| 125 | } |
| 126 | |
| 127 | async function showUndoSelector(host: SlashCommandHost): Promise<void> { |
| 128 | if (host.session === undefined) { |
| 129 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | const availability = await resolveUndoAvailability(host); |
| 134 | const choices = createUndoChoices( |
| 135 | host.state.transcriptEntries, |
| 136 | host.state.transcriptContainer.children, |
| 137 | availability.maxCount, |
| 138 | ); |
| 139 | if (choices.length === 0) { |
| 140 | showUndoLimitStatus(host, formatNothingToUndoMessage(availability)); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | host.mountEditorReplacement( |
| 145 | new UndoSelectorComponent({ |
| 146 | choices, |
| 147 | onSelect: (choice) => { |
| 148 | void undoByCount(host, choice.count).then((undone) => { |
| 149 | if (undone) { |
| 150 | host.restoreInputText(choice.input); |
| 151 | return; |
| 152 | } |
| 153 | host.restoreEditor(); |
| 154 | }); |
| 155 | }, |
| 156 | onCancel: () => { |
| 157 | host.restoreEditor(); |
| 158 | }, |
| 159 | }), |
| 160 | ); |
| 161 | } |
| 162 | |
| 163 | function parseUndoCount(args: string): number | undefined { |
| 164 | const value = args.trim(); |
no test coverage detected