Skip to content

Commit 13e2176

Browse files
committed
resetting the code as it was
1 parent 169c0ed commit 13e2176

File tree

2 files changed

+11
-51
lines changed

2 files changed

+11
-51
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ export class InteractiveEditorController implements IEditorContribution {
249249
return State.INIT_UI;
250250
}
251251

252-
private _showWidget(): void {
253-
assertType(this._activeSession);
254-
const selectionRange = this._activeSession.wholeRange.value;
255-
const position = this._strategy?.getWidgetPosition(selectionRange);
256-
this._zone.value.showWidget(selectionRange, position);
257-
}
258-
259252
private async [State.INIT_UI](options: InteractiveEditorRunOptions | undefined): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {
260253
assertType(this._activeSession);
261254

@@ -276,9 +269,8 @@ export class InteractiveEditorController implements IEditorContribution {
276269
this._zone.value.widget.placeholder = this._getPlaceholderText();
277270
this._zone.value.widget.value = this._activeSession.lastInput ?? '';
278271
this._zone.value.widget.updateInfo(this._activeSession.session.message ?? localize('welcome.1', "AI-generated code may be incorrect"));
272+
this._zone.value.show(this._activeSession.wholeRange.value.getEndPosition());
279273
this._zone.value.widget.preferredExpansionState = this._activeSession.lastExpansionState;
280-
console.log('before show of the init ui');
281-
this._showWidget();
282274

283275
this._sessionStore.add(this._editor.onDidChangeModel((e) => {
284276
const msg = this._activeSession?.lastExchange
@@ -367,9 +359,7 @@ export class InteractiveEditorController implements IEditorContribution {
367359
assertType(this._activeSession);
368360

369361
this._zone.value.widget.placeholder = this._getPlaceholderText();
370-
371-
console.log('before show of wait_for_input');
372-
this._showWidget();
362+
this._zone.value.show(this._activeSession.wholeRange.value.getEndPosition());
373363

374364
if (options?.message) {
375365
this._zone.value.widget.value = options?.message;

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

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vs/editor/br
2626
import { HiddenItemStrategy, MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
2727
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
2828
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
29-
import { Position } from 'vs/editor/common/core/position';
29+
import { IPosition, Position } from 'vs/editor/common/core/position';
3030
import { DEFAULT_FONT_FAMILY } from 'vs/workbench/browser/style';
3131
import { DropdownWithDefaultActionViewItem, IMenuEntryActionViewItemOptions, MenuEntryActionViewItem, createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
3232
import { CompletionItem, CompletionItemInsertTextRule, CompletionItemKind, CompletionItemProvider, CompletionList, ProviderResult, TextEdit } from 'vs/editor/common/languages';
@@ -183,7 +183,6 @@ export class InteractiveEditorWidget {
183183
private _isLayouting: boolean = false;
184184
private _preferredExpansionState: ExpansionState | undefined;
185185
private _expansionState: ExpansionState = ExpansionState.NOT_CROPPED;
186-
private _indentationWidth: number = 0;
187186

188187
constructor(
189188
private readonly parentEditor: ICodeEditor,
@@ -465,14 +464,6 @@ export class InteractiveEditorWidget {
465464
this._preferredExpansionState = expansionState;
466465
}
467466

468-
set indentationWidth(indentationWidth: number) {
469-
this._indentationWidth = indentationWidth;
470-
}
471-
472-
get indentationWidth(): number {
473-
return this._indentationWidth;
474-
}
475-
476467
updateMarkdownMessage(message: Node | undefined) {
477468
this._elements.markdownMessage.classList.toggle('hidden', !message);
478469
let expansionState: ExpansionState;
@@ -772,9 +763,14 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
772763
protected override _doLayout(heightInPixel: number): void {
773764

774765
const info = this.editor.getLayoutInfo();
766+
const spaceLeft = info.lineNumbersWidth + info.glyphMarginWidth + info.decorationsWidth;
767+
const spaceRight = info.minimap.minimapWidth + info.verticalScrollbarWidth;
768+
775769
const maxWidth = !this.widget.showsAnyPreview() ? 640 : Number.MAX_SAFE_INTEGER;
776-
const width = Math.min(maxWidth, info.contentWidth - (info.glyphMarginWidth + info.decorationsWidth + this.widget.indentationWidth));
770+
const width = Math.min(maxWidth, info.contentWidth - (info.glyphMarginWidth + info.decorationsWidth));
777771
this._dimension = new Dimension(width, heightInPixel);
772+
this.widget.domNode.style.marginLeft = `${spaceLeft}px`;
773+
this.widget.domNode.style.marginRight = `${spaceRight}px`;
778774
this.widget.domNode.style.width = `${width}px`;
779775
this.widget.layout(this._dimension);
780776
}
@@ -791,36 +787,10 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
791787
super._relayout(this._computeHeightInLines());
792788
}
793789

794-
showWidget(selectionRange: Range, position: Position | undefined): void {
795-
console.log('selectionRange : ', selectionRange);
796-
console.log('position : ', position);
797-
798-
super.show(position ?? selectionRange.getEndPosition(), this._computeHeightInLines());
790+
override show(where: IPosition): void {
791+
super.show(where, this._computeHeightInLines());
799792
this.widget.focus();
800793
this._ctxVisible.set(true);
801-
this._setMargins(selectionRange);
802-
}
803-
804-
private _setMargins(selectionRange: Range): void {
805-
const info = this.editor.getLayoutInfo();
806-
const startLineNumber = selectionRange.getStartPosition().lineNumber;
807-
const endLineNumber = selectionRange.getEndPosition().lineNumber;
808-
const viewModel = this.editor._getViewModel();
809-
let indentationLineNumber = endLineNumber;
810-
let indentationLevel = viewModel?.getLineFirstNonWhitespaceColumn(endLineNumber);
811-
for (let lineNumber = endLineNumber; lineNumber >= startLineNumber; lineNumber--) {
812-
const currentIndentationLevel = viewModel?.getLineFirstNonWhitespaceColumn(lineNumber);
813-
if (currentIndentationLevel && currentIndentationLevel !== 0) {
814-
indentationLineNumber = lineNumber;
815-
indentationLevel = currentIndentationLevel;
816-
break;
817-
}
818-
}
819-
this.widget.indentationWidth = (indentationLevel ? this.editor.getOffsetForColumn(indentationLineNumber, indentationLevel) : 0);
820-
const spaceLeft = info.lineNumbersWidth + info.glyphMarginWidth + info.decorationsWidth + this.widget.indentationWidth;
821-
const spaceRight = info.minimap.minimapWidth + info.verticalScrollbarWidth;
822-
this.widget.domNode.style.marginLeft = `${spaceLeft}px`;
823-
this.widget.domNode.style.marginRight = `${spaceRight}px`;
824794
}
825795

826796
override hide(): void {

0 commit comments

Comments
 (0)