Merge from vscode 2cd495805cf99b31b6926f08ff4348124b2cf73d

This commit is contained in:
ADS Merger
2020-06-30 04:40:21 +00:00
committed by AzureDataStudio
parent a8a7559229
commit 1388493cc1
602 changed files with 16375 additions and 12940 deletions

View File

@@ -503,8 +503,13 @@ const editorConfiguration: IConfigurationNode = {
description: nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
},
'editor.semanticHighlighting.enabled': {
type: 'boolean',
default: true,
enum: [true, false, 'configuredByTheme'],
enumDescriptions: [
nls.localize('semanticHighlighting.true', 'Semantic highlighting enabled for all color themes.'),
nls.localize('semanticHighlighting.false', 'Semantic highlighting disabled for all color themes.'),
nls.localize('semanticHighlighting.configuredByTheme', 'Semantic highlighting is configured by the current color theme\'s `semanticHighlighting` setting.')
],
default: 'configuredByTheme',
description: nls.localize('semanticHighlighting.enabled', "Controls whether the semanticHighlighting is shown for the languages that support it.")
},
'editor.stablePeek': {

View File

@@ -594,6 +594,10 @@ export interface IEditorOptions {
* Defaults to false.
*/
definitionLinkOpensInPeek?: boolean;
/**
* Controls strikethrough deprecated variables.
*/
showDeprecated?: boolean;
}
export interface IEditorConstructionOptions extends IEditorOptions {
@@ -1219,22 +1223,28 @@ class EditorClassName extends ComputedEditorOption<EditorOption.editorClassName,
}
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string {
let className = 'monaco-editor';
const classNames = ['monaco-editor'];
if (options.get(EditorOption.extraEditorClassName)) {
className += ' ' + options.get(EditorOption.extraEditorClassName);
classNames.push(options.get(EditorOption.extraEditorClassName));
}
if (env.extraEditorClassName) {
className += ' ' + env.extraEditorClassName;
classNames.push(env.extraEditorClassName);
}
if (options.get(EditorOption.mouseStyle) === 'default') {
className += ' mouse-default';
classNames.push('mouse-default');
} else if (options.get(EditorOption.mouseStyle) === 'copy') {
className += ' mouse-copy';
classNames.push('mouse-copy');
}
if (options.get(EditorOption.showUnused)) {
className += ' showUnused';
classNames.push('showUnused');
}
return className;
if (options.get(EditorOption.showDeprecated)) {
classNames.push('showDeprecated');
}
return classNames.join(' ');
}
}
@@ -3599,6 +3609,7 @@ export const enum EditorOption {
wordWrapMinified,
wrappingIndent,
wrappingStrategy,
showDeprecated,
// Leave these at the end (because they have dependencies!)
editorClassName,
@@ -4085,6 +4096,10 @@ export const EditorOptions = {
EditorOption.showUnused, 'showUnused', true,
{ description: nls.localize('showUnused', "Controls fading out of unused code.") }
)),
showDeprecated: register(new EditorBooleanOption(
EditorOption.showDeprecated, 'showDeprecated', true,
{ description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") }
)),
snippetSuggestions: register(new EditorStringEnumOption(
EditorOption.snippetSuggestions, 'snippetSuggestions',
'inline' as 'top' | 'bottom' | 'inline' | 'none',

View File

@@ -163,11 +163,9 @@ export class WordOperations {
public static moveWordLeft(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, position: Position, wordNavigationType: WordNavigationType): Position {
let lineNumber = position.lineNumber;
let column = position.column;
let movedToPreviousLine = false;
if (column === 1) {
if (lineNumber > 1) {
movedToPreviousLine = true;
lineNumber = lineNumber - 1;
column = model.getLineMaxColumn(lineNumber);
}
@@ -176,17 +174,6 @@ export class WordOperations {
let prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, column));
if (wordNavigationType === WordNavigationType.WordStart) {
if (prevWordOnLine && !movedToPreviousLine) {
// Special case for Visual Studio compatibility:
// when starting in the trim whitespace at the end of a line,
// go to the end of the last word
const lastWhitespaceColumn = model.getLineLastNonWhitespaceColumn(lineNumber);
if (lastWhitespaceColumn < column) {
return new Position(lineNumber, prevWordOnLine.end + 1);
}
}
return new Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
}

View File

@@ -41,7 +41,6 @@ export class InternalEditorAction implements IEditorAction {
return Promise.resolve(undefined);
}
const r = this._run();
return r ? r : Promise.resolve(undefined);
return this._run();
}
}

View File

@@ -35,7 +35,7 @@ import { VSBufferReadableStream, VSBuffer } from 'vs/base/common/buffer';
import { TokensStore, MultilineTokens, countEOL, MultilineTokens2, TokensStore2 } from 'vs/editor/common/model/tokensStore';
import { Color } from 'vs/base/common/color';
import { EditorTheme } from 'vs/editor/common/view/viewContext';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { IUndoRedoService, ResourceEditStackSnapshot } from 'vs/platform/undoRedo/common/undoRedo';
import { TextChange } from 'vs/editor/common/model/textChange';
import { Constants } from 'vs/base/common/uint';
@@ -278,6 +278,7 @@ export class TextModel extends Disposable implements model.ITextModel {
* Unlike, versionId, this can go down (via undo) or go to previous values (via redo)
*/
private _alternativeVersionId: number;
private _initialUndoRedoSnapshot: ResourceEditStackSnapshot | null;
private readonly _isTooLargeForSyncing: boolean;
private readonly _isTooLargeForTokenization: boolean;
@@ -351,6 +352,7 @@ export class TextModel extends Disposable implements model.ITextModel {
this._versionId = 1;
this._alternativeVersionId = 1;
this._initialUndoRedoSnapshot = null;
this._isDisposed = false;
this._isDisposing = false;
@@ -719,6 +721,11 @@ export class TextModel extends Disposable implements model.ITextModel {
return this._alternativeVersionId;
}
public getInitialUndoRedoSnapshot(): ResourceEditStackSnapshot | null {
this._assertNotDisposed();
return this._initialUndoRedoSnapshot;
}
public getOffsetAt(rawPosition: IPosition): number {
this._assertNotDisposed();
let position = this._validatePosition(rawPosition.lineNumber, rawPosition.column, StringOffsetValidationType.Relaxed);
@@ -744,6 +751,10 @@ export class TextModel extends Disposable implements model.ITextModel {
this._alternativeVersionId = newAlternativeVersionId;
}
public _overwriteInitialUndoRedoSnapshot(newInitialUndoRedoSnapshot: ResourceEditStackSnapshot | null): void {
this._initialUndoRedoSnapshot = newInitialUndoRedoSnapshot;
}
public getValue(eol?: model.EndOfLinePreference, preserveBOM: boolean = false): string {
this._assertNotDisposed();
const fullModelRange = this.getFullModelRange();
@@ -1187,6 +1198,9 @@ export class TextModel extends Disposable implements model.ITextModel {
try {
this._onDidChangeDecorations.beginDeferredEmit();
this._eventEmitter.beginDeferredEmit();
if (this._initialUndoRedoSnapshot === null) {
this._initialUndoRedoSnapshot = this._undoRedoService.createSnapshot(this.uri);
}
this._commandManager.pushEOL(eol);
} finally {
this._eventEmitter.endDeferredEmit();
@@ -1311,6 +1325,9 @@ export class TextModel extends Disposable implements model.ITextModel {
this._trimAutoWhitespaceLines = null;
}
if (this._initialUndoRedoSnapshot === null) {
this._initialUndoRedoSnapshot = this._undoRedoService.createSnapshot(this.uri);
}
return this._commandManager.pushEditOperation(beforeCursorState, editOperations, cursorStateComputer);
}

View File

@@ -548,8 +548,12 @@ export class Searcher {
if (matchStartIndex === this._prevMatchStartIndex && matchLength === this._prevMatchLength) {
if (matchLength === 0) {
// the search result is an empty string and won't advance `regex.lastIndex`, so `regex.exec` will stuck here
// we attempt to recover from that by advancing by one
this._searchRegex.lastIndex += 1;
// we attempt to recover from that by advancing by two if surrogate pair found and by one otherwise
if (strings.getNextCodePoint(text, textLength, this._searchRegex.lastIndex) > 0xFFFF) {
this._searchRegex.lastIndex += 2;
} else {
this._searchRegex.lastIndex += 1;
}
continue;
}
// Exit early if the regex matches the same range twice

View File

@@ -5,6 +5,7 @@
import { IRelativePattern, match as matchGlobPattern } from 'vs/base/common/glob';
import { URI } from 'vs/base/common/uri'; // TODO@Alex
import { normalize } from 'vs/base/common/path';
export interface LanguageFilter {
language?: string;
@@ -83,7 +84,19 @@ export function score(selector: LanguageSelector | undefined, candidateUri: URI,
}
if (pattern) {
if (pattern === candidateUri.fsPath || matchGlobPattern(pattern, candidateUri.fsPath)) {
let normalizedPattern: string | IRelativePattern;
if (typeof pattern === 'string') {
normalizedPattern = pattern;
} else {
// Since this pattern has a `base` property, we need
// to normalize this path first before passing it on
// because we will compare it against `Uri.fsPath`
// which uses platform specific separators.
// Refs: https://github.com/microsoft/vscode/issues/99938
normalizedPattern = { ...pattern, base: normalize(pattern.base) };
}
if (normalizedPattern === candidateUri.fsPath || matchGlobPattern(normalizedPattern, candidateUri.fsPath)) {
ret = 10;
} else {
return 0;

View File

@@ -154,7 +154,7 @@ function getClassifier(): CharacterClassifier<CharacterClass> {
if (_classifier === null) {
_classifier = new CharacterClassifier<CharacterClass>(CharacterClass.None);
const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…';
const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…';
for (let i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
_classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), CharacterClass.ForceTermination);
}

View File

@@ -22,6 +22,7 @@ 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';
import { canceled } from 'vs/base/common/errors';
/**
* Stop syncing a model to the worker if it was not needed for 1 min.
@@ -380,6 +381,7 @@ export class EditorWorkerClient extends Disposable {
private _worker: IWorkerClient<EditorSimpleWorker> | null;
private readonly _workerFactory: DefaultWorkerFactory;
private _modelManager: EditorModelManager | null;
private _disposed = false;
constructor(modelService: IModelService, keepIdleModels: boolean, label: string | undefined) {
super();
@@ -427,6 +429,9 @@ export class EditorWorkerClient extends Disposable {
}
protected _withSyncedResources(resources: URI[]): Promise<EditorSimpleWorker> {
if (this._disposed) {
return Promise.reject(canceled());
}
return this._getProxy().then((proxy) => {
this._getOrCreateModelManager(proxy).ensureSyncedResources(resources);
return proxy;
@@ -495,4 +500,9 @@ export class EditorWorkerClient extends Disposable {
return proxy.navigateValueSet(resource.toString(), range, up, wordDef, wordDefFlags);
});
}
dispose(): void {
super.dispose();
this._disposed = true;
}
}

View File

@@ -24,14 +24,14 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
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 { IUndoRedoService, IUndoRedoElement, IPastFutureElements, ResourceEditStackSnapshot } from 'vs/platform/undoRedo/common/undoRedo';
import { StringSHA1 } from 'vs/base/common/hash';
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';
export interface IEditorSemanticHighlightingOptions {
enabled?: boolean;
enabled: true | false | 'configuredByTheme';
}
function MODEL_ID(resource: URI): string {
@@ -51,7 +51,7 @@ function computeModelSha1(model: ITextModel): string {
class ModelData implements IDisposable {
public readonly model: ITextModel;
public readonly model: TextModel;
private _languageSelection: ILanguageSelection | null;
private _languageSelectionListener: IDisposable | null;
@@ -59,7 +59,7 @@ class ModelData implements IDisposable {
private readonly _modelEventListeners = new DisposableStore();
constructor(
model: ITextModel,
model: TextModel,
onWillDispose: (model: ITextModel) => void,
onDidChangeLanguage: (model: ITextModel, e: IModelLanguageChangedEvent) => void
) {
@@ -138,6 +138,7 @@ function isEditStackElements(elements: IUndoRedoElement[]): elements is EditStac
class DisposedModelInfo {
constructor(
public readonly uri: URI,
public readonly initialUndoRedoSnapshot: ResourceEditStackSnapshot | null,
public readonly time: number,
public readonly sharesUndoRedoStack: boolean,
public readonly heapSize: number,
@@ -362,7 +363,9 @@ export class ModelServiceImpl extends Disposable implements IModelService {
while (disposedModels.length > 0 && this._disposedModelsHeapSize > maxModelsHeapSize) {
const disposedModel = disposedModels.shift()!;
this._removeDisposedModel(disposedModel.uri);
this._undoRedoService.removeElements(disposedModel.uri);
if (disposedModel.initialUndoRedoSnapshot !== null) {
this._undoRedoService.restoreSnapshot(disposedModel.initialUndoRedoSnapshot);
}
}
}
}
@@ -390,9 +393,12 @@ export class ModelServiceImpl extends Disposable implements IModelService {
if (sha1IsEqual) {
model._overwriteVersionId(disposedModelData.versionId);
model._overwriteAlternativeVersionId(disposedModelData.alternativeVersionId);
model._overwriteInitialUndoRedoSnapshot(disposedModelData.initialUndoRedoSnapshot);
}
} else {
this._undoRedoService.removeElements(resource);
if (disposedModelData.initialUndoRedoSnapshot !== null) {
this._undoRedoService.restoreSnapshot(disposedModelData.initialUndoRedoSnapshot);
}
}
}
const modelId = MODEL_ID(model.uri);
@@ -541,7 +547,10 @@ export class ModelServiceImpl extends Disposable implements IModelService {
if (!maintainUndoRedoStack) {
if (!sharesUndoRedoStack) {
this._undoRedoService.removeElements(resource);
const initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();
if (initialUndoRedoSnapshot !== null) {
this._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);
}
}
modelData.model.dispose();
return;
@@ -550,7 +559,10 @@ export class ModelServiceImpl extends Disposable implements IModelService {
const maxMemory = ModelServiceImpl.MAX_MEMORY_FOR_CLOSED_FILES_UNDO_STACK;
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);
const initialUndoRedoSnapshot = modelData.model.getInitialUndoRedoSnapshot();
if (initialUndoRedoSnapshot !== null) {
this._undoRedoService.restoreSnapshot(initialUndoRedoSnapshot);
}
modelData.model.dispose();
return;
}
@@ -559,7 +571,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
// We only invalidate the elements, but they remain in the undo-redo service.
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()));
this._insertDisposedModel(new DisposedModelInfo(resource, modelData.model.getInitialUndoRedoSnapshot(), Date.now(), sharesUndoRedoStack, heapSize, computeModelSha1(model), model.getVersionId(), model.getAlternativeVersionId()));
modelData.model.dispose();
}
@@ -621,11 +633,11 @@ export interface ILineSequence {
export const SEMANTIC_HIGHLIGHTING_SETTING_ID = 'editor.semanticHighlighting';
export function isSemanticColoringEnabled(model: ITextModel, themeService: IThemeService, configurationService: IConfigurationService): boolean {
if (!themeService.getColorTheme().semanticHighlighting) {
return false;
const setting = configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri })?.enabled;
if (typeof setting === 'boolean') {
return setting;
}
const options = configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri });
return Boolean(options && options.enabled);
return themeService.getColorTheme().semanticHighlighting;
}
class SemanticColoringFeature extends Disposable {

View File

@@ -279,11 +279,12 @@ export enum EditorOption {
wordWrapMinified = 109,
wrappingIndent = 110,
wrappingStrategy = 111,
editorClassName = 112,
pixelRatio = 113,
tabFocusMode = 114,
layoutInfo = 115,
wrappingInfo = 116
showDeprecated = 112,
editorClassName = 113,
pixelRatio = 114,
tabFocusMode = 115,
layoutInfo = 116,
wrappingInfo = 117
}
/**

View File

@@ -210,12 +210,12 @@ export class ViewLayout extends Disposable implements IViewLayout {
const width = layoutInfo.contentWidth;
const height = layoutInfo.height;
const scrollDimensions = this._scrollable.getScrollDimensions();
const scrollWidth = scrollDimensions.scrollWidth;
const contentWidth = scrollDimensions.contentWidth;
this._scrollable.setScrollDimensions(new EditorScrollDimensions(
width,
scrollDimensions.contentWidth,
height,
this._getContentHeight(width, height, scrollWidth)
this._getContentHeight(width, height, contentWidth)
));
} else {
this._updateHeight();
@@ -250,14 +250,14 @@ export class ViewLayout extends Disposable implements IViewLayout {
return scrollbar.horizontalScrollbarSize;
}
private _getContentHeight(width: number, height: number, scrollWidth: number): number {
private _getContentHeight(width: number, height: number, contentWidth: number): number {
const options = this._configuration.options;
let result = this._linesLayout.getLinesTotalHeight();
if (options.get(EditorOption.scrollBeyondLastLine)) {
result += height - options.get(EditorOption.lineHeight);
} else {
result += this._getHorizontalScrollbarHeight(width, scrollWidth);
result += this._getHorizontalScrollbarHeight(width, contentWidth);
}
return result;
@@ -267,12 +267,12 @@ export class ViewLayout extends Disposable implements IViewLayout {
const scrollDimensions = this._scrollable.getScrollDimensions();
const width = scrollDimensions.width;
const height = scrollDimensions.height;
const scrollWidth = scrollDimensions.scrollWidth;
const contentWidth = scrollDimensions.contentWidth;
this._scrollable.setScrollDimensions(new EditorScrollDimensions(
width,
scrollDimensions.contentWidth,
height,
this._getContentHeight(width, height, scrollWidth)
this._getContentHeight(width, height, contentWidth)
));
}