From 7031abadeafec54c8876231e3579c938dee6e1a5 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 29 Mar 2021 10:29:45 +0200 Subject: [PATCH] debt - less explicit any --- src/vs/base/browser/contextmenu.ts | 2 +- src/vs/base/browser/dnd.ts | 2 +- src/vs/base/browser/event.ts | 2 +- .../browser/ui/actionbar/actionViewItems.ts | 4 +- src/vs/base/browser/ui/actionbar/actionbar.ts | 12 ++--- .../browser/ui/contextview/contextview.ts | 4 +- src/vs/base/browser/ui/iconLabel/iconLabel.ts | 6 +-- src/vs/base/browser/ui/list/listView.ts | 4 +- src/vs/base/browser/ui/menu/menu.ts | 2 +- src/vs/base/browser/ui/sash/sash.ts | 2 +- src/vs/base/common/actions.ts | 51 +++++++++---------- src/vs/editor/browser/widget/diffReview.ts | 5 +- .../contextview/browser/contextMenuHandler.ts | 7 ++- .../api/browser/mainThreadUriOpeners.ts | 4 +- .../browser/actions/navigationActions.ts | 20 +++----- .../browser/actions/textInputActions.ts | 2 +- .../browser/actions/windowActions.ts | 4 +- .../workbench/browser/parts/compositePart.ts | 4 +- .../browser/parts/editor/editorGroupView.ts | 4 +- .../browser/parts/editor/editorStatus.ts | 2 +- .../browser/parts/editor/titleControl.ts | 9 ++-- .../browser/parts/titlebar/menubarControl.ts | 7 +-- .../workbench/browser/parts/views/treeView.ts | 7 +-- .../contrib/debug/browser/debugService.ts | 4 +- .../contrib/debug/browser/debugToolBar.ts | 4 +- .../contrib/debug/browser/rawDebugSession.ts | 3 +- .../extensions/browser/extensionsActions.ts | 2 +- .../issue/electron-sandbox/issueActions.ts | 8 +-- .../preferences/browser/keybindingsEditor.ts | 2 +- .../preferences/browser/preferencesWidgets.ts | 7 +-- .../preferences/browser/settingsEditor2.ts | 2 +- .../preferences/browser/settingsTree.ts | 6 +-- .../walkThrough/browser/walkThroughPart.ts | 2 +- 33 files changed, 94 insertions(+), 112 deletions(-) diff --git a/src/vs/base/browser/contextmenu.ts b/src/vs/base/browser/contextmenu.ts index 49667d70eef..9d79833936f 100644 --- a/src/vs/base/browser/contextmenu.ts +++ b/src/vs/base/browser/contextmenu.ts @@ -20,7 +20,7 @@ export interface IContextMenuDelegate { getActions(): readonly IAction[]; getCheckedActionsRepresentation?(action: IAction): 'radio' | 'checkbox'; getActionViewItem?(action: IAction): IActionViewItem | undefined; - getActionsContext?(event?: IContextMenuEvent): any; + getActionsContext?(event?: IContextMenuEvent): unknown; getKeyBinding?(action: IAction): ResolvedKeybinding | undefined; getMenuClassName?(): string; onHide?(didCancel: boolean): void; diff --git a/src/vs/base/browser/dnd.ts b/src/vs/base/browser/dnd.ts index 642b0827420..3753e458b28 100644 --- a/src/vs/base/browser/dnd.ts +++ b/src/vs/base/browser/dnd.ts @@ -89,7 +89,7 @@ export function applyDragImage(event: DragEvent, label: string | null, clazz: st export interface IDragAndDropData { update(dataTransfer: DataTransfer): void; - getData(): any; + getData(): unknown; } export class DragAndDropData implements IDragAndDropData { diff --git a/src/vs/base/browser/event.ts b/src/vs/base/browser/event.ts index 02a8488d51e..9ae46f15147 100644 --- a/src/vs/base/browser/event.ts +++ b/src/vs/base/browser/event.ts @@ -9,7 +9,7 @@ export type EventHandler = HTMLElement | HTMLDocument | Window; export interface IDomEvent { (element: EventHandler, type: K, useCapture?: boolean): BaseEvent; - (element: EventHandler, type: string, useCapture?: boolean): BaseEvent; + (element: EventHandler, type: string, useCapture?: boolean): BaseEvent; } export const domEvent: IDomEvent = (element: EventHandler, type: string, useCapture?: boolean) => { diff --git a/src/vs/base/browser/ui/actionbar/actionViewItems.ts b/src/vs/base/browser/ui/actionbar/actionViewItems.ts index 26523c5508b..7203b9850c0 100644 --- a/src/vs/base/browser/ui/actionbar/actionViewItems.ts +++ b/src/vs/base/browser/ui/actionbar/actionViewItems.ts @@ -27,12 +27,12 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem { element: HTMLElement | undefined; - _context: any; + _context: unknown; _action: IAction; private _actionRunner: IActionRunner | undefined; - constructor(context: any, action: IAction, protected options: IBaseActionViewItemOptions = {}) { + constructor(context: unknown, action: IAction, protected options: IBaseActionViewItemOptions = {}) { super(); this._context = context || this; diff --git a/src/vs/base/browser/ui/actionbar/actionbar.ts b/src/vs/base/browser/ui/actionbar/actionbar.ts index 2a51544c746..b6fcbb24295 100644 --- a/src/vs/base/browser/ui/actionbar/actionbar.ts +++ b/src/vs/base/browser/ui/actionbar/actionbar.ts @@ -15,7 +15,7 @@ import { IActionViewItemOptions, ActionViewItem, BaseActionViewItem } from 'vs/b export interface IActionViewItem extends IDisposable { actionRunner: IActionRunner; - setActionContext(context: any): void; + setActionContext(context: unknown): void; render(element: HTMLElement): void; isEnabled(): boolean; focus(fromRight?: boolean): void; // TODO@isidorn what is this? @@ -38,7 +38,7 @@ export interface ActionTrigger { export interface IActionBarOptions { readonly orientation?: ActionsOrientation; - readonly context?: any; + readonly context?: unknown; readonly actionViewItemProvider?: IActionViewItemProvider; readonly actionRunner?: IActionRunner; readonly ariaLabel?: string; @@ -264,11 +264,11 @@ export class ActionBar extends Disposable implements IActionRunner { } } - get context(): any { + get context(): unknown { return this._context; } - set context(context: any) { + set context(context: unknown) { this._context = context; this.viewItems.forEach(i => i.setActionContext(context)); } @@ -525,8 +525,8 @@ export class ActionBar extends Disposable implements IActionRunner { } } - run(action: IAction, context?: unknown): Promise { - return this._actionRunner.run(action, context); + async run(action: IAction, context?: unknown): Promise { + await this._actionRunner.run(action, context); } dispose(): void { diff --git a/src/vs/base/browser/ui/contextview/contextview.ts b/src/vs/base/browser/ui/contextview/contextview.ts index ef695b6a5a2..9632da876a7 100644 --- a/src/vs/base/browser/ui/contextview/contextview.ts +++ b/src/vs/base/browser/ui/contextview/contextview.ts @@ -45,7 +45,7 @@ export interface IDelegate { anchorAxisAlignment?: AnchorAxisAlignment; // default: vertical canRelayout?: boolean; // default: true onDOMEvent?(e: Event, activeElement: HTMLElement): void; - onHide?(data?: any): void; + onHide?(data?: unknown): void; } export interface IContextViewProvider { @@ -324,7 +324,7 @@ export class ContextView extends Disposable { this.view.style.width = 'initial'; } - hide(data?: any): void { + hide(data?: unknown): void { const delegate = this.delegate; this.delegate = null; diff --git a/src/vs/base/browser/ui/iconLabel/iconLabel.ts b/src/vs/base/browser/ui/iconLabel/iconLabel.ts index b131ad7f3de..ecdd346b6b4 100644 --- a/src/vs/base/browser/ui/iconLabel/iconLabel.ts +++ b/src/vs/base/browser/ui/iconLabel/iconLabel.ts @@ -222,12 +222,12 @@ export class IconLabel extends Disposable { let isHovering = false; let tokenSource: CancellationTokenSource; let hoverDisposable: IDisposable | undefined; - function mouseOver(this: HTMLElement, e: MouseEvent): any { + function mouseOver(this: HTMLElement, e: MouseEvent): void { if (isHovering) { return; } tokenSource = new CancellationTokenSource(); - function mouseLeaveOrDown(this: HTMLElement, e: MouseEvent): any { + function mouseLeaveOrDown(this: HTMLElement, e: MouseEvent): void { const isMouseDown = e.type === dom.EventType.MOUSE_DOWN; if (isMouseDown) { hoverDisposable?.dispose(); @@ -245,7 +245,7 @@ export class IconLabel extends Disposable { const mouseDownDisposable = domEvent(htmlElement, dom.EventType.MOUSE_DOWN, true)(mouseLeaveOrDown.bind(htmlElement)); isHovering = true; - function mouseMove(this: HTMLElement, e: MouseEvent): any { + function mouseMove(this: HTMLElement, e: MouseEvent): void { mouseX = e.x; } const mouseMoveDisposable = domEvent(htmlElement, dom.EventType.MOUSE_MOVE, true)(mouseMove.bind(htmlElement)); diff --git a/src/vs/base/browser/ui/list/listView.ts b/src/vs/base/browser/ui/list/listView.ts index 840d53cb55c..b773496b257 100644 --- a/src/vs/base/browser/ui/list/listView.ts +++ b/src/vs/base/browser/ui/list/listView.ts @@ -339,7 +339,7 @@ export class ListView implements ISpliceable, IDisposable { container.appendChild(this.domNode); this.scrollableElement.onScroll(this.onScroll, this, this.disposables); - domEvent(this.rowsContainer, TouchEventType.Change)(this.onTouchChange, this, this.disposables); + domEvent(this.rowsContainer, TouchEventType.Change)(e => this.onTouchChange(e as GestureEvent), this, this.disposables); // Prevent the monaco-scrollable-element from scrolling // https://github.com/microsoft/vscode/issues/44181 @@ -898,7 +898,7 @@ export class ListView implements ISpliceable, IDisposable { @memoize get onMouseOut(): Event> { return Event.map(domEvent(this.domNode, 'mouseout'), e => this.toMouseEvent(e)); } @memoize get onContextMenu(): Event> { return Event.map(domEvent(this.domNode, 'contextmenu'), e => this.toMouseEvent(e)); } @memoize get onTouchStart(): Event> { return Event.map(domEvent(this.domNode, 'touchstart'), e => this.toTouchEvent(e)); } - @memoize get onTap(): Event> { return Event.map(domEvent(this.rowsContainer, TouchEventType.Tap), e => this.toGestureEvent(e)); } + @memoize get onTap(): Event> { return Event.map(domEvent(this.rowsContainer, TouchEventType.Tap), e => this.toGestureEvent(e as GestureEvent)); } private toMouseEvent(browserEvent: MouseEvent): IListMouseEvent { const index = this.getItemIndexFromEventTarget(browserEvent.target || null); diff --git a/src/vs/base/browser/ui/menu/menu.ts b/src/vs/base/browser/ui/menu/menu.ts index 21ef5090c99..36e09bb3a66 100644 --- a/src/vs/base/browser/ui/menu/menu.ts +++ b/src/vs/base/browser/ui/menu/menu.ts @@ -37,7 +37,7 @@ export enum Direction { } export interface IMenuOptions { - context?: any; + context?: unknown; actionViewItemProvider?: IActionViewItemProvider; actionRunner?: IActionRunner; getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined; diff --git a/src/vs/base/browser/ui/sash/sash.ts b/src/vs/base/browser/ui/sash/sash.ts index 34322ee6ad1..b3d76b24de9 100644 --- a/src/vs/base/browser/ui/sash/sash.ts +++ b/src/vs/base/browser/ui/sash/sash.ts @@ -211,7 +211,7 @@ export class Sash extends Disposable { this._register(domEvent(this.el, 'mouseleave')(() => Sash.onMouseLeave(this))); this._register(Gesture.addTarget(this.el)); - this._register(domEvent(this.el, EventType.Start)(this.onTouchStart, this)); + this._register(domEvent(this.el, EventType.Start)(e => this.onTouchStart(e as GestureEvent), this)); if (typeof options.size === 'number') { this.size = options.size; diff --git a/src/vs/base/common/actions.ts b/src/vs/base/common/actions.ts index 466be3c5cae..171853e2fd6 100644 --- a/src/vs/base/common/actions.ts +++ b/src/vs/base/common/actions.ts @@ -10,7 +10,7 @@ import { Event, Emitter } from 'vs/base/common/event'; export interface ITelemetryData { readonly from?: string; readonly target?: string; - [key: string]: any; + [key: string]: unknown; } export type WorkbenchActionExecutedClassification = { @@ -30,13 +30,14 @@ export interface IAction extends IDisposable { class: string | undefined; enabled: boolean; checked: boolean; - run(event?: any): Promise; + run(event?: unknown): Promise; } export interface IActionRunner extends IDisposable { - run(action: IAction, context?: any): Promise; readonly onDidRun: Event; readonly onBeforeRun: Event; + + run(action: IAction, context?: unknown): Promise; } export interface IActionChangeEvent { @@ -58,9 +59,9 @@ export class Action extends Disposable implements IAction { protected _cssClass: string | undefined; protected _enabled: boolean = true; protected _checked: boolean = false; - protected readonly _actionCallback?: (event?: any) => Promise; + protected readonly _actionCallback?: (event?: unknown) => Promise; - constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise) { + constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: unknown) => Promise) { super(); this._id = id; this._label = label; @@ -148,19 +149,16 @@ export class Action extends Disposable implements IAction { } } - run(event?: any, _data?: ITelemetryData): Promise { + async run(event?: unknown, data?: ITelemetryData): Promise { if (this._actionCallback) { - return this._actionCallback(event); + await this._actionCallback(event); } - - return Promise.resolve(true); } } export interface IRunEvent { readonly action: IAction; - readonly result?: any; - readonly error?: any; + readonly error?: Error; } export class ActionRunner extends Disposable implements IActionRunner { @@ -171,24 +169,25 @@ export class ActionRunner extends Disposable implements IActionRunner { private _onDidRun = this._register(new Emitter()); readonly onDidRun = this._onDidRun.event; - async run(action: IAction, context?: any): Promise { + async run(action: IAction, context?: unknown): Promise { if (!action.enabled) { - return Promise.resolve(null); + return; } - this._onBeforeRun.fire({ action: action }); + this._onBeforeRun.fire({ action }); + let error: Error | undefined = undefined; try { - const result = await this.runAction(action, context); - this._onDidRun.fire({ action: action, result: result }); - } catch (error) { - this._onDidRun.fire({ action: action, error: error }); + await this.runAction(action, context); + } catch (e) { + error = e; } + + this._onDidRun.fire({ action, error }); } - protected runAction(action: IAction, context?: any): Promise { - const res = context ? action.run(context) : action.run(); - return Promise.resolve(res); + protected async runAction(action: IAction, context?: unknown): Promise { + await action.run(context); } } @@ -198,6 +197,7 @@ export class Separator extends Action { constructor(label?: string) { super(Separator.ID, label, label ? 'separator text' : 'separator'); + this.checked = false; this.enabled = false; } @@ -213,6 +213,7 @@ export class SubmenuAction implements IAction { readonly checked: boolean = false; private readonly _actions: readonly IAction[]; + get actions(): readonly IAction[] { return this._actions; } constructor(id: string, label: string, actions: readonly IAction[], cssClass?: string) { this.id = id; @@ -227,15 +228,13 @@ export class SubmenuAction implements IAction { // to bridge into the rendering world. } - get actions(): readonly IAction[] { - return this._actions; - } - - async run(): Promise { } + async run(): Promise { } } export class EmptySubmenuAction extends Action { + static readonly ID = 'vs.actions.empty'; + constructor() { super(EmptySubmenuAction.ID, nls.localize('submenu.empty', '(empty)'), undefined, false); } diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index 2fb0eaed0e6..8a568c82136 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -107,10 +107,7 @@ export class DiffReview extends Disposable { this.actionBarContainer.domNode )); - this._actionBar.push(new Action('diffreview.close', nls.localize('label.close', "Close"), 'close-diff-review ' + ThemeIcon.asClassName(diffReviewCloseIcon), true, () => { - this.hide(); - return Promise.resolve(null); - }), { label: false, icon: true }); + this._actionBar.push(new Action('diffreview.close', nls.localize('label.close', "Close"), 'close-diff-review ' + ThemeIcon.asClassName(diffReviewCloseIcon), true, async () => this.hide()), { label: false, icon: true }); this.domNode = createFastDomNode(document.createElement('div')); this.domNode.setClassName('diff-review monaco-editor-background'); diff --git a/src/vs/platform/contextview/browser/contextMenuHandler.ts b/src/vs/platform/contextview/browser/contextMenuHandler.ts index 0b515dc515d..bf0652d0571 100644 --- a/src/vs/platform/contextview/browser/contextMenuHandler.ts +++ b/src/vs/platform/contextview/browser/contextMenuHandler.ts @@ -18,6 +18,7 @@ import { EventType, $, isHTMLElement } from 'vs/base/browser/dom'; import { attachMenuStyler } from 'vs/platform/theme/common/styler'; import { domEvent } from 'vs/base/browser/event'; import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; +import { isPromiseCanceledError } from 'vs/base/common/errors'; export interface IContextMenuHandlerOptions { blockMouse: boolean; @@ -145,9 +146,7 @@ export class ContextMenuHandler { } private onActionRun(e: IRunEvent): void { - if (this.telemetryService) { - this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' }); - } + this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' }); this.contextViewService.hideContextView(false); @@ -158,7 +157,7 @@ export class ContextMenuHandler { } private onDidActionRun(e: IRunEvent): void { - if (e.error) { + if (e.error && !isPromiseCanceledError(e.error)) { this.notificationService.error(e.error); } } diff --git a/src/vs/workbench/api/browser/mainThreadUriOpeners.ts b/src/vs/workbench/api/browser/mainThreadUriOpeners.ts index 96eb6fd8698..ee05a2d6627 100644 --- a/src/vs/workbench/api/browser/mainThreadUriOpeners.ts +++ b/src/vs/workbench/api/browser/mainThreadUriOpeners.ts @@ -77,8 +77,8 @@ export class MainThreadUriOpeners extends Disposable implements MainThreadUriOpe await this.proxy.$openUri(id, { resolvedUri: uri, sourceUri: ctx.sourceUri }, token); } catch (e) { if (!isPromiseCanceledError(e)) { - const openDefaultAction = new Action('default', localize('openerFailedUseDefault', "Open using default opener"), undefined, undefined, () => { - return this.openerService.open(uri, { + const openDefaultAction = new Action('default', localize('openerFailedUseDefault', "Open using default opener"), undefined, undefined, async () => { + await this.openerService.open(uri, { allowTunneling: false, allowContributedOpeners: defaultExternalUriOpenerId, }); diff --git a/src/vs/workbench/browser/actions/navigationActions.ts b/src/vs/workbench/browser/actions/navigationActions.ts index 6122d65d983..6796c4d69c3 100644 --- a/src/vs/workbench/browser/actions/navigationActions.ts +++ b/src/vs/workbench/browser/actions/navigationActions.ts @@ -32,7 +32,7 @@ abstract class BaseNavigationAction extends Action { super(id, label); } - async run(): Promise { + async run(): Promise { const isEditorFocus = this.layoutService.hasFocus(Parts.EDITOR_PART); const isPanelFocus = this.layoutService.hasFocus(Parts.PANEL_PART); const isSidebarFocus = this.layoutService.hasFocus(Parts.SIDEBAR_PART); @@ -41,7 +41,7 @@ abstract class BaseNavigationAction extends Action { if (isEditorFocus) { const didNavigate = this.navigateAcrossEditorGroup(this.toGroupDirection(this.direction)); if (didNavigate) { - return true; + return; } neighborPart = this.layoutService.getVisibleNeighborPart(Parts.EDITOR_PART, this.direction); @@ -56,18 +56,12 @@ abstract class BaseNavigationAction extends Action { } if (neighborPart === Parts.EDITOR_PART) { - return this.navigateToEditorGroup(this.direction === Direction.Right ? GroupLocation.FIRST : GroupLocation.LAST); + this.navigateToEditorGroup(this.direction === Direction.Right ? GroupLocation.FIRST : GroupLocation.LAST); + } else if (neighborPart === Parts.SIDEBAR_PART) { + this.navigateToSidebar(); + } else if (neighborPart === Parts.PANEL_PART) { + this.navigateToPanel(); } - - if (neighborPart === Parts.SIDEBAR_PART) { - return this.navigateToSidebar(); - } - - if (neighborPart === Parts.PANEL_PART) { - return this.navigateToPanel(); - } - - return false; } private async navigateToPanel(): Promise { diff --git a/src/vs/workbench/browser/actions/textInputActions.ts b/src/vs/workbench/browser/actions/textInputActions.ts index 606099d232a..60dad795312 100644 --- a/src/vs/workbench/browser/actions/textInputActions.ts +++ b/src/vs/workbench/browser/actions/textInputActions.ts @@ -42,7 +42,7 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo // 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) => { + new Action('editor.action.clipboardPasteAction', localize('paste', "Paste"), undefined, true, async element => { // Native: paste is supported if (isNative) { diff --git a/src/vs/workbench/browser/actions/windowActions.ts b/src/vs/workbench/browser/actions/windowActions.ts index de5ccf08d31..389e9c794fe 100644 --- a/src/vs/workbench/browser/actions/windowActions.ts +++ b/src/vs/workbench/browser/actions/windowActions.ts @@ -304,10 +304,8 @@ export class ReloadWindowAction extends Action { super(id, label); } - async run(): Promise { + async run(): Promise { await this.hostService.reload(); - - return true; } } diff --git a/src/vs/workbench/browser/parts/compositePart.ts b/src/vs/workbench/browser/parts/compositePart.ts index 1ead62e5b8e..f735e427e6c 100644 --- a/src/vs/workbench/browser/parts/compositePart.ts +++ b/src/vs/workbench/browser/parts/compositePart.ts @@ -263,9 +263,7 @@ export abstract class CompositePart extends Part { } // Log in telemetry - if (this.telemetryService) { - this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: this.nameForTelemetry }); - } + this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: this.nameForTelemetry }); }); // Indicate to composite that it is now visible diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index 40e86600d6e..2f95e8cf947 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -300,8 +300,8 @@ export class EditorGroupView extends Themable implements IEditorGroupView { const groupId = this._group.id; const containerToolbar = this._register(new ActionBar(toolbarContainer, { ariaLabel: localize('ariaLabelGroupActions', "Editor group actions"), actionRunner: this._register(new class extends ActionRunner { - run(action: IAction) { - return action.run(groupId); + async run(action: IAction) { + await action.run(groupId); } }) })); diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index adfc7779175..18928433921 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -1069,7 +1069,7 @@ export class ChangeModeAction extends Action { super(actionId, actionLabel); } - async run(event: any, data: ITelemetryData): Promise { + async run(event: unknown, data?: ITelemetryData): Promise { const activeTextEditorControl = getCodeEditor(this.editorService.activeTextEditorControl); if (!activeTextEditorControl) { await this.quickInputService.pick([{ label: localize('noEditor', "No text editor active at this time") }]); diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index 7acaf58fe9e..45af0d3b87f 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -38,6 +38,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { withNullAsUndefined, withUndefinedAsNull, assertIsDefined } from 'vs/base/common/types'; import { isFirefox } from 'vs/base/browser/browser'; import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; +import { isPromiseCanceledError } from 'vs/base/common/errors'; export interface IToolbarActions { primary: IAction[]; @@ -151,12 +152,12 @@ export abstract class TitleControl extends Themable { this._register(this.editorActionsToolbar.actionRunner.onDidRun(e => { // Notify for Error - this.notificationService.error(e.error); + if (e.error && !isPromiseCanceledError(e.error)) { + this.notificationService.error(e.error); + } // Log in telemetry - if (this.telemetryService) { - this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'editorPart' }); - } + this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'editorPart' }); })); } diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index bc20eca2daf..701440fb360 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -251,11 +251,12 @@ export abstract class MenubarControl extends Disposable { openable = { fileUri: uri }; } - const ret: IAction = new Action(commandId, unmnemonicLabel(label), undefined, undefined, (event) => { - const openInNewWindow = event && ((!isMacintosh && (event.ctrlKey || event.shiftKey)) || (isMacintosh && (event.metaKey || event.altKey))); + const ret: IAction = new Action(commandId, unmnemonicLabel(label), undefined, undefined, event => { + const browserEvent = event as KeyboardEvent; + const openInNewWindow = event && ((!isMacintosh && (browserEvent.ctrlKey || browserEvent.shiftKey)) || (isMacintosh && (browserEvent.metaKey || browserEvent.altKey))); return this.hostService.openWindow([openable], { - forceNewWindow: openInNewWindow, + forceNewWindow: !!openInNewWindow, remoteAuthority }); }); diff --git a/src/vs/workbench/browser/parts/views/treeView.ts b/src/vs/workbench/browser/parts/views/treeView.ts index e6b076910f1..384a2f410ce 100644 --- a/src/vs/workbench/browser/parts/views/treeView.ts +++ b/src/vs/workbench/browser/parts/views/treeView.ts @@ -54,6 +54,7 @@ import { API_OPEN_DIFF_EDITOR_COMMAND_ID, API_OPEN_EDITOR_COMMAND_ID } from 'vs/ import { Codicon } from 'vs/base/common/codicons'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { Command } from 'vs/editor/common/modes'; +import { isPromiseCanceledError } from 'vs/base/common/errors'; export class TreeViewPane extends ViewPane { @@ -1071,13 +1072,13 @@ class MultipleSelectionActionRunner extends ActionRunner { constructor(notificationService: INotificationService, private getSelectedResources: (() => ITreeItem[])) { super(); this._register(this.onDidRun(e => { - if (e.error) { + if (e.error && !isPromiseCanceledError(e.error)) { notificationService.error(localize('command-error', 'Error running command {1}: {0}. This is likely caused by the extension that contributes {1}.', e.error.message, e.action.id)); } })); } - runAction(action: IAction, context: TreeViewItemHandleArg): Promise { + async runAction(action: IAction, context: TreeViewItemHandleArg): Promise { const selection = this.getSelectedResources(); let selectionHandleArgs: TreeViewItemHandleArg[] | undefined = undefined; let actionInSelected: boolean = false; @@ -1094,7 +1095,7 @@ class MultipleSelectionActionRunner extends ActionRunner { selectionHandleArgs = undefined; } - return action.run(...[context, selectionHandleArgs]); + await action.run(...[context, selectionHandleArgs]); } } diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index 25a28ac5cbf..ed9faf81747 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -780,10 +780,8 @@ export class DebugService implements IDebugService { const actions = [...errorActions, configureAction]; const { choice } = await this.dialogService.show(severity.Error, message, actions.map(a => a.label).concat(nls.localize('cancel', "Cancel")), { cancelId: actions.length }); if (choice < actions.length) { - return actions[choice].run(); + await actions[choice].run(); } - - return undefined; } //---- focus management diff --git a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts index 1445c1540bd..35313a515a0 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts @@ -126,9 +126,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { } // log in telemetry - if (this.telemetryService) { - this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'debugActionsWidget' }); - } + this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'debugActionsWidget' }); })); this._register(dom.addDisposableListener(window, dom.EventType.RESIZE, () => this.setCoordinates())); diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index 266edb6b100..9f7a8b4c093 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -686,9 +686,8 @@ export class RawDebugSession implements IDisposable { if (error && url) { const label = error.urlLabel ? error.urlLabel : nls.localize('moreInfo', "More Info"); return errors.createErrorWithActions(userMessage, { - actions: [new Action('debug.moreInfo', label, undefined, true, () => { + actions: [new Action('debug.moreInfo', label, undefined, true, async () => { this.openerService.open(URI.parse(url)); - return Promise.resolve(null); })] }); } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 0a03f1f7ab6..668c5d01356 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -978,7 +978,7 @@ export class MenuItemExtensionAction extends ExtensionAction { async run(): Promise { if (this.extension) { - return this.action.run(this.extension.identifier.id); + await this.action.run(this.extension.identifier.id); } } } diff --git a/src/vs/workbench/contrib/issue/electron-sandbox/issueActions.ts b/src/vs/workbench/contrib/issue/electron-sandbox/issueActions.ts index 44a3965755d..8b8422eed46 100644 --- a/src/vs/workbench/contrib/issue/electron-sandbox/issueActions.ts +++ b/src/vs/workbench/contrib/issue/electron-sandbox/issueActions.ts @@ -20,8 +20,8 @@ export class OpenProcessExplorer extends Action { super(id, label); } - run(): Promise { - return this.issueService.openProcessExplorer().then(() => true); + run(): Promise { + return this.issueService.openProcessExplorer(); } } @@ -37,7 +37,7 @@ export class ReportPerformanceIssueUsingReporterAction extends Action { super(id, label); } - run(): Promise { - return this.issueService.openReporter({ issueType: IssueType.PerformanceIssue }).then(() => true); + run(): Promise { + return this.issueService.openReporter({ issueType: IssueType.PerformanceIssue }); } } diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts index e9b86106f4b..5ba3b226641 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts @@ -324,7 +324,7 @@ export class KeybindingsEditor extends EditorPane implements IKeybindingsEditorP const fullTextSearchPlaceholder = localize('SearchKeybindings.FullTextSearchPlaceholder', "Type to search in keybindings"); const keybindingsSearchPlaceholder = localize('SearchKeybindings.KeybindingsSearchPlaceholder', "Recording Keys. Press Escape to exit"); - const clearInputAction = new Action(KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, localize('clearInput', "Clear Keybindings Search Input"), ThemeIcon.asClassName(preferencesClearInputIcon), false, () => { this.clearSearchResults(); return Promise.resolve(null); }); + const clearInputAction = new Action(KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, localize('clearInput', "Clear Keybindings Search Input"), ThemeIcon.asClassName(preferencesClearInputIcon), false, async () => this.clearSearchResults()); const searchContainer = DOM.append(this.headerContainer, $('.search-container')); this.searchWidget = this._register(this.instantiationService.createInstance(KeybindingsSearchWidget, searchContainer, { diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 67b174bdd46..4d993c9f85e 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -29,7 +29,7 @@ import { Schemas } from 'vs/base/common/network'; import { activeContrastBorder, badgeBackground, badgeForeground, contrastBorder, focusBorder } from 'vs/platform/theme/common/colorRegistry'; import { attachInputBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler'; import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticipant, ThemeIcon } from 'vs/platform/theme/common/themeService'; -import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace'; +import { isWorkspaceFolder, IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { ISettingsGroup, IPreferencesService } from 'vs/workbench/services/preferences/common/preferences'; @@ -539,8 +539,9 @@ export class SettingsTargetsWidget extends Widget { this.workspaceSettings = new Action('workspaceSettings', localize('workspaceSettings', "Workspace"), '.settings-tab', false, () => this.updateTarget(ConfigurationTarget.WORKSPACE)); - const folderSettingsAction = new Action('folderSettings', localize('folderSettings', "Folder"), '.settings-tab', false, - (folder: IWorkspaceFolder | null) => this.updateTarget(folder ? folder.uri : ConfigurationTarget.USER_LOCAL)); + const folderSettingsAction = new Action('folderSettings', localize('folderSettings', "Folder"), '.settings-tab', false, async folder => { + this.updateTarget(isWorkspaceFolder(folder) ? folder.uri : ConfigurationTarget.USER_LOCAL); + }); this.folderSettings = this.instantiationService.createInstance(FolderSettingsActionViewItem, folderSettingsAction); this.update(); diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index 4ab4acb0085..7b7bdbf5a77 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -440,7 +440,7 @@ export class SettingsEditor2 extends EditorPane { const searchContainer = DOM.append(this.headerContainer, $('.search-container')); - const clearInputAction = new Action(SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, localize('clearInput', "Clear Settings Search Input"), ThemeIcon.asClassName(preferencesClearInputIcon), false, () => { this.clearSearchResults(); return Promise.resolve(null); }); + const clearInputAction = new Action(SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, localize('clearInput', "Clear Settings Search Input"), ThemeIcon.asClassName(preferencesClearInputIcon), false, async () => this.clearSearchResults()); this.searchWidget = this._register(this.instantiationService.createInstance(SuggestEnabledInput, `${SettingsEditor2.ID}.searchbox`, searchContainer, { triggerCharacters: ['@'], diff --git a/src/vs/workbench/contrib/preferences/browser/settingsTree.ts b/src/vs/workbench/contrib/preferences/browser/settingsTree.ts index d8aebfa826a..9e89f833324 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsTree.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsTree.ts @@ -1541,12 +1541,10 @@ export class SettingTreeRenderers { @IUserDataAutoSyncEnablementService private readonly _userDataAutoSyncEnablementService: IUserDataAutoSyncEnablementService, ) { this.settingActions = [ - new Action('settings.resetSetting', localize('resetSettingLabel', "Reset Setting"), undefined, undefined, (context: SettingsTreeSettingElement) => { - if (context) { + new Action('settings.resetSetting', localize('resetSettingLabel', "Reset Setting"), undefined, undefined, async context => { + if (context instanceof SettingsTreeSettingElement) { this._onDidChangeSetting.fire({ key: context.setting.key, value: undefined, type: context.setting.type as SettingValueType }); } - - return Promise.resolve(null); }), new Separator(), this._instantiationService.createInstance(CopySettingIdAction), diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts b/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts index 2f7b9e16adb..5dc0c290601 100644 --- a/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts +++ b/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts @@ -413,7 +413,7 @@ export class WalkThroughPart extends EditorPane { this.loadTextEditorViewState(input); this.updatedScrollPosition(); this.contentDisposables.push(Gesture.addTarget(innerContent)); - this.contentDisposables.push(domEvent(innerContent, TouchEventType.Change)(this.onTouchChange, this, this.disposables)); + this.contentDisposables.push(domEvent(innerContent, TouchEventType.Change)(e => this.onTouchChange(e as GestureEvent), this, this.disposables)); }); }