Merge from vscode 3a6dcb42008d509900b3a3b2d695564eeb4dbdac (#5098)

This commit is contained in:
Alan Ren
2019-04-17 23:38:44 -07:00
committed by GitHub
parent 1fec26c6b3
commit b852f032d3
63 changed files with 676 additions and 413 deletions

View File

@@ -399,7 +399,7 @@ export abstract class BaseEditorSimpleWorker {
// ---- BEGIN minimal edits ---------------------------------------------------------------
private static readonly _diffLimit = 10000;
private static readonly _diffLimit = 100000;
public computeMoreMinimalEdits(modelUrl: string, edits: TextEdit[]): Promise<TextEdit[]> {
const model = this._getModel(modelUrl);
@@ -432,7 +432,7 @@ export abstract class BaseEditorSimpleWorker {
}
const original = model.getValueInRange(range);
text = text!.replace(/\r\n|\n|\r/g, model.eol);
text = text.replace(/\r\n|\n|\r/g, model.eol);
if (original === text) {
// noop

View File

@@ -21,6 +21,8 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { regExpFlags } from 'vs/base/common/strings';
import { isNonEmptyArray } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
import { StopWatch } from 'vs/base/common/stopwatch';
/**
* Stop syncing a model to the worker if it was not needed for 1 min.
@@ -48,14 +50,16 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
private readonly _modelService: IModelService;
private readonly _workerManager: WorkerManager;
private readonly _logService: ILogService;
constructor(
@IModelService modelService: IModelService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@ILogService logService: ILogService
) {
super();
this._modelService = modelService;
this._workerManager = this._register(new WorkerManager(this._modelService));
this._logService = logService;
// todo@joh make sure this happens only once
this._register(modes.LinkProviderRegistry.register('*', {
@@ -96,7 +100,10 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
if (!canSyncModel(this._modelService, resource)) {
return Promise.resolve(edits); // File too large
}
return this._workerManager.withWorker().then(client => client.computeMoreMinimalEdits(resource, edits));
const sw = StopWatch.create(true);
const result = this._workerManager.withWorker().then(client => client.computeMoreMinimalEdits(resource, edits));
result.finally(() => this._logService.trace('FORMAT#computeMoreMinimalEdits', resource.toString(true), sw.elapsed()));
return result;
} else {
return Promise.resolve(undefined);