diff --git a/src/vs/base/browser/ui/scrollbar/scrollableElement.ts b/src/vs/base/browser/ui/scrollbar/scrollableElement.ts index a6256deeba975c7f68177fda8f1aaf8f31c34c9a..9b31c847f708b0b44d2e86ea1062d579ec56e261 100644 --- a/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +++ b/src/vs/base/browser/ui/scrollbar/scrollableElement.ts @@ -281,6 +281,7 @@ export abstract class AbstractScrollableElement extends Widget { let massagedOptions = resolveOptions(newOptions); this._options.handleMouseWheel = massagedOptions.handleMouseWheel; this._options.mouseWheelScrollSensitivity = massagedOptions.mouseWheelScrollSensitivity; + this._options.fastScrollSensitivity = massagedOptions.fastScrollSensitivity; this._setListeningToMouseWheel(this._options.handleMouseWheel); if (!this._options.lazyRender) { @@ -340,6 +341,12 @@ export abstract class AbstractScrollableElement extends Widget { deltaY = 0; } + if (e.browserEvent && e.browserEvent.altKey) { + // fastScrolling + deltaX = deltaX * this._options.fastScrollSensitivity; + deltaY = deltaY * this._options.fastScrollSensitivity; + } + const futureScrollPosition = this._scrollable.getFutureScrollPosition(); let desiredScrollPosition: INewScrollPosition = {}; @@ -540,6 +547,7 @@ function resolveOptions(opts: ScrollableElementCreationOptions): ScrollableEleme alwaysConsumeMouseWheel: (typeof opts.alwaysConsumeMouseWheel !== 'undefined' ? opts.alwaysConsumeMouseWheel : false), scrollYToX: (typeof opts.scrollYToX !== 'undefined' ? opts.scrollYToX : false), mouseWheelScrollSensitivity: (typeof opts.mouseWheelScrollSensitivity !== 'undefined' ? opts.mouseWheelScrollSensitivity : 1), + fastScrollSensitivity: (typeof opts.fastScrollSensitivity !== 'undefined' ? opts.fastScrollSensitivity : 5), mouseWheelSmoothScroll: (typeof opts.mouseWheelSmoothScroll !== 'undefined' ? opts.mouseWheelSmoothScroll : true), arrowSize: (typeof opts.arrowSize !== 'undefined' ? opts.arrowSize : 11), diff --git a/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts b/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts index f8ed7e6fb11c8d419bc853ef80d47480e727f97f..7073bee8cb5929c1388677c007a0b4e02c63eca0 100644 --- a/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +++ b/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts @@ -50,6 +50,11 @@ export interface ScrollableElementCreationOptions { * Defaults to 1. */ mouseWheelScrollSensitivity?: number; + /** + * FastScrolling mulitplier speed when pressing `Alt` + * Defaults to 5. + */ + fastScrollSensitivity?: number; /** * Height for vertical arrows (top/bottom) and width for horizontal arrows (left/right). * Defaults to 11. @@ -107,6 +112,7 @@ export interface ScrollableElementCreationOptions { export interface ScrollableElementChangeOptions { handleMouseWheel?: boolean; mouseWheelScrollSensitivity?: number; + fastScrollSensitivity: number; } export interface ScrollableElementResolvedOptions { @@ -118,6 +124,7 @@ export interface ScrollableElementResolvedOptions { scrollYToX: boolean; alwaysConsumeMouseWheel: boolean; mouseWheelScrollSensitivity: number; + fastScrollSensitivity: number; mouseWheelSmoothScroll: boolean; arrowSize: number; listenOnDomNode: HTMLElement | null; diff --git a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts index df80f0b2087cd9e127cff981bef2324d5f28e8c0..8ead82c249aaed7e2a2c06d44df3d4b7e8c3fce8 100644 --- a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts +++ b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts @@ -48,6 +48,7 @@ export class EditorScrollbar extends ViewPart { handleMouseWheel: configScrollbarOpts.handleMouseWheel, arrowSize: configScrollbarOpts.arrowSize, mouseWheelScrollSensitivity: configScrollbarOpts.mouseWheelScrollSensitivity, + fastScrollSensitivity: configScrollbarOpts.fastScrollSensitivity, }; this.scrollbar = this._register(new SmoothScrollableElement(linesContent.domNode, scrollbarOptions, this._context.viewLayout.scrollable)); @@ -127,7 +128,8 @@ export class EditorScrollbar extends ViewPart { const editor = this._context.configuration.editor; let newOpts: ScrollableElementChangeOptions = { handleMouseWheel: editor.viewInfo.scrollbar.handleMouseWheel, - mouseWheelScrollSensitivity: editor.viewInfo.scrollbar.mouseWheelScrollSensitivity + mouseWheelScrollSensitivity: editor.viewInfo.scrollbar.mouseWheelScrollSensitivity, + fastScrollSensitivity: editor.viewInfo.scrollbar.fastScrollSensitivity }; this.scrollbar.updateOptions(newOpts); } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 8fa09be3b707835fedd61309552330a549f171d2..c7417e0f4bdba706821cc7670bac80db38d37cb1 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -429,6 +429,11 @@ const editorConfiguration: IConfigurationNode = { 'default': EDITOR_DEFAULTS.viewInfo.scrollbar.mouseWheelScrollSensitivity, 'markdownDescription': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }, + 'editor.fastScrollSensitivity': { + 'type': 'number', + 'default': EDITOR_DEFAULTS.viewInfo.scrollbar.fastScrollSensitivity, + 'markdownDescription': nls.localize('fastScrollSensitivity', "Scrolling speed mulitiplier when pressing `Alt`") + }, 'editor.multiCursorModifier': { 'type': 'string', 'enum': ['ctrlCmd', 'alt'], diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index ecdb1f39f452386fcd39c646df9c996a0a53d9b4..bef7f91cd4e08efdc611673d1361b6f4c4af673a 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -458,6 +458,11 @@ export interface IEditorOptions { * Defaults to 1. */ mouseWheelScrollSensitivity?: number; + /** + * FastScrolling mulitplier speed when pressing `Alt` + * Defaults to 5. + */ + fastScrollSensitivity?: number; /** * The modifier to be used to add multiple cursors with the mouse. * Defaults to 'alt' @@ -875,6 +880,7 @@ export interface InternalEditorScrollbarOptions { readonly verticalScrollbarSize: number; readonly verticalSliderSize: number; readonly mouseWheelScrollSensitivity: number; + readonly fastScrollSensitivity: number; } export interface InternalEditorMinimapOptions { @@ -1292,6 +1298,7 @@ export class InternalEditorOptions { && a.verticalScrollbarSize === b.verticalScrollbarSize && a.verticalSliderSize === b.verticalSliderSize && a.mouseWheelScrollSensitivity === b.mouseWheelScrollSensitivity + && a.fastScrollSensitivity === b.fastScrollSensitivity ); } @@ -1795,7 +1802,7 @@ export class EditorOptionsValidator { }; } - private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions | undefined, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number): InternalEditorScrollbarOptions { + private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions | undefined, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number, fastScrollSensitivity: number): InternalEditorScrollbarOptions { if (typeof opts !== 'object') { return defaults; } @@ -1818,7 +1825,8 @@ export class EditorOptionsValidator { verticalSliderSize: _clampedInt(opts.verticalSliderSize, verticalScrollbarSize, 0, 1000), handleMouseWheel: _boolean(opts.handleMouseWheel, defaults.handleMouseWheel), - mouseWheelScrollSensitivity: mouseWheelScrollSensitivity + mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, + fastScrollSensitivity: fastScrollSensitivity, }; } @@ -1965,7 +1973,12 @@ export class EditorOptionsValidator { // Disallow 0, as it would prevent/block scrolling mouseWheelScrollSensitivity = 1; } - const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity); + + let fastScrollSensitivity = _float(opts.fastScrollSensitivity, defaults.scrollbar.fastScrollSensitivity); + if (fastScrollSensitivity <= 0) { + fastScrollSensitivity = defaults.scrollbar.fastScrollSensitivity; + } + const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity, fastScrollSensitivity); const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap); return { @@ -2592,6 +2605,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { verticalSliderSize: 14, handleMouseWheel: true, mouseWheelScrollSensitivity: 1, + fastScrollSensitivity: 5, }, minimap: { enabled: true, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index e4b771b30d1d6377bb9def8fbe621179ab6ae7f2..8224e78e7f85818908697dbe419b9d7f29feab48 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2787,6 +2787,11 @@ declare namespace monaco.editor { * Defaults to 1. */ mouseWheelScrollSensitivity?: number; + /** + * FastScrolling mulitplier speed when pressing `Alt` + * Defaults to 5. + */ + fastScrollSensitivity?: number; /** * The modifier to be used to add multiple cursors with the mouse. * Defaults to 'alt' @@ -3149,6 +3154,7 @@ declare namespace monaco.editor { readonly verticalScrollbarSize: number; readonly verticalSliderSize: number; readonly mouseWheelScrollSensitivity: number; + readonly fastScrollSensitivity: number; } export interface InternalEditorMinimapOptions {