diff --git a/src/vs/editor/contrib/codeAction/codeAction.ts b/src/vs/editor/contrib/codeAction/codeAction.ts index 595d156bfb811e7b6e735b649eca623e96c9fcd5..4d2770b82600c7dafe34838d06abeddc4f6a2082 100644 --- a/src/vs/editor/contrib/codeAction/codeAction.ts +++ b/src/vs/editor/contrib/codeAction/codeAction.ts @@ -5,7 +5,7 @@ import { isFalsyOrEmpty, mergeSort, flatten } from 'vs/base/common/arrays'; import { asWinJsPromise } from 'vs/base/common/async'; -import { illegalArgument, onUnexpectedExternalError } from 'vs/base/common/errors'; +import { illegalArgument, onUnexpectedExternalError, isPromiseCanceledError } from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { registerLanguageCommand } from 'vs/editor/browser/editorExtensions'; @@ -28,6 +28,10 @@ export function getCodeActions(model: ITextModel, rangeOrSelection: Range | Sele } return providedCodeActions.filter(action => isValidAction(filter, action)); }, (err): CodeAction[] => { + if (isPromiseCanceledError(err)) { + throw err; + } + onUnexpectedExternalError(err); return []; }); diff --git a/src/vs/editor/contrib/codeAction/codeActionCommands.ts b/src/vs/editor/contrib/codeAction/codeActionCommands.ts index 5ffabccd86810f1811f81bea3c7d4461e4de8ed5..9ea29d8e5e42dd1de65a60d0e8b71b332c9694fb 100644 --- a/src/vs/editor/contrib/codeAction/codeActionCommands.ts +++ b/src/vs/editor/contrib/codeAction/codeActionCommands.ts @@ -46,6 +46,8 @@ export class QuickFixController implements IEditorContribution { private _lightBulbWidget: LightBulbWidget; private _disposables: IDisposable[] = []; + private _activeRequest: TPromise | undefined; + constructor(editor: ICodeEditor, @IMarkerService markerService: IMarkerService, @IContextKeyService contextKeyService: IContextKeyService, @@ -76,6 +78,15 @@ export class QuickFixController implements IEditorContribution { } private _onCodeActionsEvent(e: CodeActionsComputeEvent): void { + if (this._activeRequest) { + this._activeRequest.cancel(); + this._activeRequest = undefined; + } + + if (e && e.actions) { + this._activeRequest = e.actions; + } + if (e && e.trigger.filter && e.trigger.filter.kind) { // Triggered for specific scope // Apply if we only have one action or requested autoApply, otherwise show menu