Fix organize import for empty file

Fixes #132637

We should not show the lightbulb when auto applying code actions
上级 e1cd33dd
......@@ -29,7 +29,7 @@ class OrganizeImportsCommand implements Command {
private readonly telemetryReporter: TelemetryReporter,
) { }
public async execute(file: string, sortOnly = false): Promise<boolean> {
public async execute(file: string, sortOnly = false): Promise<any> {
/* __GDPR__
"organizeImports.execute" : {
"${include}": [
......@@ -50,11 +50,13 @@ class OrganizeImportsCommand implements Command {
};
const response = await this.client.interruptGetErr(() => this.client.execute('organizeImports', args, nulToken));
if (response.type !== 'response' || !response.body) {
return false;
return;
}
const edits = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
return vscode.workspace.applyEdit(edits);
if (response.body.length) {
const edits = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
return vscode.workspace.applyEdit(edits);
}
}
}
......
......@@ -84,6 +84,7 @@ export class CodeActionUi extends Disposable {
const validActionToApply = this.tryGetValidActionToApply(newState.trigger, actions);
if (validActionToApply) {
try {
this._lightBulbWidget.getValue().hide();
await this.delegate.applyCodeAction(validActionToApply, false);
} finally {
actions.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册