Add setting to prevent copying empty selections

This commit is contained in:
Kai Wood
2016-10-23 14:04:14 +02:00
parent 47e2a84747
commit 954b93afe1
5 changed files with 26 additions and 2 deletions
@@ -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,
@@ -85,6 +85,7 @@ class ConfigClass implements IConfiguration {
suggestOnTriggerCharacters: true,
acceptSuggestionOnEnter: true,
snippetSuggestions: 'bottom',
emptySelectionClipboard: true,
tabCompletion: false,
wordBasedSuggestions: true,
suggestFontSize: 0,
+8
View File
@@ -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
@@ -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;
}
+5
View File
@@ -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;