Skip to content

Commit e4126d8

Browse files
committed
using instead the position, instead of the selection
1 parent 72d20c9 commit e4126d8

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export class InteractiveEditorController implements IEditorContribution {
269269
this._zone.value.widget.placeholder = this._getPlaceholderText();
270270
this._zone.value.widget.value = this._activeSession.lastInput ?? '';
271271
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);
272+
this._zone.value.show(this._activeSession.wholeRange.value.getEndPosition());
273273
this._zone.value.widget.preferredExpansionState = this._activeSession.lastExpansionState;
274274

275275
this._sessionStore.add(this._editor.onDidChangeModel((e) => {
@@ -359,7 +359,7 @@ export class InteractiveEditorController implements IEditorContribution {
359359
assertType(this._activeSession);
360360

361361
this._zone.value.widget.placeholder = this._getPlaceholderText();
362-
this._zone.value.show(this._activeSession.wholeRange.value);
362+
this._zone.value.show(this._activeSession.wholeRange.value.getEndPosition());
363363

364364
if (options?.message) {
365365
this._zone.value.widget.value = options?.message;

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -787,32 +787,33 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
787787
super._relayout(this._computeHeightInLines());
788788
}
789789

790-
override show(selectionRange: Range): void {
791-
super.show(selectionRange.getEndPosition(), this._computeHeightInLines());
790+
override show(position: Position): void {
791+
super.show(position, this._computeHeightInLines());
792792
this.widget.focus();
793793
this._ctxVisible.set(true);
794-
this._setMargins(selectionRange);
794+
this._setMargins(position);
795795
}
796796

797-
private _setMargins(selectionRange: Range): void {
798-
const info = this.editor.getLayoutInfo();
799-
const startLineNumber = selectionRange.getStartPosition().lineNumber;
800-
const endLineNumber = selectionRange.getEndPosition().lineNumber;
797+
private _setMargins(position: Position): void {
801798
const viewModel = this.editor._getViewModel();
802799
if (!viewModel) {
803800
return;
804801
}
802+
const visibleRange = viewModel.getCompletelyVisibleViewRange();
803+
const startLineVisibleRange = visibleRange.startLineNumber;
804+
const positionLine = position.lineNumber;
805805
let indentationLineNumber;
806806
let indentationLevel;
807-
for (let lineNumber = endLineNumber; lineNumber >= startLineNumber; lineNumber--) {
807+
for (let lineNumber = positionLine; lineNumber >= startLineVisibleRange; lineNumber--) {
808808
const currentIndentationLevel = viewModel.getLineFirstNonWhitespaceColumn(lineNumber);
809809
if (currentIndentationLevel !== 0) {
810810
indentationLineNumber = lineNumber;
811811
indentationLevel = currentIndentationLevel;
812812
break;
813813
}
814814
}
815-
this._indentationWidth = this.editor.getOffsetForColumn(indentationLineNumber ?? endLineNumber, indentationLevel ?? viewModel.getLineFirstNonWhitespaceColumn(endLineNumber));
815+
this._indentationWidth = this.editor.getOffsetForColumn(indentationLineNumber ?? positionLine, indentationLevel ?? viewModel.getLineFirstNonWhitespaceColumn(positionLine));
816+
const info = this.editor.getLayoutInfo();
816817
const marginWithoutIndentation = info.glyphMarginWidth + info.decorationsWidth + info.lineNumbersWidth;
817818
const marginWithIndentation = marginWithoutIndentation + this._indentationWidth;
818819
const isEnoughAvailableSpaceWithIndentation = this._availableSpaceGivenIndentation() > 400;

0 commit comments

Comments
 (0)