Skip to content

Commit ac7aafa

Browse files
committed
cleaning the code
1 parent 4629576 commit ac7aafa

File tree

3 files changed

+16
-40
lines changed

3 files changed

+16
-40
lines changed

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorActions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUE
1414
import { localize } from 'vs/nls';
1515
import { IAction2Options, MenuRegistry } from 'vs/platform/actions/common/actions';
1616
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
17-
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
17+
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1818
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1919
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
2020
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
@@ -565,8 +565,6 @@ export class ExpandMessageAction extends AbstractInteractiveEditorAction {
565565
});
566566
}
567567
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
568-
console.log('running the expand message action');
569-
console.log('CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE : ', CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE.getValue(_accessor.get(IContextKeyService)));
570568
ctrl.updateExpansionState(true);
571569
}
572570
}
@@ -587,8 +585,6 @@ export class ContractMessageAction extends AbstractInteractiveEditorAction {
587585
});
588586
}
589587
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
590-
console.log('running the contract message action');
591-
console.log('CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE : ', CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE.getValue(_accessor.get(IContextKeyService)));
592588
ctrl.updateExpansionState(false);
593589
}
594590
}

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,10 @@ export class InteractiveEditorController implements IEditorContribution {
556556
this._zone.widget.updateStatus('');
557557
this._zone.widget.updateMarkdownMessage(renderedMarkdown.element);
558558
this._zone.widget.updateToolbar(true);
559-
console.log('inside of SHOW_RESPONSE');
560-
console.log('this._activeSession.lastExpansionState', this._activeSession.lastExpansionState);
561-
const state = this._activeSession.newlySelected ? (this._activeSession.lastExpansionState ?? this._zone.widget.cropState()) : this._zone.widget.cropState();
559+
const expansionState = this._activeSession.newlySelected ? (this._activeSession.lastExpansionState ?? this._zone.widget.expansionState()) : this._zone.widget.expansionState();
562560
this._activeSession.newlySelected = false;
563-
this._activeSession.lastExpansionState = state;
564-
this._zone.widget.updateMarkdownMessageExpansionState(state);
561+
this._activeSession.lastExpansionState = expansionState;
562+
this._zone.widget.updateMarkdownMessageExpansionState(expansionState);
565563

566564
} else if (response instanceof EditResponse) {
567565
// edit response -> complex...
@@ -670,12 +668,10 @@ export class InteractiveEditorController implements IEditorContribution {
670668
}
671669

672670
updateExpansionState(expand: boolean) {
673-
console.log('inside of update expansion state, expand : ', expand);
674671
if (this._activeSession) {
675-
const state = expand ? ExpansionState.EXPANDED : ExpansionState.CROPPED;
676-
console.log('state : ', state);
677-
this._zone.widget.updateMarkdownMessageExpansionState(state);
678-
this._activeSession.lastExpansionState = state;
672+
const expansionState = expand ? ExpansionState.EXPANDED : ExpansionState.CROPPED;
673+
this._zone.widget.updateMarkdownMessageExpansionState(expansionState);
674+
this._activeSession.lastExpansionState = expansionState;
679675
}
680676
}
681677

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export class InteractiveEditorWidget {
176176

177177
private _lastDim: Dimension | undefined;
178178
private _isLayouting: boolean = false;
179+
private _expansionState: ExpansionState = ExpansionState.NOT_CROPPED;
179180

180181
constructor(
181182
parentEditor: ICodeEditor,
@@ -357,8 +358,6 @@ export class InteractiveEditorWidget {
357358
this._store.dispose();
358359
this._ctxInputEmpty.reset();
359360
this._ctxMessageCropState.reset();
360-
console.log('inside of dispose');
361-
console.log('this._ctxMessageCropState.get() : ', this._ctxMessageCropState.get());
362361
}
363362

364363
get domNode(): HTMLElement {
@@ -431,34 +430,22 @@ export class InteractiveEditorWidget {
431430
this._onDidChangeHeight.fire();
432431
}
433432

434-
cropState() {
435-
if (this._elements.message.scrollHeight > this._elements.message.clientHeight) {
436-
return ExpansionState.CROPPED;
437-
} else {
438-
return ExpansionState.NOT_CROPPED;
439-
}
433+
expansionState() {
434+
return this._expansionState;
440435
}
441436

442437
updateMarkdownMessage(message: Node | undefined) {
443-
console.log('inside of update markdown message');
444438
this._elements.markdownMessage.classList.toggle('hidden', !message);
445439
if (!message) {
446-
this._ctxMessageCropState.reset();
447-
console.log('inside of case when message is undefined');
448-
console.log('this._ctxMessageCropState.get() : ', this._ctxMessageCropState.get());
449440
reset(this._elements.message);
441+
this._ctxMessageCropState.reset();
442+
this._expansionState = ExpansionState.NOT_CROPPED;
450443
} else {
451-
// reset the css to what it was before
452444
this._elements.message.style.webkitLineClamp = '3';
453445
reset(this._elements.message, message);
454-
console.log('message overflowing : ', this._elements.message.scrollHeight > this._elements.message.clientHeight);
455-
if (this._elements.message.scrollHeight > this._elements.message.clientHeight) {
456-
this._ctxMessageCropState.set(ExpansionState.CROPPED);
457-
} else {
458-
this._ctxMessageCropState.set(ExpansionState.NOT_CROPPED);
459-
}
460-
console.log('inside of the case when the message is defined');
461-
console.log('this._ctxMessageCropState.get() : ', this._ctxMessageCropState.get());
446+
const expansionState = this._elements.message.scrollHeight > this._elements.message.clientHeight ? ExpansionState.CROPPED : ExpansionState.NOT_CROPPED;
447+
this._ctxMessageCropState.set(expansionState);
448+
this._expansionState = expansionState;
462449
}
463450
this._onDidChangeHeight.fire();
464451
}
@@ -508,12 +495,9 @@ export class InteractiveEditorWidget {
508495
}
509496

510497
updateMarkdownMessageExpansionState(expansionState: ExpansionState) {
511-
console.log('inside of update markdown message expansion state');
512-
console.log('expansionState : ', expansionState);
513498
this._ctxMessageCropState.set(expansionState);
514-
console.log('this._ctxMessageCropState.get() : ', this._ctxMessageCropState.get());
499+
this._expansionState = expansionState;
515500
this._elements.message.style.webkitLineClamp = expansionState === ExpansionState.NOT_CROPPED ? 'none' : (expansionState === ExpansionState.EXPANDED ? '10' : '3');
516-
console.log('this._elements.message.style.webkitLineClamp : ', this._elements.message.style.webkitLineClamp);
517501
this._onDidChangeHeight.fire();
518502
}
519503

0 commit comments

Comments
 (0)