mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
don't use ICodeEditor#getOffsetForColumn
for lines that aren't rendered (#208896)
fixes https://github.com/microsoft/vscode-copilot/issues/4828
This commit is contained in:
parent
2fbd5e0656
commit
631514ae58
|
@ -132,14 +132,14 @@ export class InlineChatZoneWidget extends ZoneWidget {
|
|||
const marginWithoutIndentation = info.glyphMarginWidth + info.decorationsWidth + info.lineNumbersWidth;
|
||||
this.container.style.marginLeft = `${marginWithoutIndentation}px`;
|
||||
|
||||
this._setWidgetMargins(position);
|
||||
super.show(position, this._computeHeightInLines());
|
||||
this._setWidgetMargins(position);
|
||||
this.widget.focus();
|
||||
}
|
||||
|
||||
override updatePositionAndHeight(position: Position): void {
|
||||
this._setWidgetMargins(position);
|
||||
super.updatePositionAndHeight(position, this._computeHeightInLines());
|
||||
this._setWidgetMargins(position);
|
||||
}
|
||||
|
||||
protected override _getWidth(info: EditorLayoutInfo): number {
|
||||
|
@ -157,12 +157,17 @@ export class InlineChatZoneWidget extends ZoneWidget {
|
|||
if (!viewModel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const visibleRange = viewModel.getCompletelyVisibleViewRange();
|
||||
const startLineVisibleRange = visibleRange.startLineNumber;
|
||||
const positionLine = position.lineNumber;
|
||||
let indentationLineNumber: number | undefined;
|
||||
let indentationLevel: number | undefined;
|
||||
for (let lineNumber = positionLine; lineNumber >= startLineVisibleRange; lineNumber--) {
|
||||
if (!visibleRange.containsPosition(position)) {
|
||||
// this is needed because `getOffsetForColumn` won't work when the position
|
||||
// isn't visible/rendered
|
||||
return 0;
|
||||
}
|
||||
|
||||
let indentationLevel = viewModel.getLineFirstNonWhitespaceColumn(position.lineNumber);
|
||||
let indentationLineNumber = position.lineNumber;
|
||||
for (let lineNumber = position.lineNumber; lineNumber >= visibleRange.startLineNumber; lineNumber--) {
|
||||
const currentIndentationLevel = viewModel.getLineFirstNonWhitespaceColumn(lineNumber);
|
||||
if (currentIndentationLevel !== 0) {
|
||||
indentationLineNumber = lineNumber;
|
||||
|
@ -170,7 +175,8 @@ export class InlineChatZoneWidget extends ZoneWidget {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return this.editor.getOffsetForColumn(indentationLineNumber ?? positionLine, indentationLevel ?? viewModel.getLineFirstNonWhitespaceColumn(positionLine));
|
||||
|
||||
return Math.max(0, this.editor.getOffsetForColumn(indentationLineNumber, indentationLevel)); // double-guard against invalie getOffsetForColumn-calls
|
||||
}
|
||||
|
||||
private _setWidgetMargins(position: Position): void {
|
||||
|
|
Loading…
Reference in a new issue