Skip to content

Commit 7ed090e

Browse files
committed
avoid recursion w/ statemachine
1 parent 69efe10 commit 7ed090e

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ export class InlineChatController implements IEditorContribution {
213213
this._zone.value.show(widgetPosition);
214214
}
215215

216-
protected async _nextState(state: State, options: InlineChatRunOptions | undefined): Promise<void> {
217-
this._log('setState to ', state);
218-
const nextState = await this[state](options);
219-
if (nextState) {
220-
await this._nextState(nextState, options);
216+
protected async _nextState(state: State, options: InlineChatRunOptions): Promise<void> {
217+
let nextState: State | void = state;
218+
while (nextState) {
219+
this._log('setState to ', nextState);
220+
nextState = await this[nextState](options);
221221
}
222222
}
223223

src/vs/workbench/contrib/inlineChat/test/browser/inlineChatController.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ suite('InteractiveChatontroller', function () {
5757
});
5858
}
5959

60-
protected override _nextState(state: State, options: InlineChatRunOptions | undefined): Promise<void> {
61-
this._onDidChangeState.fire(state);
62-
(<State[]>this.states).push(state);
63-
return super._nextState(state, options);
60+
protected override async _nextState(state: State, options: InlineChatRunOptions): Promise<void> {
61+
let nextState: State | void = state;
62+
while (nextState) {
63+
this._onDidChangeState.fire(nextState);
64+
(<State[]>this.states).push(nextState);
65+
nextState = await this[nextState](options);
66+
}
6467
}
6568

6669
override dispose() {

0 commit comments

Comments
 (0)