mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Show error if TS returns an empty refactoring
Fixes #70526 An empty refactoring response indicates that something went wrong
This commit is contained in:
@@ -4,15 +4,18 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
import { Command, CommandManager } from '../utils/commandManager';
|
||||
import { VersionDependentRegistration } from '../utils/dependentRegistration';
|
||||
import TelemetryReporter from '../utils/telemetry';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
import FormattingOptionsManager from './fileConfigurationManager';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
class ApplyRefactoringCommand implements Command {
|
||||
@@ -49,7 +52,12 @@ class ApplyRefactoringCommand implements Command {
|
||||
action,
|
||||
};
|
||||
const response = await this.client.execute('getEditsForRefactor', args, nulToken);
|
||||
if (response.type !== 'response' || !response.body || !response.body.edits.length) {
|
||||
if (response.type !== 'response' || !response.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!response.body.edits.length) {
|
||||
vscode.window.showErrorMessage(localize('refactoringFailed', "Could not apply refactoring"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user