提交 a3d44c1f 编写于 作者: J Johannes Rieken

re-request code action after applying them, fixes #21060

上级 b307369d
......@@ -50,6 +50,7 @@ export class QuickFixController implements IEditorContribution {
this._updateLightBulbTitle();
this._disposables.push(
this._quickFixContextMenu.onDidExecuteCodeAction(_ => this._model.trigger('auto')),
this._lightBulbWidget.onClick(this._handleLightBulbSelect, this),
this._model.onDidChangeFixes(e => this._onQuickFixEvent(e)),
this._keybindingService.onDidUpdateKeybindings(this._updateLightBulbTitle, this)
......@@ -88,7 +89,7 @@ export class QuickFixController implements IEditorContribution {
}
public triggerFromEditorSelection(): void {
this._model.triggerManual();
this._model.trigger('manual');
}
private _updateLightBulbTitle(): void {
......
......@@ -6,6 +6,7 @@
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { always } from 'vs/base/common/async';
import { getDomNodePagePosition } from 'vs/base/browser/dom';
import { Position } from 'vs/editor/common/core/position';
import { IPosition } from 'vs/editor/common/editorCommon';
......@@ -14,6 +15,7 @@ import { CodeAction } from 'vs/editor/common/modes';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { Action } from 'vs/base/common/actions';
import Event, { Emitter } from 'vs/base/common/event';
export class QuickFixContextMenu {
......@@ -21,6 +23,9 @@ export class QuickFixContextMenu {
private _contextMenuService: IContextMenuService;
private _commandService: ICommandService;
private _visible: boolean;
private _onDidExecuteCodeAction = new Emitter<void>();
readonly onDidExecuteCodeAction: Event<void> = this._onDidExecuteCodeAction.event;
constructor(editor: ICodeEditor, contextMenuService: IContextMenuService, commandService: ICommandService) {
this._editor = editor;
......@@ -31,9 +36,12 @@ export class QuickFixContextMenu {
show(fixes: TPromise<CodeAction[]>, at: { x: number; y: number } | IPosition) {
const actions = fixes.then(value => {
return value.map(({command}) => {
return value.map(({ command }) => {
return new Action(command.id, command.title, undefined, true, () => {
return this._commandService.executeCommand(command.id, ...command.arguments);
return always(
this._commandService.executeCommand(command.id, ...command.arguments),
() => this._onDidExecuteCodeAction.fire(undefined)
);
});
});
});
......
......@@ -32,7 +32,7 @@ export class QuickFixOracle {
this._disposables = dispose(this._disposables);
}
trigger(type: 'manual' | 'auto' = 'manual'): void {
trigger(type: 'manual' | 'auto'): void {
let range = this._rangeAtPosition();
if (!range) {
range = this._editor.getSelection();
......@@ -47,7 +47,7 @@ export class QuickFixOracle {
}
private _onMarkerChanges(resources: URI[]): void {
const {uri} = this._editor.getModel();
const { uri } = this._editor.getModel();
for (const resource of resources) {
if (resource.toString() === uri.toString()) {
this._onCursorChange();
......@@ -90,7 +90,7 @@ export class QuickFixOracle {
private _markerAtPosition(): IMarker {
const position = this._editor.getPosition();
const {uri} = this._editor.getModel();
const { uri } = this._editor.getModel();
const markers = this._markerService.read({ resource: uri }).sort(Range.compareRangesUsingStarts);
let idx = arrays.findFirst(markers, marker => marker.endLineNumber >= position.lineNumber);
......@@ -172,9 +172,9 @@ export class QuickFixModel {
}
}
triggerManual(): void {
trigger(type: 'auto' | 'manual'): void {
if (this._quickFixOracle) {
this._quickFixOracle.trigger();
this._quickFixOracle.trigger(type);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册