Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option scrollOnUserInput #4289

Merged
merged 2 commits into from Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser/Terminal.ts
Expand Up @@ -995,7 +995,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
const shouldIgnoreComposition = this.browser.isMac && this.options.macOptionIsMeta && event.altKey;

if (!shouldIgnoreComposition && !this._compositionHelper!.keydown(event)) {
if (this.buffer.ybase !== this.buffer.ydisp) {
if (this.options.scrollOnKeypress && this.buffer.ybase !== this.buffer.ydisp) {
this._bufferService.scrollToBottom();
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/CoreService.ts
Expand Up @@ -68,7 +68,7 @@ export class CoreService extends Disposable implements ICoreService {

// Input is being sent to the terminal, the terminal should focus the prompt.
const buffer = this._bufferService.buffer;
if (buffer.ybase !== buffer.ydisp) {
if (wasUserInput && this._optionsService.rawOptions.scrollOnKeypress && buffer.ybase !== buffer.ydisp) {
this._scrollToBottom!();
}

Expand Down
1 change: 1 addition & 0 deletions src/common/services/OptionsService.ts
Expand Up @@ -28,6 +28,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
linkHandler: null,
logLevel: 'info',
scrollback: 1000,
scrollOnKeypress: true,
scrollSensitivity: 1,
screenReaderMode: false,
smoothScrollDuration: 0,
Expand Down
3 changes: 2 additions & 1 deletion src/common/services/Services.ts
Expand Up @@ -87,7 +87,7 @@ export interface ICoreService {
* @param data The data that is being emitted.
* @param wasFromUser Whether the data originated from the user (as opposed to
JasonXJ marked this conversation as resolved.
Show resolved Hide resolved
* resulting from parsing incoming data). When true this will also:
* - Scroll to the bottom of the buffer.s
* - Scroll to the bottom of the buffer if option scrollOnKeypress is true.
* - Fire the `onUserInput` event (so selection can be cleared).
*/
triggerDataEvent(data: string, wasUserInput?: boolean): void;
Expand Down Expand Up @@ -243,6 +243,7 @@ export interface ITerminalOptions {
rows?: number;
screenReaderMode?: boolean;
scrollback?: number;
scrollOnKeypress?: boolean;
scrollSensitivity?: number;
smoothScrollDuration?: number;
tabStopWidth?: number;
Expand Down
6 changes: 6 additions & 0 deletions typings/xterm.d.ts
Expand Up @@ -193,6 +193,12 @@ declare module 'xterm' {
*/
scrollback?: number;

/**
* Whether to scroll to the bottom whenever a key is pressed. The default is
* true.
*/
scrollOnKeypress?: boolean;
JasonXJ marked this conversation as resolved.
Show resolved Hide resolved

/**
* The scrolling speed multiplier used for adjusting normal scrolling speed.
*/
Expand Down