mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae
This commit is contained in:
committed by
AzureDataStudio
parent
a971aee5bd
commit
5e7071e466
@@ -94,10 +94,10 @@ export interface IEditorOptions {
|
||||
*/
|
||||
renderFinalNewline?: boolean;
|
||||
/**
|
||||
* Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS), NEXT LINE (NEL).
|
||||
* Defaults to true.
|
||||
* Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
|
||||
* Defaults to 'prompt'.
|
||||
*/
|
||||
removeUnusualLineTerminators?: boolean;
|
||||
unusualLineTerminators?: 'off' | 'prompt' | 'auto';
|
||||
/**
|
||||
* Should the corresponding line be selected when clicking on the line number?
|
||||
* Defaults to true.
|
||||
@@ -3560,7 +3560,6 @@ export const enum EditorOption {
|
||||
quickSuggestions,
|
||||
quickSuggestionsDelay,
|
||||
readOnly,
|
||||
removeUnusualLineTerminators,
|
||||
renameOnType,
|
||||
renderControlCharacters,
|
||||
renderIndentGuides,
|
||||
@@ -3590,6 +3589,7 @@ export const enum EditorOption {
|
||||
suggestOnTriggerCharacters,
|
||||
suggestSelection,
|
||||
tabCompletion,
|
||||
unusualLineTerminators,
|
||||
useTabStops,
|
||||
wordSeparators,
|
||||
wordWrap,
|
||||
@@ -3979,10 +3979,6 @@ export const EditorOptions = {
|
||||
readOnly: register(new EditorBooleanOption(
|
||||
EditorOption.readOnly, 'readOnly', false,
|
||||
)),
|
||||
removeUnusualLineTerminators: register(new EditorBooleanOption(
|
||||
EditorOption.removeUnusualLineTerminators, 'removeUnusualLineTerminators', true,
|
||||
{ description: nls.localize('removeUnusualLineTerminators', "Remove unusual line terminators that might cause problems.") }
|
||||
)),
|
||||
renameOnType: register(new EditorBooleanOption(
|
||||
EditorOption.renameOnType, 'renameOnType', false,
|
||||
{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type.") }
|
||||
@@ -4152,6 +4148,19 @@ export const EditorOptions = {
|
||||
description: nls.localize('tabCompletion', "Enables tab completions.")
|
||||
}
|
||||
)),
|
||||
unusualLineTerminators: register(new EditorStringEnumOption(
|
||||
EditorOption.unusualLineTerminators, 'unusualLineTerminators',
|
||||
'prompt' as 'off' | 'prompt' | 'auto',
|
||||
['off', 'prompt', 'auto'] as const,
|
||||
{
|
||||
enumDescriptions: [
|
||||
nls.localize('unusualLineTerminators.off', "Unusual line terminators are ignored."),
|
||||
nls.localize('unusualLineTerminators.prompt', "Unusual line terminators prompt to be removed."),
|
||||
nls.localize('unusualLineTerminators.auto', "Unusual line terminators are automatically removed."),
|
||||
],
|
||||
description: nls.localize('unusualLineTerminators', "Remove unusual line terminators that might cause problems.")
|
||||
}
|
||||
)),
|
||||
useTabStops: register(new EditorBooleanOption(
|
||||
EditorOption.useTabStops, 'useTabStops', true,
|
||||
{ description: nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops.") }
|
||||
|
||||
@@ -80,17 +80,17 @@ export class CursorMoveCommands {
|
||||
);
|
||||
}
|
||||
|
||||
public static moveToEndOfLine(viewModel: IViewModel, cursors: CursorState[], inSelectionMode: boolean): PartialCursorState[] {
|
||||
public static moveToEndOfLine(viewModel: IViewModel, cursors: CursorState[], inSelectionMode: boolean, sticky: boolean): PartialCursorState[] {
|
||||
let result: PartialCursorState[] = [];
|
||||
for (let i = 0, len = cursors.length; i < len; i++) {
|
||||
const cursor = cursors[i];
|
||||
result[i] = this._moveToLineEnd(viewModel, cursor, inSelectionMode);
|
||||
result[i] = this._moveToLineEnd(viewModel, cursor, inSelectionMode, sticky);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static _moveToLineEnd(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean): PartialCursorState {
|
||||
private static _moveToLineEnd(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean, sticky: boolean): PartialCursorState {
|
||||
const viewStatePosition = cursor.viewState.position;
|
||||
const viewModelMaxColumn = viewModel.getLineMaxColumn(viewStatePosition.lineNumber);
|
||||
const isEndOfViewLine = viewStatePosition.column === viewModelMaxColumn;
|
||||
@@ -100,21 +100,21 @@ export class CursorMoveCommands {
|
||||
const isEndLineOfWrappedLine = viewModelMaxColumn - viewStatePosition.column === modelMaxColumn - modelStatePosition.column;
|
||||
|
||||
if (isEndOfViewLine || isEndLineOfWrappedLine) {
|
||||
return this._moveToLineEndByModel(viewModel, cursor, inSelectionMode);
|
||||
return this._moveToLineEndByModel(viewModel, cursor, inSelectionMode, sticky);
|
||||
} else {
|
||||
return this._moveToLineEndByView(viewModel, cursor, inSelectionMode);
|
||||
return this._moveToLineEndByView(viewModel, cursor, inSelectionMode, sticky);
|
||||
}
|
||||
}
|
||||
|
||||
private static _moveToLineEndByView(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean): PartialCursorState {
|
||||
private static _moveToLineEndByView(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean, sticky: boolean): PartialCursorState {
|
||||
return CursorState.fromViewState(
|
||||
MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode)
|
||||
MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, sticky)
|
||||
);
|
||||
}
|
||||
|
||||
private static _moveToLineEndByModel(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean): PartialCursorState {
|
||||
private static _moveToLineEndByModel(viewModel: IViewModel, cursor: CursorState, inSelectionMode: boolean, sticky: boolean): PartialCursorState {
|
||||
return CursorState.fromModelState(
|
||||
MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode)
|
||||
MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode, sticky)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -404,13 +404,14 @@ export class CursorMoveCommands {
|
||||
}
|
||||
|
||||
private static _moveLeft(viewModel: IViewModel, cursors: CursorState[], inSelectionMode: boolean, noOfColumns: number): PartialCursorState[] {
|
||||
const hasMultipleCursors = (cursors.length > 1);
|
||||
let result: PartialCursorState[] = [];
|
||||
for (let i = 0, len = cursors.length; i < len; i++) {
|
||||
const cursor = cursors[i];
|
||||
|
||||
const skipWrappingPointStop = hasMultipleCursors || !cursor.viewState.hasSelection();
|
||||
let newViewState = MoveOperations.moveLeft(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns);
|
||||
|
||||
if (!cursor.viewState.hasSelection() && noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
|
||||
if (skipWrappingPointStop && noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
|
||||
// moved over to the previous view line
|
||||
const newViewModelPosition = viewModel.coordinatesConverter.convertViewPositionToModelPosition(newViewState.position);
|
||||
if (newViewModelPosition.lineNumber === cursor.modelState.position.lineNumber) {
|
||||
@@ -436,12 +437,14 @@ export class CursorMoveCommands {
|
||||
}
|
||||
|
||||
private static _moveRight(viewModel: IViewModel, cursors: CursorState[], inSelectionMode: boolean, noOfColumns: number): PartialCursorState[] {
|
||||
const hasMultipleCursors = (cursors.length > 1);
|
||||
let result: PartialCursorState[] = [];
|
||||
for (let i = 0, len = cursors.length; i < len; i++) {
|
||||
const cursor = cursors[i];
|
||||
const skipWrappingPointStop = hasMultipleCursors || !cursor.viewState.hasSelection();
|
||||
let newViewState = MoveOperations.moveRight(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns);
|
||||
|
||||
if (!cursor.viewState.hasSelection() && noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
|
||||
if (skipWrappingPointStop && noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
|
||||
// moved over to the next view line
|
||||
const newViewModelPosition = viewModel.coordinatesConverter.convertViewPositionToModelPosition(newViewState.position);
|
||||
if (newViewModelPosition.lineNumber === cursor.modelState.position.lineNumber) {
|
||||
|
||||
@@ -222,10 +222,10 @@ export class MoveOperations {
|
||||
return cursor.move(inSelectionMode, lineNumber, column, 0);
|
||||
}
|
||||
|
||||
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
|
||||
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, sticky: boolean): SingleCursorState {
|
||||
let lineNumber = cursor.position.lineNumber;
|
||||
let maxColumn = model.getLineMaxColumn(lineNumber);
|
||||
return cursor.move(inSelectionMode, lineNumber, maxColumn, Constants.MAX_SAFE_SMALL_INTEGER - maxColumn);
|
||||
return cursor.move(inSelectionMode, lineNumber, maxColumn, sticky ? Constants.MAX_SAFE_SMALL_INTEGER - maxColumn : 0);
|
||||
}
|
||||
|
||||
public static moveToBeginningOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
|
||||
|
||||
@@ -36,6 +36,8 @@ export namespace EditorContextKeys {
|
||||
export const canUndo = new RawContextKey<boolean>('canUndo', false);
|
||||
export const canRedo = new RawContextKey<boolean>('canRedo', false);
|
||||
|
||||
export const hoverVisible = new RawContextKey<boolean>('editorHoverVisible', false);
|
||||
|
||||
/**
|
||||
* A context key that is set when an editor is part of a larger editor, like notebooks or
|
||||
* (future) a diff editor
|
||||
|
||||
@@ -552,7 +552,7 @@ export interface ITextModel {
|
||||
mightContainRTL(): boolean;
|
||||
|
||||
/**
|
||||
* If true, the text model might contain LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS), NEXT LINE (NEL).
|
||||
* If true, the text model might contain LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
|
||||
* If false, the text model definitely does not contain these.
|
||||
* @internal
|
||||
*/
|
||||
|
||||
@@ -168,6 +168,16 @@ export class SingleModelEditStackElement implements IResourceUndoRedoElement {
|
||||
this._data = SingleModelEditStackData.create(model, beforeCursorState);
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
const data = (this._data instanceof SingleModelEditStackData ? this._data : SingleModelEditStackData.deserialize(this._data));
|
||||
return data.changes.map(change => change.toString()).join(', ');
|
||||
}
|
||||
|
||||
public matchesResource(resource: URI): boolean {
|
||||
const uri = (URI.isUri(this.model) ? this.model : this.model.uri);
|
||||
return (uri.toString() === resource.toString());
|
||||
}
|
||||
|
||||
public setModel(model: ITextModel | URI): void {
|
||||
this.model = model;
|
||||
}
|
||||
@@ -270,6 +280,11 @@ export class MultiModelEditStackElement implements IWorkspaceUndoRedoElement {
|
||||
return result;
|
||||
}
|
||||
|
||||
public matchesResource(resource: URI): boolean {
|
||||
const key = uriGetComparisonKey(resource);
|
||||
return (this._editStackElementsMap.has(key));
|
||||
}
|
||||
|
||||
public setModel(model: ITextModel | URI): void {
|
||||
const key = uriGetComparisonKey(URI.isUri(model) ? model : model.uri);
|
||||
if (this._editStackElementsMap.has(key)) {
|
||||
@@ -338,7 +353,7 @@ function getModelEOL(model: ITextModel): EndOfLineSequence {
|
||||
}
|
||||
}
|
||||
|
||||
function isKnownStackElement(element: IResourceUndoRedoElement | IWorkspaceUndoRedoElement | null): element is EditStackElement {
|
||||
export function isEditStackElement(element: IResourceUndoRedoElement | IWorkspaceUndoRedoElement | null): element is EditStackElement {
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
@@ -357,7 +372,7 @@ export class EditStack {
|
||||
|
||||
public pushStackElement(): void {
|
||||
const lastElement = this._undoRedoService.getLastElement(this._model.uri);
|
||||
if (isKnownStackElement(lastElement)) {
|
||||
if (isEditStackElement(lastElement)) {
|
||||
lastElement.close();
|
||||
}
|
||||
}
|
||||
@@ -368,7 +383,7 @@ export class EditStack {
|
||||
|
||||
private _getOrCreateEditStackElement(beforeCursorState: Selection[] | null): EditStackElement {
|
||||
const lastElement = this._undoRedoService.getLastElement(this._model.uri);
|
||||
if (isKnownStackElement(lastElement) && lastElement.canAppend(this._model)) {
|
||||
if (isEditStackElement(lastElement) && lastElement.canAppend(this._model)) {
|
||||
return lastElement;
|
||||
}
|
||||
const newElement = new SingleModelEditStackElement(this._model, beforeCursorState);
|
||||
|
||||
@@ -510,6 +510,32 @@ export class PieceTreeTextBuffer implements ITextBuffer, IDisposable {
|
||||
public getPieceTree(): PieceTreeBase {
|
||||
return this._pieceTree;
|
||||
}
|
||||
|
||||
public static _getInverseEditRange(range: Range, text: string) {
|
||||
let startLineNumber = range.startLineNumber;
|
||||
let startColumn = range.startColumn;
|
||||
const [eolCount, firstLineLength, lastLineLength] = countEOL(text);
|
||||
let resultRange: Range;
|
||||
|
||||
if (text.length > 0) {
|
||||
// the operation inserts something
|
||||
const lineCount = eolCount + 1;
|
||||
|
||||
if (lineCount === 1) {
|
||||
// single line insert
|
||||
resultRange = new Range(startLineNumber, startColumn, startLineNumber, startColumn + firstLineLength);
|
||||
} else {
|
||||
// multi line insert
|
||||
resultRange = new Range(startLineNumber, startColumn, startLineNumber + lineCount - 1, lastLineLength + 1);
|
||||
}
|
||||
} else {
|
||||
// There is nothing to insert
|
||||
resultRange = new Range(startLineNumber, startColumn, startLineNumber, startColumn);
|
||||
}
|
||||
|
||||
return resultRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assumes `operations` are validated and sorted ascending
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,16 @@ export class TextChange {
|
||||
public readonly newText: string
|
||||
) { }
|
||||
|
||||
public toString(): string {
|
||||
if (this.oldText.length === 0) {
|
||||
return `(insert@${this.oldPosition} "${this.newText}")`;
|
||||
}
|
||||
if (this.newText.length === 0) {
|
||||
return `(delete@${this.oldPosition} "${this.oldText}")`;
|
||||
}
|
||||
return `(replace@${this.oldPosition} "${this.oldText}" with "${this.newText}")`;
|
||||
}
|
||||
|
||||
private static _writeStringSize(str: string): number {
|
||||
return (
|
||||
4 + 2 * str.length
|
||||
|
||||
@@ -706,9 +706,8 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
public removeUnusualLineTerminators(selections: Selection[] | null = null): void {
|
||||
const matches = this.findMatches(strings.UNUSUAL_LINE_TERMINATORS.source, false, true, false, null, false, Constants.MAX_SAFE_SMALL_INTEGER);
|
||||
const eol = this.getEOL();
|
||||
this._buffer.resetMightContainUnusualLineTerminators();
|
||||
this.pushEditOperations(selections, matches.map(m => ({ range: m.range, text: eol })), () => null);
|
||||
this.pushEditOperations(selections, matches.map(m => ({ range: m.range, text: null })), () => null);
|
||||
}
|
||||
|
||||
public mightContainNonBasicASCII(): boolean {
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface ILanguageSelection extends IDisposable {
|
||||
}
|
||||
|
||||
export interface IModeService {
|
||||
_serviceBrand: undefined;
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
onDidCreateMode: Event<IMode>;
|
||||
onLanguagesMaybeChanged: Event<void>;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -240,36 +240,36 @@ export enum EditorOption {
|
||||
quickSuggestions = 70,
|
||||
quickSuggestionsDelay = 71,
|
||||
readOnly = 72,
|
||||
removeUnusualLineTerminators = 73,
|
||||
renameOnType = 74,
|
||||
renderControlCharacters = 75,
|
||||
renderIndentGuides = 76,
|
||||
renderFinalNewline = 77,
|
||||
renderLineHighlight = 78,
|
||||
renderLineHighlightOnlyWhenFocus = 79,
|
||||
renderValidationDecorations = 80,
|
||||
renderWhitespace = 81,
|
||||
revealHorizontalRightPadding = 82,
|
||||
roundedSelection = 83,
|
||||
rulers = 84,
|
||||
scrollbar = 85,
|
||||
scrollBeyondLastColumn = 86,
|
||||
scrollBeyondLastLine = 87,
|
||||
scrollPredominantAxis = 88,
|
||||
selectionClipboard = 89,
|
||||
selectionHighlight = 90,
|
||||
selectOnLineNumbers = 91,
|
||||
showFoldingControls = 92,
|
||||
showUnused = 93,
|
||||
snippetSuggestions = 94,
|
||||
smoothScrolling = 95,
|
||||
stopRenderingLineAfter = 96,
|
||||
suggest = 97,
|
||||
suggestFontSize = 98,
|
||||
suggestLineHeight = 99,
|
||||
suggestOnTriggerCharacters = 100,
|
||||
suggestSelection = 101,
|
||||
tabCompletion = 102,
|
||||
renameOnType = 73,
|
||||
renderControlCharacters = 74,
|
||||
renderIndentGuides = 75,
|
||||
renderFinalNewline = 76,
|
||||
renderLineHighlight = 77,
|
||||
renderLineHighlightOnlyWhenFocus = 78,
|
||||
renderValidationDecorations = 79,
|
||||
renderWhitespace = 80,
|
||||
revealHorizontalRightPadding = 81,
|
||||
roundedSelection = 82,
|
||||
rulers = 83,
|
||||
scrollbar = 84,
|
||||
scrollBeyondLastColumn = 85,
|
||||
scrollBeyondLastLine = 86,
|
||||
scrollPredominantAxis = 87,
|
||||
selectionClipboard = 88,
|
||||
selectionHighlight = 89,
|
||||
selectOnLineNumbers = 90,
|
||||
showFoldingControls = 91,
|
||||
showUnused = 92,
|
||||
snippetSuggestions = 93,
|
||||
smoothScrolling = 94,
|
||||
stopRenderingLineAfter = 95,
|
||||
suggest = 96,
|
||||
suggestFontSize = 97,
|
||||
suggestLineHeight = 98,
|
||||
suggestOnTriggerCharacters = 99,
|
||||
suggestSelection = 100,
|
||||
tabCompletion = 101,
|
||||
unusualLineTerminators = 102,
|
||||
useTabStops = 103,
|
||||
wordSeparators = 104,
|
||||
wordWrap = 105,
|
||||
|
||||
Reference in New Issue
Block a user