diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index a9040b359bd32cf9d83691674f7d807dcbc52fe5..d25e520f940ad143e9f98ed289315c98fd560724 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -310,6 +310,7 @@ class InternalEditorOptionsHelper { suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters), acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter), snippetSuggestions: opts.snippetSuggestions, + emptySelectionClipboard: opts.emptySelectionClipboard, tabCompletion: opts.tabCompletion, wordBasedSuggestions: opts.wordBasedSuggestions, suggestFontSize: opts.suggestFontSize, @@ -762,6 +763,11 @@ let editorConfiguration: IConfigurationNode = { 'default': DefaultConfig.editor.snippetSuggestions, 'description': nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.") }, + 'editor.emptySelectionClipboard': { + 'type': 'boolean', + 'default': DefaultConfig.editor.emptySelectionClipboard, + 'description': nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.") + }, 'editor.wordBasedSuggestions': { 'type': 'boolean', 'default': DefaultConfig.editor.wordBasedSuggestions, diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index f2d1306259c6f07f7fcb04033f7d201a09b7e9e8..9225405950fa11a64f576dd5e5fa8cbeacf7ed88 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -85,6 +85,7 @@ class ConfigClass implements IConfiguration { suggestOnTriggerCharacters: true, acceptSuggestionOnEnter: true, snippetSuggestions: 'bottom', + emptySelectionClipboard: true, tabCompletion: false, wordBasedSuggestions: true, suggestFontSize: 0, diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 3b75519152f1dd4570abd8e9879f27802e740647..00f81e68f82dfe24ef52d62495107767d392a8d6 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -402,6 +402,10 @@ export interface IEditorOptions { * Enable snippet suggestions. Default to 'true'. */ snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none'; + /** + * Copying without a selection copies the current line. + */ + emptySelectionClipboard?: boolean; /** * Enable tab completion. Defaults to 'false' */ @@ -862,6 +866,7 @@ export class EditorContribOptions { readonly suggestOnTriggerCharacters: boolean; readonly acceptSuggestionOnEnter: boolean; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly emptySelectionClipboard: boolean; readonly tabCompletion: boolean; readonly wordBasedSuggestions: boolean; readonly suggestFontSize: number; @@ -885,6 +890,7 @@ export class EditorContribOptions { suggestOnTriggerCharacters: boolean; acceptSuggestionOnEnter: boolean; snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + emptySelectionClipboard: boolean; tabCompletion: boolean; wordBasedSuggestions: boolean; suggestFontSize: number; @@ -904,6 +910,7 @@ export class EditorContribOptions { this.suggestOnTriggerCharacters = Boolean(source.suggestOnTriggerCharacters); this.acceptSuggestionOnEnter = Boolean(source.acceptSuggestionOnEnter); this.snippetSuggestions = source.snippetSuggestions; + this.emptySelectionClipboard = source.emptySelectionClipboard; this.tabCompletion = source.tabCompletion; this.wordBasedSuggestions = source.wordBasedSuggestions; this.suggestFontSize = source.suggestFontSize; @@ -929,6 +936,7 @@ export class EditorContribOptions { && this.suggestOnTriggerCharacters === other.suggestOnTriggerCharacters && this.acceptSuggestionOnEnter === other.acceptSuggestionOnEnter && this.snippetSuggestions === other.snippetSuggestions + && this.emptySelectionClipboard === other.emptySelectionClipboard && this.tabCompletion === other.tabCompletion && this.wordBasedSuggestions === other.wordBasedSuggestions && this.suggestFontSize === other.suggestFontSize diff --git a/src/vs/editor/contrib/clipboard/browser/clipboard.ts b/src/vs/editor/contrib/clipboard/browser/clipboard.ts index 34bbd1abd101fe7861520178465b903e697822e3..1714c171e3c88ded5080fd270fec8f3589c64477 100644 --- a/src/vs/editor/contrib/clipboard/browser/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/browser/clipboard.ts @@ -73,7 +73,9 @@ class ExecCommandCutAction extends ExecCommandAction { } public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void { - if (!browser.enableEmptySelectionClipboard && editor.getSelection().isEmpty()) { + var enableEmptySelectionClipboard = editor.getConfiguration().contribInfo.emptySelectionClipboard && browser.enableEmptySelectionClipboard; + + if (!enableEmptySelectionClipboard && editor.getSelection().isEmpty()) { return; } @@ -103,7 +105,9 @@ class ExecCommandCopyAction extends ExecCommandAction { } public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void { - if (!browser.enableEmptySelectionClipboard && editor.getSelection().isEmpty()) { + var enableEmptySelectionClipboard = editor.getConfiguration().contribInfo.emptySelectionClipboard && browser.enableEmptySelectionClipboard; + + if (!enableEmptySelectionClipboard && editor.getSelection().isEmpty()) { return; } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 2f7793222e6014718f612a12798870bd771740ea..740547ab351285c0b3a457849d5451bb93992d66 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1262,6 +1262,10 @@ declare module monaco.editor { * Enable snippet suggestions. Default to 'true'. */ snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none'; + /** + * Copying without a selection copies the current line. + */ + emptySelectionClipboard?: boolean; /** * Enable tab completion. Defaults to 'false' */ @@ -1458,6 +1462,7 @@ declare module monaco.editor { readonly suggestOnTriggerCharacters: boolean; readonly acceptSuggestionOnEnter: boolean; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly emptySelectionClipboard: boolean; readonly tabCompletion: boolean; readonly wordBasedSuggestions: boolean; readonly suggestFontSize: number;