提交 b228ffc4 编写于 作者: M Matt Bierner

Show progress while computing code actions

Fixes #49939
上级 4c57171e
......@@ -24,6 +24,7 @@ import { CodeActionContextMenu } from './codeActionWidget';
import { LightBulbWidget } from './lightBulbWidget';
import { escapeRegExpCharacters } from 'vs/base/common/strings';
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { IProgressService } from 'vs/platform/progress/common/progress';
function contextKeyForSupportedActions(kind: CodeActionKind) {
return ContextKeyExpr.regex(
......@@ -48,13 +49,14 @@ export class QuickFixController implements IEditorContribution {
constructor(editor: ICodeEditor,
@IMarkerService markerService: IMarkerService,
@IContextKeyService contextKeyService: IContextKeyService,
@ICommandService private readonly _commandService: ICommandService,
@IProgressService progressService: IProgressService,
@IContextMenuService contextMenuService: IContextMenuService,
@ICommandService private readonly _commandService: ICommandService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IBulkEditService private readonly _bulkEditService: IBulkEditService
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
) {
this._editor = editor;
this._model = new CodeActionModel(this._editor, markerService, contextKeyService);
this._model = new CodeActionModel(this._editor, markerService, contextKeyService, progressService);
this._codeActionContextMenu = new CodeActionContextMenu(editor, contextMenuService, action => this._onApplyCodeAction(action));
this._lightBulbWidget = new LightBulbWidget(editor);
......
......@@ -16,6 +16,7 @@ import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/cont
import { IMarkerService } from 'vs/platform/markers/common/markers';
import { getCodeActions } from './codeAction';
import { CodeActionTrigger } from './codeActionTrigger';
import { IProgressService } from 'vs/platform/progress/common/progress';
export const SUPPORTED_CODE_ACTIONS = new RawContextKey<string>('supportedCodeAction', '');
......@@ -25,9 +26,10 @@ export class CodeActionOracle {
constructor(
private _editor: ICodeEditor,
private _markerService: IMarkerService,
private readonly _markerService: IMarkerService,
private _signalChange: (e: CodeActionsComputeEvent) => any,
delay: number = 250
delay: number = 250,
private readonly _progressService?: IProgressService,
) {
this._disposables.push(
debounceEvent(this._markerService.onMarkerChanged, (last, cur) => last ? last.concat(cur) : cur, delay / 2)(e => this._onMarkerChanges(e)),
......@@ -113,6 +115,10 @@ export class CodeActionOracle {
const position = markerRange ? markerRange.getStartPosition() : selection.getStartPosition();
const actions = getCodeActions(model, selection, trigger && trigger.filter);
if (this._progressService) {
this._progressService.showWhile(actions, 250);
}
this._signalChange({
trigger,
rangeOrSelection: selection,
......@@ -140,7 +146,7 @@ export class CodeActionModel {
private _disposables: IDisposable[] = [];
private readonly _supportedCodeActions: IContextKey<string>;
constructor(editor: ICodeEditor, markerService: IMarkerService, contextKeyService: IContextKeyService) {
constructor(editor: ICodeEditor, markerService: IMarkerService, contextKeyService: IContextKeyService, private readonly _progressService: IProgressService) {
this._editor = editor;
this._markerService = markerService;
......@@ -183,7 +189,7 @@ export class CodeActionModel {
this._supportedCodeActions.set(supportedActions.join(' '));
this._codeActionOracle = new CodeActionOracle(this._editor, this._markerService, p => this._onDidChangeFixes.fire(p));
this._codeActionOracle = new CodeActionOracle(this._editor, this._markerService, p => this._onDidChangeFixes.fire(p), undefined, this._progressService);
this._codeActionOracle.trigger({ type: 'auto' });
} else {
this._supportedCodeActions.reset();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册