Merge from vscode 313ede61cbad8f9dc748907b3384e059ddddb79a (#7436)

* Merge from vscode 313ede61cbad8f9dc748907b3384e059ddddb79a

* fix strict null checks
This commit is contained in:
Anthony Dresser
2019-09-30 23:35:45 -07:00
committed by GitHub
parent 6ab03053a0
commit 084524cd2d
196 changed files with 2927 additions and 2547 deletions

View File

@@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IAction, Action } from 'vs/base/common/actions';
import { localize } from 'vs/nls';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Disposable } from 'vs/base/common/lifecycle';
import { EventHelper } from 'vs/base/browser/dom';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { Registry } from 'vs/platform/registry/common/platform';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { isNative } from 'vs/base/common/platform';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
export class TextInputActionsProvider extends Disposable implements IWorkbenchContribution {
private textInputActions: IAction[] = [];
constructor(
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IClipboardService private readonly clipboardService: IClipboardService
) {
super();
this.createActions();
this.registerListeners();
}
private createActions(): void {
this.textInputActions.push(
// Undo/Redo
new Action('undo', localize('undo', "Undo"), undefined, true, async () => document.execCommand('undo')),
new Action('redo', localize('redo', "Redo"), undefined, true, async () => document.execCommand('redo')),
new Separator(),
// Cut / Copy / Paste
new Action('editor.action.clipboardCutAction', localize('cut', "Cut"), undefined, true, async () => document.execCommand('cut')),
new Action('editor.action.clipboardCopyAction', localize('copy', "Copy"), undefined, true, async () => document.execCommand('copy')),
new Action('editor.action.clipboardPasteAction', localize('paste', "Paste"), undefined, true, async (element: HTMLInputElement | HTMLTextAreaElement) => {
// Native: paste is supported
if (isNative) {
document.execCommand('paste');
}
// Web: paste is not supported due to security reasons
else {
const clipboardText = await this.clipboardService.readText();
if (
element instanceof HTMLTextAreaElement ||
element instanceof HTMLInputElement
) {
const selectionStart = element.selectionStart || 0;
const selectionEnd = element.selectionEnd || 0;
element.value = `${element.value.substring(0, selectionStart)}${clipboardText}${element.value.substring(selectionEnd, element.value.length)}`;
element.selectionStart = selectionStart + clipboardText.length;
element.selectionEnd = element.selectionStart;
}
}
}),
new Separator(),
// Select All
new Action('editor.action.selectAll', localize('selectAll', "Select All"), undefined, true, async () => document.execCommand('selectAll'))
);
}
private registerListeners(): void {
// Context menu support in input/textarea
this.layoutService.container.addEventListener('contextmenu', e => this.onContextMenu(e));
}
private onContextMenu(e: MouseEvent): void {
if (e.target instanceof HTMLElement) {
const target = <HTMLElement>e.target;
if (target.nodeName && (target.nodeName.toLowerCase() === 'input' || target.nodeName.toLowerCase() === 'textarea')) {
EventHelper.stop(e, true);
this.contextMenuService.showContextMenu({
getAnchor: () => e,
getActions: () => this.textInputActions,
getActionsContext: () => target,
onHide: () => target.focus() // fixes https://github.com/Microsoft/vscode/issues/52948
});
}
}
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(TextInputActionsProvider, LifecyclePhase.Ready);

View File

@@ -135,7 +135,7 @@ abstract class BaseOpenRecentAction extends Action {
});
if (pick) {
return this.hostService.openInWindow([pick.openable], { forceNewWindow: keyMods && keyMods.ctrlCmd });
return this.hostService.openWindow([pick.openable], { forceNewWindow: keyMods && keyMods.ctrlCmd });
}
}
}
@@ -260,7 +260,7 @@ export class NewWindowAction extends Action {
}
run(): Promise<void> {
return this.hostService.openEmptyWindow();
return this.hostService.openWindow();
}
}

View File

@@ -297,7 +297,7 @@ export class ResourcesDropHandler {
// Open in separate windows if we drop workspaces or just one folder
if (toOpen.length > folderURIs.length || folderURIs.length === 1) {
await this.hostService.openInWindow(toOpen, { forceReuseWindow: true });
await this.hostService.openWindow(toOpen, { forceReuseWindow: true });
}
// folders.length > 1: Multiple folders: Create new workspace with folders and open

View File

@@ -163,7 +163,7 @@ export class OpenWorkspaceButtonContribution extends Disposable implements IEdit
this._register(this.openWorkspaceButton.onClick(() => {
const model = this.editor.getModel();
if (model) {
this.hostService.openInWindow([{ workspaceUri: model.uri }]);
this.hostService.openWindow([{ workspaceUri: model.uri }]);
}
}));

View File

@@ -34,7 +34,7 @@ export class NoTabsTitleControl extends TitleControl {
this.registerContainerListeners();
// Gesture Support
Gesture.addTarget(this.titleContainer);
this._register(Gesture.addTarget(this.titleContainer));
const labelContainer = document.createElement('div');
addClass(labelContainer, 'label-container');

View File

@@ -435,7 +435,7 @@ export class TabsTitleControl extends TitleControl {
addClass(tabContainer, 'tab');
// Gesture Support
Gesture.addTarget(tabContainer);
this._register(Gesture.addTarget(tabContainer));
// Tab Border Top
const tabBorderTopContainer = document.createElement('div');

View File

@@ -10,6 +10,7 @@
height: 22px;
font-size: 12px;
display: flex;
overflow: visible;
}
.monaco-workbench .part.statusbar.status-border-top::after {
@@ -52,7 +53,7 @@
.monaco-workbench .part.statusbar > .items-container > .statusbar-item.has-beak:before {
content: '';
position: absolute;
left: calc(50% - 8px); /* 3px (margin) + 5px (padding) = 8px */
left: calc(50% - 9px); /* 3px (margin) + 5px (padding) + 1px (icon) = 9px */
top: -5px;
border-bottom-width: 5px;
border-bottom-style: solid;

View File

@@ -223,7 +223,7 @@ export abstract class MenubarControl extends Disposable {
const ret: IAction = new Action(commandId, unmnemonicLabel(label), undefined, undefined, (event) => {
const openInNewWindow = event && ((!isMacintosh && (event.ctrlKey || event.shiftKey)) || (isMacintosh && (event.metaKey || event.altKey)));
return this.hostService.openInWindow([openable], {
return this.hostService.openWindow([openable], {
forceNewWindow: openInNewWindow
});
});