mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-22 12:50:29 -04:00
Merge from master
This commit is contained in:
@@ -8,7 +8,6 @@ import { Action } from 'vs/base/common/actions';
|
||||
import { always } from 'vs/base/common/async';
|
||||
import { canceled } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
@@ -25,12 +24,12 @@ export class CodeActionContextMenu {
|
||||
constructor(
|
||||
private readonly _editor: ICodeEditor,
|
||||
private readonly _contextMenuService: IContextMenuService,
|
||||
private readonly _onApplyCodeAction: (action: CodeAction) => TPromise<any>
|
||||
private readonly _onApplyCodeAction: (action: CodeAction) => Promise<any>
|
||||
) { }
|
||||
|
||||
show(fixes: Thenable<CodeAction[]>, at: { x: number; y: number } | Position) {
|
||||
|
||||
const actions = fixes.then(value => {
|
||||
const actionsPromise = fixes ? fixes.then(value => {
|
||||
return value.map(action => {
|
||||
return new Action(action.command ? action.command.id : action.title, action.title, undefined, true, () => {
|
||||
return always(
|
||||
@@ -41,24 +40,26 @@ export class CodeActionContextMenu {
|
||||
}).then(actions => {
|
||||
if (!this._editor.getDomNode()) {
|
||||
// cancel when editor went off-dom
|
||||
return TPromise.wrapError<any>(canceled());
|
||||
return Promise.reject(canceled());
|
||||
}
|
||||
return actions;
|
||||
});
|
||||
}) : Promise.resolve([] as Action[]);
|
||||
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => {
|
||||
if (Position.isIPosition(at)) {
|
||||
at = this._toCoords(at);
|
||||
}
|
||||
return at;
|
||||
},
|
||||
getActions: () => TPromise.wrap(actions),
|
||||
onHide: () => {
|
||||
this._visible = false;
|
||||
this._editor.focus();
|
||||
},
|
||||
autoSelectFirstItem: true
|
||||
actionsPromise.then(actions => {
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => {
|
||||
if (Position.isIPosition(at)) {
|
||||
at = this._toCoords(at);
|
||||
}
|
||||
return at;
|
||||
},
|
||||
getActions: () => actions,
|
||||
onHide: () => {
|
||||
this._visible = false;
|
||||
this._editor.focus();
|
||||
},
|
||||
autoSelectFirstItem: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user