mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix a few more floating promises (#8290)
* Fix a few more floating promises * More explicit calls
This commit is contained in:
@@ -15,6 +15,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
|||||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
|
|
||||||
import { Button, IButtonStyles } from 'sql/base/browser/ui/button/button';
|
import { Button, IButtonStyles } from 'sql/base/browser/ui/button/button';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export interface IDropdownStyles {
|
export interface IDropdownStyles {
|
||||||
backgroundColor?: Color;
|
backgroundColor?: Color;
|
||||||
@@ -42,14 +43,14 @@ export class DropdownList extends Dropdown {
|
|||||||
this.button = new Button(_contentContainer);
|
this.button = new Button(_contentContainer);
|
||||||
this.button.label = action.label;
|
this.button.label = action.label;
|
||||||
this._register(DOM.addDisposableListener(this.button.element, DOM.EventType.CLICK, () => {
|
this._register(DOM.addDisposableListener(this.button.element, DOM.EventType.CLICK, () => {
|
||||||
action.run();
|
action.run().catch(e => onUnexpectedError(e));
|
||||||
this.hide();
|
this.hide();
|
||||||
}));
|
}));
|
||||||
this._register(DOM.addDisposableListener(this.button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
this._register(DOM.addDisposableListener(this.button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||||
let event = new StandardKeyboardEvent(e);
|
let event = new StandardKeyboardEvent(e);
|
||||||
if (event.equals(KeyCode.Enter)) {
|
if (event.equals(KeyCode.Enter)) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
action.run();
|
action.run().catch(e => onUnexpectedError(e));
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import * as lifecycle from 'vs/base/common/lifecycle';
|
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import * as types from 'vs/base/common/types';
|
import * as types from 'vs/base/common/types';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
const defaultOptions: IActionBarOptions = {
|
const defaultOptions: IActionBarOptions = {
|
||||||
orientation: ActionsOrientation.HORIZONTAL,
|
orientation: ActionsOrientation.HORIZONTAL,
|
||||||
@@ -344,7 +345,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
|||||||
let actionItem = this._items[this._focusedItem];
|
let actionItem = this._items[this._focusedItem];
|
||||||
if (actionItem instanceof BaseActionViewItem) {
|
if (actionItem instanceof BaseActionViewItem) {
|
||||||
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context;
|
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context;
|
||||||
this.run(actionItem._action, context);
|
this.run(actionItem._action, context).catch(e => onUnexpectedError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
|||||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export interface IDropdownOptions extends IDropdownStyles {
|
export interface IDropdownOptions extends IDropdownStyles {
|
||||||
/**
|
/**
|
||||||
@@ -260,7 +261,7 @@ export class Dropdown extends Disposable {
|
|||||||
this._treeContainer.style.height = height + 'px';
|
this._treeContainer.style.height = height + 'px';
|
||||||
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
||||||
this._tree.layout(parseInt(this._treeContainer.style.height));
|
this._tree.layout(parseInt(this._treeContainer.style.height));
|
||||||
this._tree.refresh();
|
this._tree.refresh().catch(e => onUnexpectedError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +273,7 @@ export class Dropdown extends Disposable {
|
|||||||
this._treeContainer.style.height = height + 'px';
|
this._treeContainer.style.height = height + 'px';
|
||||||
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
||||||
this._tree.layout(parseInt(this._treeContainer.style.height));
|
this._tree.layout(parseInt(this._treeContainer.style.height));
|
||||||
this._tree.setInput(new DropdownModel());
|
this._tree.setInput(new DropdownModel()).catch(e => onUnexpectedError(e));
|
||||||
this._input.validate();
|
this._input.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib
|
|||||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
protected async handlePreviewFeatures(): Promise<void> {
|
protected handlePreviewFeatures(): void {
|
||||||
let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures'];
|
let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||||
if (previewFeaturesEnabled || this.storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) {
|
if (previewFeaturesEnabled || this.storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) {
|
||||||
return;
|
return;
|
||||||
@@ -30,11 +30,11 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib
|
|||||||
Promise.all([
|
Promise.all([
|
||||||
this.hostService.hasFocus,
|
this.hostService.hasFocus,
|
||||||
this.getWindowCount()
|
this.getWindowCount()
|
||||||
]).then(([focused, count]) => {
|
]).then(async ([focused, count]) => {
|
||||||
if (!focused && count > 1) {
|
if (!focused && count > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', false);
|
await this.configurationService.updateValue('workbench.enablePreviewFeatures', false);
|
||||||
|
|
||||||
const enablePreviewFeaturesNotice = localize('enablePreviewFeatures.notice', "Preview features are required in order for extensions to be fully supported and for some actions to be available. Would you like to enable preview features?");
|
const enablePreviewFeaturesNotice = localize('enablePreviewFeatures.notice', "Preview features are required in order for extensions to be fully supported and for some actions to be available. Would you like to enable preview features?");
|
||||||
this.notificationService.prompt(
|
this.notificationService.prompt(
|
||||||
@@ -43,25 +43,24 @@ export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContrib
|
|||||||
[{
|
[{
|
||||||
label: localize('enablePreviewFeatures.yes', "Yes"),
|
label: localize('enablePreviewFeatures.yes', "Yes"),
|
||||||
run: () => {
|
run: () => {
|
||||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', true);
|
this.configurationService.updateValue('workbench.enablePreviewFeatures', true).catch(e => onUnexpectedError(e));
|
||||||
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: localize('enablePreviewFeatures.no', "No"),
|
label: localize('enablePreviewFeatures.no', "No"),
|
||||||
run: () => {
|
run: () => {
|
||||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', false);
|
this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e));
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: localize('enablePreviewFeatures.never', "No, don't show again"),
|
label: localize('enablePreviewFeatures.never', "No, don't show again"),
|
||||||
run: () => {
|
run: () => {
|
||||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', false);
|
this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e));
|
||||||
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
||||||
},
|
},
|
||||||
isSecondary: true
|
isSecondary: true
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
})
|
}).catch(e => onUnexpectedError(e));
|
||||||
.then(null, onUnexpectedError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract getWindowCount(): Promise<number>;
|
protected abstract getWindowCount(): Promise<number>;
|
||||||
|
|||||||
Reference in New Issue
Block a user