Skip to content

Commit 15db606

Browse files
committed
cleaning the code
1 parent 2615102 commit 15db606

File tree

3 files changed

+7
-70
lines changed

3 files changed

+7
-70
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class StartSessionAction extends EditorAction2 {
6767
options = arg;
6868
}
6969
InlineChatController.get(editor)?.run(options);
70-
InlineChatController.get(editor)?.run(options);
7170
}
7271
}
7372

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

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,14 @@ export class InlineChatController implements IEditorContribution {
134134
}
135135

136136
this._log('session RESUMING', e);
137-
console.log('before calling create session of the constructor');
138137
await this._nextState(State.CREATE_SESSION, { existingSession });
139138
this._log('session done or paused');
140139
}));
141140
this._log('NEW controller');
142141
}
143142

144143
dispose(): void {
145-
console.log('inside of dispose');
146144
this._stashedSession.clear();
147-
console.log('inside of dispose before calling finishExistingSession');
148145
this.finishExistingSession();
149146
this._store.dispose();
150147
this._log('controller disposed');
@@ -221,18 +218,6 @@ export class InlineChatController implements IEditorContribution {
221218
}
222219

223220
private async [State.CREATE_SESSION](options: InlineChatRunOptions): Promise<State.CANCEL | State.INIT_UI | State.PAUSE> {
224-
console.log('inside of CREATE_SESSION');
225-
console.log('inside of CREATE_SESSION, this._activeSession : ', this._activeSession);
226-
// if (this._activeSession) {
227-
// console.log('inside of CREATE_SESSION, before clearing the session store');
228-
// this._sessionStore.clear();
229-
// console.log('inside of CREATE_SESSION, before releasing the session');
230-
// this._inlineChatSessionService.releaseSession(this._activeSession);
231-
// console.log('inside of CREATE_SESSION, before calling pause');
232-
// // Doesn't appear to be properly awaited?
233-
// await this[State.PAUSE]();
234-
// }
235-
console.log('inside of CREATE_SESSION, this._activeSession after the cleaning : ', this._activeSession);
236221
assertType(this._activeSession === undefined);
237222
assertType(this._editor.hasModel());
238223

@@ -245,7 +230,6 @@ export class InlineChatController implements IEditorContribution {
245230
if (!session) {
246231
const createSessionCts = new CancellationTokenSource();
247232
const msgListener = Event.once(this._messages.event)(m => {
248-
console.log('inside of CREATE_SESSION, inside of the msgListener code of CREATE_SESSION');
249233
this._log('state=_createSession) message received', m);
250234
if (m === Message.ACCEPT_INPUT) {
251235
// user accepted the input before having a session
@@ -297,8 +281,6 @@ export class InlineChatController implements IEditorContribution {
297281
}
298282

299283
private async [State.INIT_UI](options: InlineChatRunOptions): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {
300-
console.log('inside of init ui');
301-
console.log('inside of INIT_UI, this._activeSession : ', this._activeSession);
302284
assertType(this._activeSession);
303285

304286
// hide/cancel inline completions when invoking IE
@@ -359,20 +341,16 @@ export class InlineChatController implements IEditorContribution {
359341

360342
if (editIsOutsideOfWholeRange) {
361343
this._log('text changed outside of whole range, FINISH session');
362-
console.log('inside of INIT_UI, before calling finish existing session');
363344
this.finishExistingSession();
364345
}
365346
}));
366347

367348
if (!this._activeSession.lastExchange) {
368-
console.log('inside of INIT_UI,before waiting for input');
369349
return State.WAIT_FOR_INPUT;
370350
} else if (options.isUnstashed) {
371351
delete options.isUnstashed;
372-
console.log('inside of INIT_UI,before apply response');
373352
return State.APPLY_RESPONSE;
374353
} else {
375-
console.log('inside of INIT_UI,before show response');
376354
return State.SHOW_RESPONSE;
377355
}
378356
}
@@ -391,9 +369,7 @@ export class InlineChatController implements IEditorContribution {
391369
}
392370

393371

394-
private async [State.WAIT_FOR_INPUT](options: InlineChatRunOptions): Promise<void | State.ACCEPT | State.CANCEL | State.PAUSE | State.WAIT_FOR_INPUT | State.MAKE_REQUEST> {
395-
console.log('inside of wait for input');
396-
372+
private async [State.WAIT_FOR_INPUT](options: InlineChatRunOptions): Promise<State.ACCEPT | State.CANCEL | State.PAUSE | State.WAIT_FOR_INPUT | State.MAKE_REQUEST> {
397373
assertType(this._activeSession);
398374
assertType(this._strategy);
399375

@@ -414,7 +390,6 @@ export class InlineChatController implements IEditorContribution {
414390
} else {
415391
const barrier = new Barrier();
416392
const msgListener = Event.once(this._messages.event)(m => {
417-
console.log('inside of WAIT_FOR_INPUT, inside of msgListener');
418393
this._log('state=_waitForInput) message received', m);
419394
message = m;
420395
barrier.open();
@@ -426,17 +401,11 @@ export class InlineChatController implements IEditorContribution {
426401
this._zone.value.widget.selectAll();
427402

428403
if (message & (Message.CANCEL_INPUT | Message.CANCEL_SESSION)) {
429-
console.log('inside of WAIT_FOR_INPUT,entered into the case when message cancel session');
430-
await this[State.CANCEL]();
431-
return;
432-
// return State.CANCEL;
404+
return State.CANCEL;
433405
}
434406

435407
if (message & Message.ACCEPT_SESSION) {
436-
console.log('inside of WAIT_FOR_INPUT,entered into the case when message accept');
437-
await this[State.ACCEPT]();
438-
return;
439-
// return State.ACCEPT;
408+
return State.ACCEPT;
440409
}
441410

442411
if (message & Message.PAUSE_SESSION) {
@@ -488,7 +457,6 @@ export class InlineChatController implements IEditorContribution {
488457

489458
let message = Message.NONE;
490459
const msgListener = Event.once(this._messages.event)(m => {
491-
console.log('inside of MAKE_REQUEST, inside of msgListener of MAKE REQUEST');
492460
this._log('state=_makeRequest) message received', m);
493461
message = m;
494462
requestCts.cancel();
@@ -543,12 +511,10 @@ export class InlineChatController implements IEditorContribution {
543511
this._activeSession.addExchange(new SessionExchange(this._activeSession.lastInput, response));
544512

545513
if (message & Message.CANCEL_SESSION) {
546-
console.log('inside of MAKE_REQUEST, cancelling the session');
547514
return State.CANCEL;
548515
} else if (message & Message.PAUSE_SESSION) {
549516
return State.PAUSE;
550517
} else if (message & Message.ACCEPT_SESSION) {
551-
console.log('inside of MAKE_REQUEST, accepting');
552518
return State.ACCEPT;
553519
} else {
554520
return State.APPLY_RESPONSE;
@@ -664,8 +630,6 @@ export class InlineChatController implements IEditorContribution {
664630

665631
private async [State.PAUSE]() {
666632

667-
console.log('entered into pause state');
668-
669633
this._ctxDidEdit.reset();
670634
this._ctxUserDidEdit.reset();
671635
this._ctxLastResponseType.reset();
@@ -685,35 +649,24 @@ export class InlineChatController implements IEditorContribution {
685649
}
686650

687651
private async [State.ACCEPT]() {
688-
console.log('inside of State.ACCEPT');
689652
assertType(this._activeSession);
690653
assertType(this._strategy);
691654
this._sessionStore.clear();
692-
console.log('inside of State.ACCEPT, after assert type');
693655

694656
try {
695-
console.log('inside of State.ACCEPT, before strategy apply');
696657
await this._strategy.apply();
697-
console.log('inside of State.ACCEPT, after strategy apply');
698-
// TODO: ASK WHY DESPITE AWAIT, AFTER STRATEFY NOT PRINTED BEFORE CREATE SESSION
699658
} catch (err) {
700-
console.log('inside of State.ACCEPT, when error obtained');
701659
this._dialogService.error(localize('err.apply', "Failed to apply changes.", toErrorMessage(err)));
702660
this._log('FAILED to apply changes');
703661
this._log(err);
704662
}
705663

706-
console.log('inside of State.ACCEPT, before release session');
707-
708-
await this._inlineChatSessionService.releaseSession(this._activeSession);
664+
this._inlineChatSessionService.releaseSession(this._activeSession);
709665

710-
console.log('inside of State.ACCEPT, before state pause');
711-
await this[State.PAUSE]();
666+
this[State.PAUSE]();
712667
}
713668

714669
private async [State.CANCEL]() {
715-
console.log('inside of cancel the session');
716-
717670
assertType(this._activeSession);
718671
assertType(this._strategy);
719672
this._sessionStore.clear();
@@ -728,14 +681,13 @@ export class InlineChatController implements IEditorContribution {
728681
this._log(err);
729682
}
730683

731-
await this[State.PAUSE]();
684+
this[State.PAUSE]();
732685

733686
this._stashedSession.clear();
734687
if (!mySession.isUnstashed && mySession.lastExchange) {
735688
// only stash sessions that had edits
736689
this._stashedSession.value = this._instaService.createInstance(StashedSession, this._editor, mySession);
737690
} else {
738-
console.log('before releasing the session of cancel');
739691
this._inlineChatSessionService.releaseSession(mySession);
740692
}
741693
}
@@ -815,13 +767,10 @@ export class InlineChatController implements IEditorContribution {
815767
}
816768

817769
acceptSession(): void {
818-
console.log('inside of acceptSession method');
819-
// Will fire a message which will be picked up by the controller and some other code will be run
820770
this._messages.fire(Message.ACCEPT_SESSION);
821771
}
822772

823773
cancelSession() {
824-
console.log('inside of cancelSession');
825774
let result: string | undefined;
826775
if (this._strategy && this._activeSession) {
827776
const changedText = this._activeSession.asChangedText();
@@ -836,21 +785,15 @@ export class InlineChatController implements IEditorContribution {
836785
}
837786

838787
finishExistingSession(): void {
839-
console.log('inside of finish existing session');
840-
console.log(this._activeSession);
841788
if (this._activeSession) {
842789
if (this._activeSession.editMode === EditMode.Preview) {
843790
this._log('finishing existing session, using CANCEL', this._activeSession.editMode);
844-
console.log('before cancelling inside of finish existing session');
845791
this.cancelSession();
846792
} else {
847793
this._log('finishing existing session, using APPLY', this._activeSession.editMode);
848-
console.log('before accepting inside of finish existing session');
849794
this.acceptSession();
850795
}
851-
852796
}
853-
console.log('at the end of finish existing session');
854797
}
855798

856799
unstashLastSession(): Session | undefined {
@@ -879,7 +822,6 @@ class StashedSession {
879822
this._ctxHasStashedSession.set(true);
880823
this._listener = Event.once(Event.any(editor.onDidChangeCursorSelection, editor.onDidChangeModelContent, editor.onDidChangeModel))(() => {
881824
this._session = undefined;
882-
console.log('before release session of constructor');
883825
this._sessionService.releaseSession(session);
884826
this._ctxHasStashedSession.reset();
885827
});
@@ -889,7 +831,6 @@ class StashedSession {
889831
this._listener.dispose();
890832
this._ctxHasStashedSession.reset();
891833
if (this._session) {
892-
console.log('before release session of dispose');
893834
this._sessionService.releaseSession(this._session);
894835
}
895836
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class PreviewStrategy extends EditModeStrategy {
8686
}
8787

8888
async apply() {
89-
console.log('at the beginning of the apply method of preview strategy');
89+
9090
if (!(this._session.lastExchange?.response instanceof EditResponse)) {
9191
return;
9292
}
@@ -107,7 +107,6 @@ export class PreviewStrategy extends EditModeStrategy {
107107
modelN.pushStackElement();
108108
}
109109
}
110-
console.log('at the end of the apply method of preview strategy');
111110
}
112111

113112
async cancel(): Promise<void> {
@@ -280,15 +279,13 @@ export class LiveStrategy extends EditModeStrategy {
280279
}
281280

282281
async apply() {
283-
console.log('inside of apply of live strategy');
284282
if (this._editCount > 0) {
285283
this._editor.pushUndoStop();
286284
}
287285
if (this._lastResponse?.workspaceEdits) {
288286
await this._bulkEditService.apply(this._lastResponse.workspaceEdits);
289287
this._instaService.invokeFunction(showSingleCreateFile, this._lastResponse);
290288
}
291-
console.log('at the end of apply for live strategy');
292289
}
293290

294291
async cancel() {

0 commit comments

Comments
 (0)