Skip to content

Commit 66ce26e

Browse files
authored
Merge pull request microsoft#210566 from microsoft/tyriar/chat_padding
Have terminal chat align with xterm element
2 parents 7ec2211 + 4a1327e commit 66ce26e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import type { Terminal as RawXtermTerminal } from '@xterm/xterm';
7-
import { Dimension, IFocusTracker, trackFocus } from 'vs/base/browser/dom';
7+
import { Dimension, getActiveWindow, IFocusTracker, trackFocus } from 'vs/base/browser/dom';
88
import { Event } from 'vs/base/common/event';
99
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
1010
import { MicrotaskDelay } from 'vs/base/common/symbols';
@@ -100,11 +100,18 @@ export class TerminalChatWidget extends Disposable {
100100
}
101101

102102
private _doLayout(heightInPixel: number) {
103-
const width = Math.min(640, this._terminalElement.clientWidth - 12/* padding */ - 2/* border */ - Constants.HorizontalMargin);
103+
const xtermElement = this._xterm.raw!.element;
104+
if (!xtermElement) {
105+
return;
106+
}
107+
const style = getActiveWindow().getComputedStyle(xtermElement);
108+
const xtermPadding = parseInt(style.paddingLeft) + parseInt(style.paddingRight);
109+
const width = Math.min(640, xtermElement.clientWidth - 12/* padding */ - 2/* border */ - Constants.HorizontalMargin - xtermPadding);
104110
const height = Math.min(480, heightInPixel, this._getTerminalWrapperHeight() ?? Number.MAX_SAFE_INTEGER);
105111
if (width === 0 || height === 0) {
106112
return;
107113
}
114+
this._container.style.paddingLeft = style.paddingLeft;
108115
this._dimension = new Dimension(width, height);
109116
this._inlineChatWidget.layout(this._dimension);
110117

0 commit comments

Comments
 (0)