Skip to content

Commit d3692b2

Browse files
committed
changes from review
1 parent 09b41be commit d3692b2

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
@@ -725,6 +716,7 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
725716
private readonly _ctxVisible: IContextKey<boolean>;
726717
private readonly _ctxCursorPosition: IContextKey<'above' | 'below' | ''>;
727718
private _dimension?: Dimension;
719+
private _indentationWidth: number = 0;
728720

729721
constructor(
730722
editor: ICodeEditor,
@@ -773,7 +765,7 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
773765

774766
const info = this.editor.getLayoutInfo();
775767
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));
768+
const width = Math.min(maxWidth, info.contentWidth - (info.glyphMarginWidth + info.decorationsWidth + this._indentationWidth));
777769
this._dimension = new Dimension(width, heightInPixel);
778770
this.widget.domNode.style.width = `${width}px`;
779771
this.widget.layout(this._dimension);
@@ -803,18 +795,21 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
803795
const startLineNumber = selectionRange.getStartPosition().lineNumber;
804796
const endLineNumber = selectionRange.getEndPosition().lineNumber;
805797
const viewModel = this.editor._getViewModel();
806-
let indentationLineNumber = endLineNumber;
807-
let indentationLevel = viewModel?.getLineFirstNonWhitespaceColumn(endLineNumber);
798+
if (!viewModel) {
799+
return;
800+
}
801+
let indentationLineNumber;
802+
let indentationLevel;
808803
for (let lineNumber = endLineNumber; lineNumber >= startLineNumber; lineNumber--) {
809-
const currentIndentationLevel = viewModel?.getLineFirstNonWhitespaceColumn(lineNumber);
810-
if (currentIndentationLevel && currentIndentationLevel !== 0) {
804+
const currentIndentationLevel = viewModel.getLineFirstNonWhitespaceColumn(lineNumber);
805+
if (currentIndentationLevel !== 0) {
811806
indentationLineNumber = lineNumber;
812807
indentationLevel = currentIndentationLevel;
813808
break;
814809
}
815810
}
816-
this.widget.indentationWidth = (indentationLevel ? this.editor.getOffsetForColumn(indentationLineNumber, indentationLevel) : 0);
817-
const spaceLeft = info.lineNumbersWidth + info.glyphMarginWidth + info.decorationsWidth + this.widget.indentationWidth;
811+
this._indentationWidth = this.editor.getOffsetForColumn(indentationLineNumber ?? endLineNumber, indentationLevel ?? viewModel.getLineFirstNonWhitespaceColumn(endLineNumber));
812+
const spaceLeft = info.lineNumbersWidth + info.glyphMarginWidth + info.decorationsWidth + this._indentationWidth;
818813
const spaceRight = info.minimap.minimapWidth + info.verticalScrollbarWidth;
819814
this.widget.domNode.style.marginLeft = `${spaceLeft}px`;
820815
this.widget.domNode.style.marginRight = `${spaceRight}px`;

0 commit comments

Comments
 (0)