From 1bd78fbf8ab6783d4a99f689bddc622577c98c62 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 1 Jul 2016 14:13:30 +0200 Subject: [PATCH] Fixes #8282: Guard editor zooming with `editor.mouseWheelZoom` that is off by default until we implement a better story --- src/vs/editor/browser/controller/mouseHandler.ts | 3 +++ src/vs/editor/common/config/commonEditorConfig.ts | 6 ++++++ src/vs/editor/common/config/defaultConfig.ts | 1 + src/vs/editor/common/editorCommon.ts | 11 +++++++++++ src/vs/monaco.d.ts | 7 +++++++ 5 files changed, 28 insertions(+) diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index 59dd86ea512..a5cd4a25670 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -167,6 +167,9 @@ export class MouseHandler extends ViewEventHandler implements IDisposable { this.listenersToRemove.push(mouseEvents.onMouseDown(this.viewHelper.viewDomNode, (e) => this._onMouseDown(e))); let onMouseWheel = (browserEvent: MouseWheelEvent) => { + if (!this._context.configuration.editor.viewInfo.mouseWheelZoom) { + return; + } let e = new StandardMouseWheelEvent(browserEvent); if (e.browserEvent.ctrlKey) { let zoomLevel:number = EditorZoom.getZoomLevel(); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 05a6a75c964..272c2882aa7 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -195,6 +195,7 @@ class InternalEditorOptionsHelper { roundedSelection: toBoolean(opts.roundedSelection), overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3), cursorBlinking: opts.cursorBlinking, + mouseWheelZoom: toBoolean(opts.mouseWheelZoom), cursorStyle: cursorStyleFromString(opts.cursorStyle), hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler), scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine), @@ -671,6 +672,11 @@ let editorConfiguration:IConfigurationNode = { 'default': DefaultConfig.editor.cursorBlinking, 'description': nls.localize('cursorBlinking', "Controls the cursor blinking animation, accepted values are 'blink', 'visible', and 'hidden'") }, + 'editor.mouseWheelZoom': { + 'type': 'boolean', + 'default': DefaultConfig.editor.mouseWheelZoom, + 'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding Ctrl") + }, 'editor.cursorStyle' : { 'type': 'string', 'enum': ['block', 'line'], diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index 1fa86749274..a0085c9e4f1 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -58,6 +58,7 @@ class ConfigClass implements IConfiguration { }, overviewRulerLanes: 2, cursorBlinking: 'blink', + mouseWheelZoom: false, cursorStyle: 'line', fontLigatures: false, disableTranslate3d: false, diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 1dbfce4e16f..9c9e471ad13 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -263,6 +263,11 @@ export interface IEditorOptions { * Defaults to 'blink'. */ cursorBlinking?:string; + /** + * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. + * Defaults to false. + */ + mouseWheelZoom?: boolean; /** * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. @@ -611,6 +616,7 @@ export class InternalEditorViewOptions { roundedSelection:boolean; overviewRulerLanes:number; cursorBlinking:string; + mouseWheelZoom:boolean; cursorStyle:TextEditorCursorStyle; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; @@ -637,6 +643,7 @@ export class InternalEditorViewOptions { roundedSelection:boolean; overviewRulerLanes:number; cursorBlinking:string; + mouseWheelZoom:boolean; cursorStyle:TextEditorCursorStyle; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; @@ -659,6 +666,7 @@ export class InternalEditorViewOptions { this.roundedSelection = Boolean(source.roundedSelection); this.overviewRulerLanes = source.overviewRulerLanes|0; this.cursorBlinking = String(source.cursorBlinking); + this.mouseWheelZoom = Boolean(source.mouseWheelZoom); this.cursorStyle = source.cursorStyle|0; this.hideCursorInOverviewRuler = Boolean(source.hideCursorInOverviewRuler); this.scrollBeyondLastLine = Boolean(source.scrollBeyondLastLine); @@ -715,6 +723,7 @@ export class InternalEditorViewOptions { && this.roundedSelection === other.roundedSelection && this.overviewRulerLanes === other.overviewRulerLanes && this.cursorBlinking === other.cursorBlinking + && this.mouseWheelZoom === other.mouseWheelZoom && this.cursorStyle === other.cursorStyle && this.hideCursorInOverviewRuler === other.hideCursorInOverviewRuler && this.scrollBeyondLastLine === other.scrollBeyondLastLine @@ -744,6 +753,7 @@ export class InternalEditorViewOptions { roundedSelection: this.roundedSelection !== newOpts.roundedSelection, overviewRulerLanes: this.overviewRulerLanes !== newOpts.overviewRulerLanes, cursorBlinking: this.cursorBlinking !== newOpts.cursorBlinking, + mouseWheelZoom: this.mouseWheelZoom !== newOpts.mouseWheelZoom, cursorStyle: this.cursorStyle !== newOpts.cursorStyle, hideCursorInOverviewRuler: this.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler, scrollBeyondLastLine: this.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine, @@ -777,6 +787,7 @@ export interface IViewConfigurationChangedEvent { roundedSelection: boolean; overviewRulerLanes: boolean; cursorBlinking: boolean; + mouseWheelZoom: boolean; cursorStyle: boolean; hideCursorInOverviewRuler: boolean; scrollBeyondLastLine: boolean; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index a0ae15d76d4..ad77581eec1 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1117,6 +1117,11 @@ declare module monaco.editor { * Defaults to 'blink'. */ cursorBlinking?: string; + /** + * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. + * Defaults to false. + */ + mouseWheelZoom?: boolean; /** * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. @@ -1362,6 +1367,7 @@ declare module monaco.editor { roundedSelection: boolean; overviewRulerLanes: number; cursorBlinking: string; + mouseWheelZoom: boolean; cursorStyle: TextEditorCursorStyle; hideCursorInOverviewRuler: boolean; scrollBeyondLastLine: boolean; @@ -1386,6 +1392,7 @@ declare module monaco.editor { roundedSelection: boolean; overviewRulerLanes: boolean; cursorBlinking: boolean; + mouseWheelZoom: boolean; cursorStyle: boolean; hideCursorInOverviewRuler: boolean; scrollBeyondLastLine: boolean; -- GitLab