mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 9bc92b48d945144abb405b9e8df05e18accb9148
This commit is contained in:
@@ -287,6 +287,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements IC
|
||||
public options!: ComputedEditorOptions;
|
||||
|
||||
private _isDominatedByLongLines: boolean;
|
||||
private _maxLineNumber: number;
|
||||
private _lineNumbersDigitCount: number;
|
||||
|
||||
private _rawOptions: IEditorOptions;
|
||||
@@ -298,6 +299,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements IC
|
||||
this.isSimpleWidget = isSimpleWidget;
|
||||
|
||||
this._isDominatedByLongLines = false;
|
||||
this._maxLineNumber = 1;
|
||||
this._lineNumbersDigitCount = 1;
|
||||
|
||||
this._rawOptions = deepCloneAndMigrateOptions(_options);
|
||||
@@ -347,6 +349,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements IC
|
||||
fontInfo: this.readConfiguration(bareFontInfo),
|
||||
extraEditorClassName: partialEnv.extraEditorClassName,
|
||||
isDominatedByLongLines: this._isDominatedByLongLines,
|
||||
maxLineNumber: this._maxLineNumber,
|
||||
lineNumbersDigitCount: this._lineNumbersDigitCount,
|
||||
emptySelectionClipboard: partialEnv.emptySelectionClipboard,
|
||||
pixelRatio: partialEnv.pixelRatio,
|
||||
@@ -405,11 +408,11 @@ export abstract class CommonEditorConfiguration extends Disposable implements IC
|
||||
}
|
||||
|
||||
public setMaxLineNumber(maxLineNumber: number): void {
|
||||
let digitCount = CommonEditorConfiguration._digitCount(maxLineNumber);
|
||||
if (this._lineNumbersDigitCount === digitCount) {
|
||||
if (this._maxLineNumber === maxLineNumber) {
|
||||
return;
|
||||
}
|
||||
this._lineNumbersDigitCount = digitCount;
|
||||
this._maxLineNumber = maxLineNumber;
|
||||
this._lineNumbersDigitCount = CommonEditorConfiguration._digitCount(maxLineNumber);
|
||||
this._recomputeOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -678,6 +678,7 @@ export interface IEnvironmentalOptions {
|
||||
readonly fontInfo: FontInfo;
|
||||
readonly extraEditorClassName: string;
|
||||
readonly isDominatedByLongLines: boolean;
|
||||
readonly maxLineNumber: number;
|
||||
readonly lineNumbersDigitCount: number;
|
||||
readonly emptySelectionClipboard: boolean;
|
||||
readonly pixelRatio: number;
|
||||
@@ -1691,6 +1692,14 @@ export interface EditorLayoutInfo {
|
||||
* The width of the minimap
|
||||
*/
|
||||
readonly minimapWidth: number;
|
||||
readonly minimapHeightIsEditorHeight: boolean;
|
||||
readonly minimapIsSampling: boolean;
|
||||
readonly minimapScale: number;
|
||||
readonly minimapLineHeight: number;
|
||||
readonly minimapCanvasInnerWidth: number;
|
||||
readonly minimapCanvasInnerHeight: number;
|
||||
readonly minimapCanvasOuterWidth: number;
|
||||
readonly minimapCanvasOuterHeight: number;
|
||||
|
||||
/**
|
||||
* Minimap render type
|
||||
@@ -1724,6 +1733,7 @@ export interface EditorLayoutInfoComputerEnv {
|
||||
outerWidth: number;
|
||||
outerHeight: number;
|
||||
lineHeight: number;
|
||||
maxLineNumber: number;
|
||||
lineNumbersDigitCount: number;
|
||||
typicalHalfwidthCharacterWidth: number;
|
||||
maxDigitWidth: number;
|
||||
@@ -1747,6 +1757,7 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
outerWidth: env.outerWidth,
|
||||
outerHeight: env.outerHeight,
|
||||
lineHeight: env.fontInfo.lineHeight,
|
||||
maxLineNumber: env.maxLineNumber,
|
||||
lineNumbersDigitCount: env.lineNumbersDigitCount,
|
||||
typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
|
||||
maxDigitWidth: env.fontInfo.maxDigitWidth,
|
||||
@@ -1754,6 +1765,20 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
});
|
||||
}
|
||||
|
||||
public static computeContainedMinimapLineCount(input: {
|
||||
modelLineCount: number;
|
||||
scrollBeyondLastLine: boolean;
|
||||
height: number;
|
||||
lineHeight: number;
|
||||
pixelRatio: number;
|
||||
}): { typicalViewportLineCount: number; extraLinesBeyondLastLine: number; desiredRatio: number; minimapLineCount: number; } {
|
||||
const typicalViewportLineCount = input.height / input.lineHeight;
|
||||
const extraLinesBeyondLastLine = input.scrollBeyondLastLine ? (typicalViewportLineCount - 1) : 0;
|
||||
const desiredRatio = (input.modelLineCount + extraLinesBeyondLastLine) / (input.pixelRatio * input.height);
|
||||
const minimapLineCount = Math.floor(input.modelLineCount / desiredRatio);
|
||||
return { typicalViewportLineCount, extraLinesBeyondLastLine, desiredRatio, minimapLineCount };
|
||||
}
|
||||
|
||||
public static computeLayout(options: IComputedEditorOptions, env: EditorLayoutInfoComputerEnv): EditorLayoutInfo {
|
||||
const outerWidth = env.outerWidth | 0;
|
||||
const outerHeight = env.outerHeight | 0;
|
||||
@@ -1766,12 +1791,14 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
const showGlyphMargin = options.get(EditorOption.glyphMargin);
|
||||
const showLineNumbers = (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off);
|
||||
const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars) | 0;
|
||||
const scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine);
|
||||
const minimap = options.get(EditorOption.minimap);
|
||||
const minimapEnabled = minimap.enabled;
|
||||
const minimapSide = minimap.side;
|
||||
const minimapRenderCharacters = minimap.renderCharacters;
|
||||
const minimapScale = (pixelRatio >= 2 ? Math.round(minimap.scale * 2) : minimap.scale);
|
||||
let minimapScale = (pixelRatio >= 2 ? Math.round(minimap.scale * 2) : minimap.scale);
|
||||
const minimapMaxColumn = minimap.maxColumn | 0;
|
||||
const minimapMode = minimap.mode;
|
||||
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
const verticalScrollbarWidth = scrollbar.verticalScrollbarSize | 0;
|
||||
@@ -1811,19 +1838,65 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
|
||||
const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;
|
||||
|
||||
const baseCharHeight = minimapRenderCharacters ? 2 : 3;
|
||||
let renderMinimap: RenderMinimap;
|
||||
let minimapLeft: number;
|
||||
let minimapWidth: number;
|
||||
let minimapCanvasInnerWidth: number;
|
||||
let minimapCanvasInnerHeight = Math.floor(pixelRatio * outerHeight);
|
||||
let minimapCanvasOuterWidth: number;
|
||||
const minimapCanvasOuterHeight = minimapCanvasInnerHeight / pixelRatio;
|
||||
let minimapHeightIsEditorHeight = false;
|
||||
let minimapIsSampling = false;
|
||||
let minimapLineHeight = baseCharHeight * minimapScale;
|
||||
let contentWidth: number;
|
||||
if (!minimapEnabled) {
|
||||
minimapLeft = 0;
|
||||
minimapWidth = 0;
|
||||
minimapCanvasInnerWidth = 0;
|
||||
minimapCanvasOuterWidth = 0;
|
||||
minimapLineHeight = 1;
|
||||
renderMinimap = RenderMinimap.None;
|
||||
contentWidth = remainingWidth;
|
||||
} else {
|
||||
// The minimapScale is also the pixel width of each character. Adjust
|
||||
// for the pixel ratio of the screen.
|
||||
const minimapCharWidth = minimapScale / pixelRatio;
|
||||
let minimapCharWidth = minimapScale / pixelRatio;
|
||||
let minimapWidthMultiplier: number = 1;
|
||||
|
||||
if (minimapMode === 'cover' || minimapMode === 'contain') {
|
||||
const modelLineCount = env.maxLineNumber;
|
||||
const { typicalViewportLineCount, extraLinesBeyondLastLine, desiredRatio, minimapLineCount } = EditorLayoutInfoComputer.computeContainedMinimapLineCount({
|
||||
modelLineCount: modelLineCount,
|
||||
scrollBeyondLastLine: scrollBeyondLastLine,
|
||||
height: outerHeight,
|
||||
lineHeight: lineHeight,
|
||||
pixelRatio: pixelRatio
|
||||
});
|
||||
// ratio is intentionally not part of the layout to avoid the layout changing all the time
|
||||
// when doing sampling
|
||||
const ratio = modelLineCount / minimapLineCount;
|
||||
|
||||
if (ratio > 1) {
|
||||
minimapHeightIsEditorHeight = true;
|
||||
minimapIsSampling = true;
|
||||
minimapScale = 1;
|
||||
minimapLineHeight = 1;
|
||||
minimapCharWidth = minimapScale / pixelRatio;
|
||||
} else {
|
||||
const effectiveMinimapHeight = Math.ceil((modelLineCount + extraLinesBeyondLastLine) * minimapLineHeight);
|
||||
if (minimapMode === 'cover' || effectiveMinimapHeight > minimapCanvasInnerHeight) {
|
||||
minimapHeightIsEditorHeight = true;
|
||||
const configuredFontScale = minimapScale;
|
||||
minimapLineHeight = Math.min(lineHeight * pixelRatio, Math.max(1, Math.floor(1 / desiredRatio)));
|
||||
minimapScale = Math.min(configuredFontScale + 1, Math.max(1, Math.floor(minimapLineHeight / baseCharHeight)));
|
||||
if (minimapScale > configuredFontScale) {
|
||||
minimapWidthMultiplier = Math.min(2, minimapScale / configuredFontScale);
|
||||
}
|
||||
minimapCharWidth = minimapScale / pixelRatio / minimapWidthMultiplier;
|
||||
minimapCanvasInnerHeight = Math.ceil((Math.max(typicalViewportLineCount, modelLineCount + extraLinesBeyondLastLine)) * minimapLineHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderMinimap = minimapRenderCharacters ? RenderMinimap.Text : RenderMinimap.Blocks;
|
||||
|
||||
// Given:
|
||||
@@ -1855,6 +1928,10 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
} else {
|
||||
minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth;
|
||||
}
|
||||
|
||||
minimapCanvasInnerWidth = Math.floor(pixelRatio * minimapWidth);
|
||||
minimapCanvasOuterWidth = minimapCanvasInnerWidth / pixelRatio;
|
||||
minimapCanvasInnerWidth = Math.floor(minimapCanvasInnerWidth * minimapWidthMultiplier);
|
||||
}
|
||||
|
||||
// (leaving 2px for the cursor to have space after the last character)
|
||||
@@ -1881,6 +1958,14 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
|
||||
renderMinimap: renderMinimap,
|
||||
minimapLeft: minimapLeft,
|
||||
minimapWidth: minimapWidth,
|
||||
minimapHeightIsEditorHeight: minimapHeightIsEditorHeight,
|
||||
minimapIsSampling: minimapIsSampling,
|
||||
minimapScale: minimapScale,
|
||||
minimapLineHeight: minimapLineHeight,
|
||||
minimapCanvasInnerWidth: minimapCanvasInnerWidth,
|
||||
minimapCanvasInnerHeight: minimapCanvasInnerHeight,
|
||||
minimapCanvasOuterWidth: minimapCanvasOuterWidth,
|
||||
minimapCanvasOuterHeight: minimapCanvasOuterHeight,
|
||||
|
||||
viewportColumn: viewportColumn,
|
||||
|
||||
@@ -1981,6 +2066,11 @@ export interface IEditorMinimapOptions {
|
||||
* Defaults to 'right'.
|
||||
*/
|
||||
side?: 'right' | 'left';
|
||||
/**
|
||||
* Control the minimap rendering mode.
|
||||
* Defaults to 'actual'.
|
||||
*/
|
||||
mode?: 'actual' | 'cover' | 'contain';
|
||||
/**
|
||||
* Control the rendering of the minimap slider.
|
||||
* Defaults to 'mouseover'.
|
||||
@@ -1996,7 +2086,6 @@ export interface IEditorMinimapOptions {
|
||||
* Defaults to 120.
|
||||
*/
|
||||
maxColumn?: number;
|
||||
|
||||
/**
|
||||
* Relative size of the font in the minimap. Defaults to 1.
|
||||
*/
|
||||
@@ -2010,6 +2099,7 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
|
||||
constructor() {
|
||||
const defaults: EditorMinimapOptions = {
|
||||
enabled: false, // {{SQL CARBON EDIT}} disable minimap by default
|
||||
mode: 'actual',
|
||||
side: 'right',
|
||||
showSlider: 'mouseover',
|
||||
renderCharacters: true,
|
||||
@@ -2024,6 +2114,17 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
|
||||
default: defaults.enabled,
|
||||
description: nls.localize('minimap.enabled', "Controls whether the minimap is shown.")
|
||||
},
|
||||
'editor.minimap.mode': {
|
||||
type: 'string',
|
||||
enum: ['actual', 'cover', 'contain'],
|
||||
enumDescriptions: [
|
||||
nls.localize('minimap.mode.actual', "The minimap will be displayed in its original size, so it might be higher than the editor."),
|
||||
nls.localize('minimap.mode.cover', "The minimap will always have the height of the editor and will stretch or shrink as necessary."),
|
||||
nls.localize('minimap.mode.contain', "The minimap will shrink as necessary to never be higher than the editor."),
|
||||
],
|
||||
default: defaults.mode,
|
||||
description: nls.localize('minimap.mode', "Controls the rendering mode of the minimap.")
|
||||
},
|
||||
'editor.minimap.side': {
|
||||
type: 'string',
|
||||
enum: ['left', 'right'],
|
||||
@@ -2052,7 +2153,7 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
|
||||
type: 'number',
|
||||
default: defaults.maxColumn,
|
||||
description: nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.")
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2064,6 +2165,7 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
|
||||
const input = _input as IEditorMinimapOptions;
|
||||
return {
|
||||
enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
|
||||
mode: EditorStringEnumOption.stringSet<'actual' | 'cover' | 'contain'>(input.mode, this.defaultValue.mode, ['actual', 'cover', 'contain']),
|
||||
side: EditorStringEnumOption.stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']),
|
||||
showSlider: EditorStringEnumOption.stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
|
||||
renderCharacters: EditorBooleanOption.boolean(input.renderCharacters, this.defaultValue.renderCharacters),
|
||||
|
||||
@@ -1423,19 +1423,15 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
private _changeDecorations<T>(ownerId: number, callback: (changeAccessor: model.IModelDecorationsChangeAccessor) => T): T | null {
|
||||
let changeAccessor: model.IModelDecorationsChangeAccessor = {
|
||||
addDecoration: (range: IRange, options: model.IModelDecorationOptions): string => {
|
||||
this._onDidChangeDecorations.fire();
|
||||
return this._deltaDecorationsImpl(ownerId, [], [{ range: range, options: options }])[0];
|
||||
},
|
||||
changeDecoration: (id: string, newRange: IRange): void => {
|
||||
this._onDidChangeDecorations.fire();
|
||||
this._changeDecorationImpl(id, newRange);
|
||||
},
|
||||
changeDecorationOptions: (id: string, options: model.IModelDecorationOptions) => {
|
||||
this._onDidChangeDecorations.fire();
|
||||
this._changeDecorationOptionsImpl(id, _normalizeOptions(options));
|
||||
},
|
||||
removeDecoration: (id: string): void => {
|
||||
this._onDidChangeDecorations.fire();
|
||||
this._deltaDecorationsImpl(ownerId, [id], []);
|
||||
},
|
||||
deltaDecorations: (oldDecorations: string[], newDecorations: model.IModelDeltaDecoration[]): string[] => {
|
||||
@@ -1443,7 +1439,6 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
// nothing to do
|
||||
return [];
|
||||
}
|
||||
this._onDidChangeDecorations.fire();
|
||||
return this._deltaDecorationsImpl(ownerId, oldDecorations, newDecorations);
|
||||
}
|
||||
};
|
||||
@@ -1474,7 +1469,6 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
try {
|
||||
this._onDidChangeDecorations.beginDeferredEmit();
|
||||
this._onDidChangeDecorations.fire();
|
||||
return this._deltaDecorationsImpl(ownerId, oldDecorations, newDecorations);
|
||||
} finally {
|
||||
this._onDidChangeDecorations.endDeferredEmit();
|
||||
@@ -1622,6 +1616,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
this._decorationsTree.delete(node);
|
||||
node.reset(this.getVersionId(), startOffset, endOffset, range);
|
||||
this._decorationsTree.insert(node);
|
||||
this._onDidChangeDecorations.checkAffectedAndFire(node.options);
|
||||
}
|
||||
|
||||
private _changeDecorationOptionsImpl(decorationId: string, options: ModelDecorationOptions): void {
|
||||
@@ -1633,6 +1628,9 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
const nodeWasInOverviewRuler = (node.options.overviewRuler && node.options.overviewRuler.color ? true : false);
|
||||
const nodeIsInOverviewRuler = (options.overviewRuler && options.overviewRuler.color ? true : false);
|
||||
|
||||
this._onDidChangeDecorations.checkAffectedAndFire(node.options);
|
||||
this._onDidChangeDecorations.checkAffectedAndFire(options);
|
||||
|
||||
if (nodeWasInOverviewRuler !== nodeIsInOverviewRuler) {
|
||||
// Delete + Insert due to an overview ruler status change
|
||||
this._decorationsTree.delete(node);
|
||||
@@ -1666,6 +1664,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
// (2) remove the node from the tree (if it exists)
|
||||
if (node) {
|
||||
this._decorationsTree.delete(node);
|
||||
this._onDidChangeDecorations.checkAffectedAndFire(node.options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1688,6 +1687,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
node.ownerId = ownerId;
|
||||
node.reset(versionId, startOffset, endOffset, range);
|
||||
node.setOptions(options);
|
||||
this._onDidChangeDecorations.checkAffectedAndFire(options);
|
||||
|
||||
this._decorationsTree.insert(node);
|
||||
|
||||
@@ -1713,7 +1713,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
throw new Error('Illegal value for lineNumber');
|
||||
}
|
||||
|
||||
this._tokens.setTokens(this._languageIdentifier.id, lineNumber - 1, this._buffer.getLineLength(lineNumber), tokens);
|
||||
this._tokens.setTokens(this._languageIdentifier.id, lineNumber - 1, this._buffer.getLineLength(lineNumber), tokens, false);
|
||||
}
|
||||
|
||||
public setTokens(tokens: MultilineTokens[]): void {
|
||||
@@ -1725,16 +1725,34 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
for (let i = 0, len = tokens.length; i < len; i++) {
|
||||
const element = tokens[i];
|
||||
ranges.push({ fromLineNumber: element.startLineNumber, toLineNumber: element.startLineNumber + element.tokens.length - 1 });
|
||||
let minChangedLineNumber = 0;
|
||||
let maxChangedLineNumber = 0;
|
||||
let hasChange = false;
|
||||
for (let j = 0, lenJ = element.tokens.length; j < lenJ; j++) {
|
||||
this.setLineTokens(element.startLineNumber + j, element.tokens[j]);
|
||||
const lineNumber = element.startLineNumber + j;
|
||||
if (hasChange) {
|
||||
this._tokens.setTokens(this._languageIdentifier.id, lineNumber - 1, this._buffer.getLineLength(lineNumber), element.tokens[j], false);
|
||||
maxChangedLineNumber = lineNumber;
|
||||
} else {
|
||||
const lineHasChange = this._tokens.setTokens(this._languageIdentifier.id, lineNumber - 1, this._buffer.getLineLength(lineNumber), element.tokens[j], true);
|
||||
if (lineHasChange) {
|
||||
hasChange = true;
|
||||
minChangedLineNumber = lineNumber;
|
||||
maxChangedLineNumber = lineNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasChange) {
|
||||
ranges.push({ fromLineNumber: minChangedLineNumber, toLineNumber: maxChangedLineNumber });
|
||||
}
|
||||
}
|
||||
|
||||
this._emitModelTokensChangedEvent({
|
||||
tokenizationSupportChanged: false,
|
||||
ranges: ranges
|
||||
});
|
||||
if (ranges.length > 0) {
|
||||
this._emitModelTokensChangedEvent({
|
||||
tokenizationSupportChanged: false,
|
||||
ranges: ranges
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public setSemanticTokens(tokens: MultilineTokens2[] | null): void {
|
||||
@@ -3083,11 +3101,15 @@ export class DidChangeDecorationsEmitter extends Disposable {
|
||||
|
||||
private _deferredCnt: number;
|
||||
private _shouldFire: boolean;
|
||||
private _affectsMinimap: boolean;
|
||||
private _affectsOverviewRuler: boolean;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._deferredCnt = 0;
|
||||
this._shouldFire = false;
|
||||
this._affectsMinimap = false;
|
||||
this._affectsOverviewRuler = false;
|
||||
}
|
||||
|
||||
public beginDeferredEmit(): void {
|
||||
@@ -3098,13 +3120,31 @@ export class DidChangeDecorationsEmitter extends Disposable {
|
||||
this._deferredCnt--;
|
||||
if (this._deferredCnt === 0) {
|
||||
if (this._shouldFire) {
|
||||
const event: IModelDecorationsChangedEvent = {
|
||||
affectsMinimap: this._affectsMinimap,
|
||||
affectsOverviewRuler: this._affectsOverviewRuler,
|
||||
};
|
||||
this._shouldFire = false;
|
||||
this._actual.fire({});
|
||||
this._affectsMinimap = false;
|
||||
this._affectsOverviewRuler = false;
|
||||
this._actual.fire(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public checkAffectedAndFire(options: ModelDecorationOptions): void {
|
||||
if (!this._affectsMinimap) {
|
||||
this._affectsMinimap = options.minimap && options.minimap.position ? true : false;
|
||||
}
|
||||
if (!this._affectsOverviewRuler) {
|
||||
this._affectsOverviewRuler = options.overviewRuler && options.overviewRuler.color ? true : false;
|
||||
}
|
||||
this._shouldFire = true;
|
||||
}
|
||||
|
||||
public fire(): void {
|
||||
this._affectsMinimap = true;
|
||||
this._affectsOverviewRuler = true;
|
||||
this._shouldFire = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ export interface IModelContentChangedEvent {
|
||||
* An event describing that model decorations have changed.
|
||||
*/
|
||||
export interface IModelDecorationsChangedEvent {
|
||||
readonly affectsMinimap: boolean;
|
||||
readonly affectsOverviewRuler: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -964,10 +964,35 @@ export class TokensStore {
|
||||
this._len += insertCount;
|
||||
}
|
||||
|
||||
public setTokens(topLevelLanguageId: LanguageId, lineIndex: number, lineTextLength: number, _tokens: Uint32Array | ArrayBuffer | null): void {
|
||||
public setTokens(topLevelLanguageId: LanguageId, lineIndex: number, lineTextLength: number, _tokens: Uint32Array | ArrayBuffer | null, checkEquality: boolean): boolean {
|
||||
const tokens = TokensStore._massageTokens(topLevelLanguageId, lineTextLength, _tokens);
|
||||
this._ensureLine(lineIndex);
|
||||
const oldTokens = this._lineTokens[lineIndex];
|
||||
this._lineTokens[lineIndex] = tokens;
|
||||
|
||||
if (checkEquality) {
|
||||
return !TokensStore._equals(oldTokens, tokens);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static _equals(_a: Uint32Array | ArrayBuffer | null, _b: Uint32Array | ArrayBuffer | null) {
|
||||
if (!_a || !_b) {
|
||||
return !_a && !_b;
|
||||
}
|
||||
|
||||
const a = toUint32Array(_a);
|
||||
const b = toUint32Array(_b);
|
||||
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = a.length; i < len; i++) {
|
||||
if (a[i] !== b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//#region Editing
|
||||
|
||||
@@ -274,6 +274,16 @@ export class LanguageConfigurationRegistryImpl {
|
||||
return ensureValidWordDefinition(value.wordDefinition || null);
|
||||
}
|
||||
|
||||
public getWordDefinitions(): [LanguageId, RegExp][] {
|
||||
let result: [LanguageId, RegExp][] = [];
|
||||
this._entries.forEach((value, language) => {
|
||||
if (value) {
|
||||
result.push([language, value.wordDefinition]);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public getFoldingRules(languageId: LanguageId): FoldingRules {
|
||||
let value = this._getRichEditSupport(languageId);
|
||||
if (!value) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ScrollType, IContentSizeChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { IModelDecorationsChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
|
||||
export const enum ViewEventType {
|
||||
ViewConfigurationChanged = 1,
|
||||
@@ -82,8 +83,17 @@ export class ViewDecorationsChangedEvent {
|
||||
|
||||
public readonly type = ViewEventType.ViewDecorationsChanged;
|
||||
|
||||
constructor() {
|
||||
// Nothing to do
|
||||
readonly affectsMinimap: boolean;
|
||||
readonly affectsOverviewRuler: boolean;
|
||||
|
||||
constructor(source: IModelDecorationsChangedEvent | null) {
|
||||
if (source) {
|
||||
this.affectsMinimap = source.affectsMinimap;
|
||||
this.affectsOverviewRuler = source.affectsOverviewRuler;
|
||||
} else {
|
||||
this.affectsMinimap = true;
|
||||
this.affectsOverviewRuler = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
if (this.lines.setWrappingSettings(fontInfo, wrappingStrategy, wrappingInfo.wrappingColumn, wrappingIndent)) {
|
||||
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null));
|
||||
this.decorations.onLineMappingChanged();
|
||||
this.viewLayout.onFlushed(this.getLineCount());
|
||||
|
||||
@@ -185,7 +185,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
if (e.hasChanged(EditorOption.readOnly)) {
|
||||
// Must read again all decorations due to readOnly filtering
|
||||
this.decorations.reset();
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null));
|
||||
}
|
||||
|
||||
eventsCollector.emit(new viewEvents.ViewConfigurationChangedEvent(e));
|
||||
@@ -291,7 +291,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
|
||||
if (!hadOtherModelChange && hadModelLineChangeThatChangedLineMapping) {
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null));
|
||||
this.decorations.onLineMappingChanged();
|
||||
}
|
||||
} finally {
|
||||
@@ -354,7 +354,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
const eventsCollector = this._beginEmit();
|
||||
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null));
|
||||
} finally {
|
||||
this._endEmit();
|
||||
}
|
||||
@@ -365,7 +365,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
this.decorations.onModelDecorationsChanged();
|
||||
try {
|
||||
const eventsCollector = this._beginEmit();
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(e));
|
||||
} finally {
|
||||
this._endEmit();
|
||||
}
|
||||
@@ -379,7 +379,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
if (lineMappingChanged) {
|
||||
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null));
|
||||
this.decorations.onLineMappingChanged();
|
||||
this.viewLayout.onFlushed(this.getLineCount());
|
||||
this.viewLayout.onHeightMaybeChanged();
|
||||
|
||||
Reference in New Issue
Block a user