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

Fix console scrolling for web #5439

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { KeyboardEvent, MouseEvent, UIEvent, useCallback, useEffect, useLayoutEf
import * as nls from 'vs/nls';
import * as DOM from 'vs/base/browser/dom';
import { generateUuid } from 'vs/base/common/uuid';
import { isMacintosh } from 'vs/base/common/platform';
import { isMacintosh, isWeb } from 'vs/base/common/platform';
import { PixelRatio } from 'vs/base/browser/pixelRatio';
import { disposableTimeout } from 'vs/base/common/async';
import { DisposableStore } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -566,6 +566,16 @@ export const ConsoleInstance = (props: ConsoleInstanceProps) => {
}
};

/**
* Fixes the scroll event override that VS Code drops to prevent gesture navigation.
* @param e A WheelEvent<HTMLDivElement>
*/
const scrollOverrideHandler = (e: WheelEvent<HTMLDivElement>) => {
if (isWeb) {
consoleInstanceRef.current.scrollBy(e.deltaX, e.deltaY);
}
};

/**
* onWheel event handler.
* @param e A WheelEvent<HTMLDivElement> that describes a user interaction with the wheel.
Expand Down Expand Up @@ -608,7 +618,11 @@ export const ConsoleInstance = (props: ConsoleInstanceProps) => {
onMouseDown={mouseDownHandler}
onWheel={wheelHandler}
onScroll={scrollHandler}>
<div ref={consoleInstanceContainerRef} className='console-instance-container'>
<div
ref={consoleInstanceContainerRef}
className='console-instance-container'
onWheel={scrollOverrideHandler}
>
<ConsoleInstanceItems
positronConsoleInstance={props.positronConsoleInstance}
editorFontInfo={editorFontInfo}
Expand Down