mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
Merge remote-tracking branch 'origin/master' into alex/semantic-exploration
This commit is contained in:
@@ -401,7 +401,10 @@ export default class BufferSyncSupport extends Disposable {
|
||||
this.pendingGetErr?.cancel();
|
||||
this.pendingDiagnostics.clear();
|
||||
this.synchronizer.reset();
|
||||
}
|
||||
|
||||
public reinitialize(): void {
|
||||
this.reset();
|
||||
for (const buffer of this.syncedBuffers.allBuffers) {
|
||||
buffer.open();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
|
||||
return undefined;
|
||||
}
|
||||
const { edit, fixedDiagnostics } = autoFixResponse;
|
||||
if (!edit.size) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const codeAction = new vscode.CodeAction(
|
||||
localize('autoFix.label', 'Auto fix'),
|
||||
TypeScriptAutoFixProvider.kind);
|
||||
@@ -105,11 +109,11 @@ class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
|
||||
};
|
||||
const response = await this.client.execute('getCodeFixes', args, token);
|
||||
if (response.type !== 'response' || !response.body || response.body.length > 1) {
|
||||
return undefined;
|
||||
continue;
|
||||
}
|
||||
|
||||
const fix = response.body[0];
|
||||
if (new Set<string>(['fixClassIncorrectlyImplementsInterface', 'spelling']).has(fix.fixName)) {
|
||||
if (['fixClassIncorrectlyImplementsInterface', 'spelling'].includes(fix.fixName)) {
|
||||
typeConverters.WorkspaceEdit.withFileCodeEdits(edit, this.client, fix.changes);
|
||||
fixedDiagnostics.push(diagnostic);
|
||||
}
|
||||
|
||||
@@ -182,8 +182,6 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
|
||||
private populateService(): void {
|
||||
this.fileConfigurationManager.reset();
|
||||
this.client.bufferSyncSupport.reset();
|
||||
this.client.bufferSyncSupport.requestAllDiagnostics();
|
||||
|
||||
// See https://github.com/Microsoft/TypeScript/issues/5530
|
||||
vscode.workspace.saveAll(false).then(() => {
|
||||
|
||||
@@ -82,7 +82,8 @@ namespace ServerState {
|
||||
export default class TypeScriptServiceClient extends Disposable implements ITypeScriptServiceClient {
|
||||
private static readonly WALK_THROUGH_SNIPPET_SCHEME_COLON = `${fileSchemes.walkThroughSnippet}:`;
|
||||
|
||||
private pathSeparator: string;
|
||||
private readonly pathSeparator: string;
|
||||
private readonly inMemoryResourcePrefix = '^';
|
||||
|
||||
private _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void; };
|
||||
private _configuration: TypeScriptServiceConfiguration;
|
||||
@@ -464,6 +465,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
private serviceStarted(resendModels: boolean): void {
|
||||
this.bufferSyncSupport.reset();
|
||||
|
||||
const configureOptions: Proto.ConfigureRequestArguments = {
|
||||
hostInfo: 'vscode',
|
||||
preferences: {
|
||||
@@ -475,6 +478,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
this.setCompilerOptionsForInferredProjects(this._configuration);
|
||||
if (resendModels) {
|
||||
this._onResendModelsRequested.fire();
|
||||
this.bufferSyncSupport.reinitialize();
|
||||
this.bufferSyncSupport.requestAllDiagnostics();
|
||||
}
|
||||
|
||||
// Reconfigure any plugins
|
||||
@@ -591,23 +596,18 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return this.toPath(document.uri) || undefined;
|
||||
}
|
||||
|
||||
private get inMemoryResourcePrefix(): string {
|
||||
return this.apiVersion.gte(API.v270) ? '^' : '';
|
||||
}
|
||||
|
||||
public toResource(filepath: string): vscode.Uri {
|
||||
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
|
||||
) {
|
||||
let resource = vscode.Uri.parse(filepath);
|
||||
if (this.inMemoryResourcePrefix) {
|
||||
const dirName = path.dirname(resource.path);
|
||||
const fileName = path.basename(resource.path);
|
||||
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
|
||||
resource = resource.with({
|
||||
path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length))
|
||||
});
|
||||
}
|
||||
const dirName = path.dirname(resource.path);
|
||||
const fileName = path.basename(resource.path);
|
||||
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
|
||||
resource = resource.with({
|
||||
path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length))
|
||||
});
|
||||
}
|
||||
|
||||
return this.bufferSyncSupport.toVsCodeResource(resource);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user