Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)

* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c

* remove files we don't want

* fix hygiene

* update distro

* update distro

* fix hygiene

* fix strict nulls

* distro

* distro

* fix tests

* fix tests

* add another edit

* fix viewlet icon

* fix azure dialog

* fix some padding

* fix more padding issues
This commit is contained in:
Anthony Dresser
2019-12-04 19:28:22 -08:00
committed by GitHub
parent a8818ab0df
commit f5ce7fb2a5
1507 changed files with 42813 additions and 27370 deletions

View File

@@ -3,5 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import './inputClipboardActions';
import './sleepResumeRepaintMinimap';
import './selectionClipboard';

View File

@@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import * as platform from 'vs/base/common/platform';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
if (platform.isMacintosh) {
// On the mac, cmd+x, cmd+c and cmd+v do not result in cut / copy / paste
// We therefore add a basic keybinding rule that invokes document.execCommand
// This is to cover <input>s...
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'execCut',
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
handler: bindExecuteCommand('cut'),
weight: 0,
when: undefined,
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'execCopy',
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
handler: bindExecuteCommand('copy'),
weight: 0,
when: undefined,
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'execPaste',
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
handler: bindExecuteCommand('paste'),
weight: 0,
when: undefined,
});
function bindExecuteCommand(command: 'cut' | 'copy' | 'paste') {
return () => {
document.execCommand(command);
};
}
}

View File

@@ -6,7 +6,7 @@
import { RunOnceScheduler } from 'vs/base/common/async';
import { Disposable } from 'vs/base/common/lifecycle';
import * as platform from 'vs/base/common/platform';
import { ICodeEditor, IEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
@@ -15,6 +15,10 @@ import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { EndOfLinePreference } from 'vs/editor/common/model';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { SelectionClipboardContributionID } from 'vs/workbench/contrib/codeEditor/browser/selectionClipboard';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export class SelectionClipboard extends Disposable implements IEditorContribution {
private static readonly SELECTION_LENGTH_LIMIT = 65536;
@@ -31,15 +35,6 @@ export class SelectionClipboard extends Disposable implements IEditorContributio
}
}));
this._register(editor.onMouseUp((e: IEditorMouseEvent) => {
if (!isEnabled) {
if (e.event.middleButton) {
// try to stop the upcoming paste
e.event.preventDefault();
}
}
}));
let setSelectionToClipboard = this._register(new RunOnceScheduler(() => {
if (!editor.hasModel()) {
return;
@@ -92,4 +87,25 @@ export class SelectionClipboard extends Disposable implements IEditorContributio
}
}
class SelectionClipboardPastePreventer implements IWorkbenchContribution {
constructor(
@IConfigurationService configurationService: IConfigurationService
) {
if (platform.isLinux) {
document.addEventListener('mouseup', (e) => {
if (e.button === 1) {
// middle button
const config = configurationService.getValue<{ selectionClipboard: boolean; }>('editor');
if (!config.selectionClipboard) {
// selection clipboard is disabled
// try to stop the upcoming paste
e.preventDefault();
}
}
});
}
}
}
registerEditorContribution(SelectionClipboardContributionID, SelectionClipboard);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(SelectionClipboardPastePreventer, LifecyclePhase.Ready);