From f5aa82d2bc63eeab96b16f071f0183d727c971aa Mon Sep 17 00:00:00 2001 From: rebornix Date: Mon, 20 Feb 2017 16:14:00 -0800 Subject: [PATCH] put drag and drop behind an option and turn it off by default --- 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 +++++++ src/vs/platform/telemetry/common/telemetryUtils.ts | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index 7122c6686fc..03d1f6a36fb 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -429,7 +429,8 @@ class MouseDownOperation extends Disposable { // Overwrite the detail of the MouseEvent, as it will be sent out in an event and contributions might rely on it. e.detail = this._mouseState.count; - if (!this._mouseState.altKey // we don't support multiple mouse + if (this._context.configuration.editor.enableDragAndDrop + && !this._mouseState.altKey // we don't support multiple mouse && e.detail < 2 // only single click on a selection can work && !this._isActive // the mouse is not down yet && !this._currentSelection.isEmpty() // we don't drag single cursor diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index b2cc9668760..4ee5af6d9b4 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -317,6 +317,7 @@ class InternalEditorOptionsHelper { autoClosingBrackets: toBoolean(opts.autoClosingBrackets), useTabStops: toBoolean(opts.useTabStops), tabFocusMode: tabFocusMode, + enableDragAndDrop: toBoolean(opts.enableDragAndDrop), layoutInfo: layoutInfo, fontInfo: fontInfo, viewInfo: viewInfo, @@ -842,6 +843,11 @@ const editorConfiguration: IConfigurationNode = { 'default': false, 'description': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting Escape.") }, + 'editor.enableDragAndDrop': { + 'type': 'boolean', + 'default': DefaultConfig.editor.enableDragAndDrop, + 'description': nls.localize('enableDragAndDrop', "Controls if the editor should allow to move selections via drag and drop.") + }, 'diffEditor.renderSideBySide': { 'type': 'boolean', 'default': true, diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index ea933198d4b..0ae32298209 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -106,6 +106,7 @@ class ConfigClass implements IConfiguration { renderLineHighlight: 'line', useTabStops: true, matchBrackets: true, + enableDragAndDrop: false, fontFamily: ( platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY) diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 604e790b80c..6cc68c906b2 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -419,6 +419,11 @@ export interface IEditorOptions { * Defaults to false. */ formatOnPaste?: boolean; + /** + * Controls if the editor should allow to move selections via drag and drop. + * Defaults to false. + */ + enableDragAndDrop?: boolean; /** * Enable the suggestion box to pop-up on trigger characters. * Defaults to true. @@ -1068,6 +1073,7 @@ export class InternalEditorOptions { readonly autoClosingBrackets: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; + readonly enableDragAndDrop: boolean; // ---- grouped options readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; @@ -1085,6 +1091,7 @@ export class InternalEditorOptions { autoClosingBrackets: boolean; useTabStops: boolean; tabFocusMode: boolean; + enableDragAndDrop: boolean; layoutInfo: EditorLayoutInfo; fontInfo: FontInfo; viewInfo: InternalEditorViewOptions; @@ -1097,6 +1104,7 @@ export class InternalEditorOptions { this.autoClosingBrackets = Boolean(source.autoClosingBrackets); this.useTabStops = Boolean(source.useTabStops); this.tabFocusMode = Boolean(source.tabFocusMode); + this.enableDragAndDrop = Boolean(source.enableDragAndDrop); this.layoutInfo = source.layoutInfo.clone(); this.fontInfo = source.fontInfo.clone(); this.viewInfo = source.viewInfo.clone(); @@ -1115,6 +1123,7 @@ export class InternalEditorOptions { && this.autoClosingBrackets === other.autoClosingBrackets && this.useTabStops === other.useTabStops && this.tabFocusMode === other.tabFocusMode + && this.enableDragAndDrop === other.enableDragAndDrop && this.layoutInfo.equals(other.layoutInfo) && this.fontInfo.equals(other.fontInfo) && this.viewInfo.equals(other.viewInfo) @@ -1134,6 +1143,7 @@ export class InternalEditorOptions { autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets), useTabStops: (this.useTabStops !== newOpts.useTabStops), tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode), + enableDragAndDrop: (this.enableDragAndDrop !== newOpts.enableDragAndDrop), layoutInfo: (!this.layoutInfo.equals(newOpts.layoutInfo)), fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), viewInfo: this.viewInfo.createChangeEvent(newOpts.viewInfo), @@ -1160,6 +1170,7 @@ export interface IConfigurationChangedEvent { readonly autoClosingBrackets: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; + readonly enableDragAndDrop: boolean; readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: IViewConfigurationChangedEvent; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index fab613bd9b7..d88a73dedb9 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1340,6 +1340,11 @@ declare module monaco.editor { * Defaults to false. */ formatOnPaste?: boolean; + /** + * Controls if the editor should allow to move selections via drag and drop. + * Defaults to false. + */ + enableDragAndDrop?: boolean; /** * Enable the suggestion box to pop-up on trigger characters. * Defaults to true. @@ -1599,6 +1604,7 @@ declare module monaco.editor { readonly autoClosingBrackets: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; + readonly enableDragAndDrop: boolean; readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; @@ -1616,6 +1622,7 @@ declare module monaco.editor { readonly autoClosingBrackets: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; + readonly enableDragAndDrop: boolean; readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: IViewConfigurationChangedEvent; diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index 5f1e425dd43..7c2818b001c 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -213,6 +213,7 @@ const configurationValueWhitelist = [ 'editor.formatOnType', 'editor.formatOnSave', 'editor.formatOnPaste', + 'editor.enableDragAndDrop', 'window.openFilesInNewWindow', 'javascript.validate.enable', 'editor.mouseWheelZoom', -- GitLab