MCPcopy
hub / github.com/virattt/dexter / openOther

Method openOther

src/components/question-prompt.ts:187–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185 // ──────────────────────────────────────────────────────────────────────────
186
187 private openOther(): void {
188 const tab = this.activeTab;
189 const q = this.questions[tab];
190 const editor = new CustomEditor(this.tui, editorTheme);
191 editor.focused = true;
192 if (this.otherText[tab]) {
193 editor.setText(this.otherText[tab]!);
194 }
195 editor.onCtrlC = () => this.onAbort?.();
196 editor.onEscape = () => {
197 this.mode = 'select';
198 this.editor = null;
199 this.tui.requestRender();
200 };
201 editor.onSubmit = (text: string) => {
202 const t = text.trim();
203 if (q.multiSelect) {
204 if (t) {
205 this.otherText[tab] = t;
206 this.selected[tab].add(OTHER_MARKER);
207 } else {
208 this.otherText[tab] = undefined;
209 this.selected[tab].delete(OTHER_MARKER);
210 }
211 this.mode = 'select';
212 this.editor = null;
213 this.tui.requestRender();
214 } else if (t) {
215 this.otherText[tab] = t;
216 this.selected[tab] = new Set();
217 this.mode = 'select';
218 this.editor = null;
219 this.advance();
220 this.tui.requestRender();
221 } else {
222 this.mode = 'select';
223 this.editor = null;
224 this.tui.requestRender();
225 }
226 };
227 this.editor = editor;
228 this.mode = 'other';
229 }
230
231 // ──────────────────────────────────────────────────────────────────────────
232 // Derived state

Callers 1

activateRowMethod · 0.95

Calls 3

advanceMethod · 0.95
setTextMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected