Skip to content

Commit 46e113a

Browse files
authored
Merge pull request microsoft#199561 from microsoft/tyriar/199276
Cap term sticky scroll to 40% of viewport
2 parents 0aff17a + 3614c25 commit 46e113a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ const terminalConfiguration: IConfigurationNode = {
633633
// scope: ConfigurationScope.APPLICATION
634634
},
635635
[TerminalSettingId.StickyScrollMaxLineCount]: {
636-
markdownDescription: localize('terminal.integrated.stickyScroll.maxLineCount', "Defines the maximum number of sticky lines to show."),
636+
markdownDescription: localize('terminal.integrated.stickyScroll.maxLineCount', "Defines the maximum number of sticky lines to show. Sticky scroll lines will never exceed 40% of the viewport regardless of this setting."),
637637
type: 'number',
638638
default: 5,
639639
minimum: 1,

src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const enum CssClasses {
3939
Visible = 'visible'
4040
}
4141

42+
const enum Constants {
43+
StickyScrollPercentageCap = 0.4
44+
}
45+
4246
export class TerminalStickyScrollOverlay extends Disposable {
4347
private _stickyScrollOverlay?: RawXtermTerminal;
4448
private _serializeAddon?: SerializeAddonType;
@@ -54,7 +58,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
5458
private _refreshListeners = this._register(new MutableDisposable());
5559

5660
private _state: OverlayState = OverlayState.Off;
57-
private _maxLineCount: number = 5;
61+
private _rawMaxLineCount: number = 5;
5862

5963
constructor(
6064
private readonly _instance: ITerminalInstance,
@@ -81,7 +85,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
8185
// React to configuration changes
8286
this._register(Event.runAndSubscribe(configurationService.onDidChangeConfiguration, e => {
8387
if (!e || e.affectsConfiguration(TerminalSettingId.StickyScrollMaxLineCount)) {
84-
this._maxLineCount = configurationService.getValue(TerminalSettingId.StickyScrollMaxLineCount);
88+
this._rawMaxLineCount = configurationService.getValue(TerminalSettingId.StickyScrollMaxLineCount);
8589
}
8690
}));
8791

@@ -249,7 +253,8 @@ export class TerminalStickyScrollOverlay extends Disposable {
249253
// partial line can be drawn on the top.
250254
const isPartialCommand = !('getOutput' in command);
251255
const rowOffset = !isPartialCommand && command.endMarker ? Math.max(buffer.viewportY - command.endMarker.line + 1, 0) : 0;
252-
const stickyScrollLineCount = Math.min(promptRowCount + commandRowCount - 1, this._maxLineCount) - rowOffset;
256+
const maxLineCount = Math.min(this._rawMaxLineCount, Math.floor(xterm.rows * Constants.StickyScrollPercentageCap));
257+
const stickyScrollLineCount = Math.min(promptRowCount + commandRowCount - 1, maxLineCount) - rowOffset;
253258

254259
// Hide sticky scroll if it's currently on a line that contains it
255260
if (buffer.viewportY === stickyScrollLineStart) {

0 commit comments

Comments
 (0)