Skip to content

Commit 2e2d275

Browse files
authored
Merge pull request #4289 from JasonXJ/scroll-options
Add option scrollOnUserInput
2 parents 33bba35 + 9e84895 commit 2e2d275

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

src/browser/Terminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
995995
const shouldIgnoreComposition = this.browser.isMac && this.options.macOptionIsMeta && event.altKey;
996996

997997
if (!shouldIgnoreComposition && !this._compositionHelper!.keydown(event)) {
998-
if (this.buffer.ybase !== this.buffer.ydisp) {
998+
if (this.options.scrollOnUserInput && this.buffer.ybase !== this.buffer.ydisp) {
999999
this._bufferService.scrollToBottom();
10001000
}
10011001
return false;

src/common/services/CoreService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class CoreService extends Disposable implements ICoreService {
6868

6969
// Input is being sent to the terminal, the terminal should focus the prompt.
7070
const buffer = this._bufferService.buffer;
71-
if (buffer.ybase !== buffer.ydisp) {
71+
if (wasUserInput && this._optionsService.rawOptions.scrollOnUserInput && buffer.ybase !== buffer.ydisp) {
7272
this._scrollToBottom!();
7373
}
7474

src/common/services/OptionsService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
2828
linkHandler: null,
2929
logLevel: 'info',
3030
scrollback: 1000,
31+
scrollOnUserInput: true,
3132
scrollSensitivity: 1,
3233
screenReaderMode: false,
3334
smoothScrollDuration: 0,

src/common/services/Services.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export interface ICoreService {
8585
/**
8686
* Triggers the onData event in the public API.
8787
* @param data The data that is being emitted.
88-
* @param wasFromUser Whether the data originated from the user (as opposed to
88+
* @param wasUserInput Whether the data originated from the user (as opposed to
8989
* resulting from parsing incoming data). When true this will also:
90-
* - Scroll to the bottom of the buffer.s
90+
* - Scroll to the bottom of the buffer if option scrollOnUserInput is true.
9191
* - Fire the `onUserInput` event (so selection can be cleared).
9292
*/
9393
triggerDataEvent(data: string, wasUserInput?: boolean): void;
@@ -243,6 +243,7 @@ export interface ITerminalOptions {
243243
rows?: number;
244244
screenReaderMode?: boolean;
245245
scrollback?: number;
246+
scrollOnUserInput?: boolean;
246247
scrollSensitivity?: number;
247248
smoothScrollDuration?: number;
248249
tabStopWidth?: number;

typings/xterm.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ declare module 'xterm' {
193193
*/
194194
scrollback?: number;
195195

196+
/**
197+
* Whether to scroll to the bottom whenever there is some user input. The
198+
* default is true.
199+
*/
200+
scrollOnUserInput?: boolean;
201+
196202
/**
197203
* The scrolling speed multiplier used for adjusting normal scrolling speed.
198204
*/

0 commit comments

Comments
 (0)