提交 55021e21 编写于 作者: M Matt Bierner

Reduce nesting

上级 bc09f141
......@@ -44,51 +44,52 @@ export class CodeActionUi extends Disposable {
}
public async update(newState: CodeActionsState.State): Promise<void> {
if (newState.type === CodeActionsState.Type.Triggered) {
let actions: CodeActionSet;
try {
actions = await newState.actions;
} catch (e) {
onUnexpectedError(e);
return;
}
if (newState.type !== CodeActionsState.Type.Triggered) {
this._lightBulbWidget.hide();
return;
}
let actions: CodeActionSet;
try {
actions = await newState.actions;
} catch (e) {
onUnexpectedError(e);
return;
}
this._lightBulbWidget.update(actions, newState.position);
this._lightBulbWidget.update(actions, newState.position);
if (!actions.actions.length && newState.trigger.context) {
MessageController.get(this._editor).showMessage(newState.trigger.context.notAvailableMessage, newState.trigger.context.position);
this._activeCodeActions.value = actions;
return;
}
if (!actions.actions.length && newState.trigger.context) {
MessageController.get(this._editor).showMessage(newState.trigger.context.notAvailableMessage, newState.trigger.context.position);
this._activeCodeActions.value = actions;
return;
}
if (newState.trigger.type === 'manual') {
if (newState.trigger.filter && newState.trigger.filter.kind) {
// Triggered for specific scope
if (actions.actions.length > 0) {
// Apply if we only have one action or requested autoApply
if (newState.trigger.autoApply === CodeActionAutoApply.First || (newState.trigger.autoApply === CodeActionAutoApply.IfSingle && actions.actions.length === 1)) {
try {
await this.delegate.applyCodeAction(actions.actions[0], false);
} finally {
actions.dispose();
}
return;
if (newState.trigger.type === 'manual') {
if (newState.trigger.filter && newState.trigger.filter.kind) {
// Triggered for specific scope
if (actions.actions.length > 0) {
// Apply if we only have one action or requested autoApply
if (newState.trigger.autoApply === CodeActionAutoApply.First || (newState.trigger.autoApply === CodeActionAutoApply.IfSingle && actions.actions.length === 1)) {
try {
await this.delegate.applyCodeAction(actions.actions[0], false);
} finally {
actions.dispose();
}
return;
}
}
this._activeCodeActions.value = actions;
this._codeActionWidget.show(actions, newState.position);
} else {
// auto magically triggered
if (this._codeActionWidget.isVisible) {
// TODO: Figure out if we should update the showing menu?
actions.dispose();
} else {
this._activeCodeActions.value = actions;
}
}
this._activeCodeActions.value = actions;
this._codeActionWidget.show(actions, newState.position);
} else {
this._lightBulbWidget.hide();
// auto magically triggered
if (this._codeActionWidget.isVisible) {
// TODO: Figure out if we should update the showing menu?
actions.dispose();
} else {
this._activeCodeActions.value = actions;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册