| 128 | } |
| 129 | |
| 130 | async showQuickPick<T extends QuickPickItem>(items: [T]) { |
| 131 | const disposables: Disposable[] = [] |
| 132 | try { |
| 133 | return await new Promise<T>((resolve, reject) => { |
| 134 | const input = window.createQuickPick<T>() |
| 135 | input.title = this.title |
| 136 | input.step = this.currentStepNumber |
| 137 | input.totalSteps = this.totalSteps |
| 138 | input.items = items |
| 139 | ;(input.buttons = |
| 140 | this.steps.length > 1 ? [QuickInputButtons.Back] : []), |
| 141 | disposables.push( |
| 142 | input.onDidTriggerButton(item => { |
| 143 | if (item === QuickInputButtons.Back) { |
| 144 | reject(InputFlowAction.back()) |
| 145 | } else { |
| 146 | resolve(<any>item) |
| 147 | } |
| 148 | }), |
| 149 | input.onDidChangeSelection(items => resolve(items[0])), |
| 150 | input.onDidHide(() => { |
| 151 | reject(InputFlowAction.cancel()) |
| 152 | }) |
| 153 | ) |
| 154 | if (this.current) { |
| 155 | this.current.dispose() |
| 156 | } |
| 157 | this.current = input |
| 158 | this.current.show() |
| 159 | }) |
| 160 | } finally { |
| 161 | disposables.forEach(d => d.dispose()) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | async showInputBox(prompt: string) { |
| 166 | const disposables: Disposable[] = [] |