Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae

This commit is contained in:
ADS Merger
2020-06-18 04:32:54 +00:00
committed by AzureDataStudio
parent a971aee5bd
commit 5e7071e466
1002 changed files with 24201 additions and 13193 deletions

View File

@@ -19,7 +19,7 @@ export interface IDiffComputationResult {
}
export interface IEditorWorkerService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
canComputeDiff(original: URI, modified: URI): boolean;
computeDiff(original: URI, modified: URI, ignoreTrimWhitespace: boolean, maxComputationTime: number): Promise<IDiffComputationResult | null>;

View File

@@ -46,7 +46,7 @@ function canSyncModel(modelService: IModelService, resource: URI): boolean {
export class EditorWorkerServiceImpl extends Disposable implements IEditorWorkerService {
_serviceBrand: undefined;
declare readonly _serviceBrand: undefined;
private readonly _modelService: IModelService;
private readonly _workerManager: WorkerManager;

View File

@@ -70,7 +70,7 @@ class MarkerDecorations extends Disposable {
export class MarkerDecorationsService extends Disposable implements IMarkerDecorationsService {
_serviceBrand: undefined;
declare readonly _serviceBrand: undefined;
private readonly _onDidChangeMarker = this._register(new Emitter<ITextModel>());
readonly onDidChangeMarker: Event<ITextModel> = this._onDidChangeMarker.event;

View File

@@ -12,7 +12,7 @@ import { Range } from 'vs/editor/common/core/range';
export const IMarkerDecorationsService = createDecorator<IMarkerDecorationsService>('markerDecorationsService');
export interface IMarkerDecorationsService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
onDidChangeMarker: Event<ITextModel>;

View File

@@ -28,7 +28,7 @@ export interface ILanguageSelection extends IDisposable {
}
export interface IModeService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
onDidCreateMode: Event<IMode>;
onLanguagesMaybeChanged: Event<void>;

View File

@@ -16,7 +16,7 @@ export const IModelService = createDecorator<IModelService>('modelService');
export type DocumentTokensProvider = DocumentSemanticTokensProvider | DocumentRangeSemanticTokensProvider;
export interface IModelService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget?: boolean): ITextModel;

View File

@@ -26,7 +26,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
import { IUndoRedoService, IUndoRedoElement, IPastFutureElements } from 'vs/platform/undoRedo/common/undoRedo';
import { StringSHA1 } from 'vs/base/common/hash';
import { SingleModelEditStackElement, MultiModelEditStackElement, EditStackElement } from 'vs/editor/common/model/editStack';
import { SingleModelEditStackElement, MultiModelEditStackElement, EditStackElement, isEditStackElement } from 'vs/editor/common/model/editStack';
import { Schemas } from 'vs/base/common/network';
import { SemanticTokensProviderStyling, toMultilineTokens2 } from 'vs/editor/common/services/semanticTokensProviderStyling';
@@ -139,6 +139,7 @@ class DisposedModelInfo {
constructor(
public readonly uri: URI,
public readonly time: number,
public readonly sharesUndoRedoStack: boolean,
public readonly heapSize: number,
public readonly sha1: string,
public readonly versionId: number,
@@ -352,7 +353,11 @@ export class ModelServiceImpl extends Disposable implements IModelService {
if (this._disposedModelsHeapSize > maxModelsHeapSize) {
// we must remove some old undo stack elements to free up some memory
const disposedModels: DisposedModelInfo[] = [];
this._disposedModels.forEach(entry => disposedModels.push(entry));
this._disposedModels.forEach(entry => {
if (!entry.sharesUndoRedoStack) {
disposedModels.push(entry);
}
});
disposedModels.sort((a, b) => a.time - b.time);
while (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {
const disposedModel = disposedModels.shift()!;
@@ -369,16 +374,23 @@ export class ModelServiceImpl extends Disposable implements IModelService {
if (resource && this._disposedModels.has(MODEL_ID(resource))) {
const disposedModelData = this._removeDisposedModel(resource)!;
const elements = this._undoRedoService.getElements(resource);
if (computeModelSha1(model) === disposedModelData.sha1 && isEditStackPastFutureElements(elements)) {
const sha1IsEqual = (computeModelSha1(model) === disposedModelData.sha1);
if (sha1IsEqual || disposedModelData.sharesUndoRedoStack) {
for (const element of elements.past) {
element.setModel(model);
if (isEditStackElement(element) && element.matchesResource(resource)) {
element.setModel(model);
}
}
for (const element of elements.future) {
element.setModel(model);
if (isEditStackElement(element) && element.matchesResource(resource)) {
element.setModel(model);
}
}
this._undoRedoService.setElementsValidFlag(resource, true, (element) => (isEditStackElement(element) && element.matchesResource(resource)));
if (sha1IsEqual) {
model._overwriteVersionId(disposedModelData.versionId);
model._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);
}
this._undoRedoService.setElementsIsValid(resource, true);
model._overwriteVersionId(disposedModelData.versionId);
model._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);
} else {
this._undoRedoService.removeElements(resource);
}
@@ -504,31 +516,39 @@ export class ModelServiceImpl extends Disposable implements IModelService {
return;
}
const model = modelData.model;
const sharesUndoRedoStack = (this._undoRedoService.getUriComparisonKey(model.uri) !== model.uri.toString());
let maintainUndoRedoStack = false;
let heapSize = 0;
if (this._shouldRestoreUndoStack() && (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote || resource.scheme === Schemas.userData)) {
if (sharesUndoRedoStack || (this._shouldRestoreUndoStack() && (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote || resource.scheme === Schemas.userData))) {
const elements = this._undoRedoService.getElements(resource);
if ((elements.past.length > 0 || elements.future.length > 0) && isEditStackPastFutureElements(elements)) {
maintainUndoRedoStack = true;
if (elements.past.length > 0 || elements.future.length > 0) {
for (const element of elements.past) {
heapSize += element.heapSize(resource);
element.setModel(resource); // remove reference from text buffer instance
if (isEditStackElement(element) && element.matchesResource(resource)) {
maintainUndoRedoStack = true;
heapSize += element.heapSize(resource);
element.setModel(resource); // remove reference from text buffer instance
}
}
for (const element of elements.future) {
heapSize += element.heapSize(resource);
element.setModel(resource); // remove reference from text buffer instance
if (isEditStackElement(element) && element.matchesResource(resource)) {
maintainUndoRedoStack = true;
heapSize += element.heapSize(resource);
element.setModel(resource); // remove reference from text buffer instance
}
}
}
}
if (!maintainUndoRedoStack) {
this._undoRedoService.removeElements(resource);
if (!sharesUndoRedoStack) {
this._undoRedoService.removeElements(resource);
}
modelData.model.dispose();
return;
}
const maxMemory = ModelServiceImpl.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;
if (heapSize > maxMemory) {
if (!sharesUndoRedoStack && heapSize > maxMemory) {
// the undo stack for this file would never fit in the configured memory, so don't bother with it.
this._undoRedoService.removeElements(resource);
modelData.model.dispose();
@@ -538,8 +558,8 @@ export class ModelServiceImpl extends Disposable implements IModelService {
this._ensureDisposedModelsHeapSize(maxMemory - heapSize);
// We only invalidate the elements, but they remain in the undo-redo service.
this._undoRedoService.setElementsIsValid(resource, false);
this._insertDisposedModel(new DisposedModelInfo(resource, Date.now(), heapSize, computeModelSha1(model), model.getVersionId(), model.getAlternativeVersionId()));
this._undoRedoService.setElementsValidFlag(resource, false, (element) => (isEditStackElement(element) && element.matchesResource(resource)));
this._insertDisposedModel(new DisposedModelInfo(resource, Date.now(), sharesUndoRedoStack, heapSize, computeModelSha1(model), model.getVersionId(), model.getAlternativeVersionId()));
modelData.model.dispose();
}

View File

@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
export const ITextModelService = createDecorator<ITextModelService>('textModelService');
export interface ITextModelService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
/**
* Provided a resource URI, it will return a model reference

View File

@@ -31,7 +31,7 @@ export interface ITextResourceConfigurationChangeEvent {
export interface ITextResourceConfigurationService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
/**
* Event that fires when the configuration changes.
@@ -70,7 +70,7 @@ export const ITextResourcePropertiesService = createDecorator<ITextResourcePrope
export interface ITextResourcePropertiesService {
_serviceBrand: undefined;
readonly _serviceBrand: undefined;
/**
* Returns the End of Line characters for the given resource

View File

@@ -28,9 +28,9 @@ export class TextResourceConfigurationService extends Disposable implements ITex
this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(this.toResourceConfigurationChangeEvent(e))));
}
getValue<T>(resource: URI, section?: string): T;
getValue<T>(resource: URI, at?: IPosition, section?: string): T;
getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
getValue<T>(resource: URI | undefined, section?: string): T;
getValue<T>(resource: URI | undefined, at?: IPosition, section?: string): T;
getValue<T>(resource: URI | undefined, arg2?: any, arg3?: any): T {
if (typeof arg3 === 'string') {
return this._getValue(resource, Position.isIPosition(arg2) ? arg2 : null, arg3);
}
@@ -98,7 +98,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex
return ConfigurationTarget.USER_LOCAL;
}
private _getValue<T>(resource: URI, position: IPosition | null, section: string | undefined): T {
private _getValue<T>(resource: URI | undefined, position: IPosition | null, section: string | undefined): T {
const language = resource ? this.getLanguage(resource, position) : undefined;
if (typeof section === 'undefined') {
return this.configurationService.getValue<T>({ resource, overrideIdentifier: language });