wip
parent
1d64cc51d8
commit
ed5fbf5a16
|
@ -396,7 +396,11 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
}
|
||||
|
||||
public getId(): string {
|
||||
return this.getEditorType() + ':' + this._id;
|
||||
return this.getEditorType() + ':' + this.getIdNumber();
|
||||
}
|
||||
|
||||
public getIdNumber(): number {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public getEditorType(): string {
|
||||
|
|
|
@ -23,7 +23,9 @@ export abstract class DelegatingEditor extends Disposable implements IEditor {
|
|||
|
||||
protected abstract get _targetEditor(): CodeEditorWidget;
|
||||
|
||||
getId(): string { return this.getEditorType() + ':v2:' + this._id; }
|
||||
getId(): string { return this.getEditorType() + ':v2:' + this.getIdNumber(); }
|
||||
|
||||
getIdNumber(): number { return this._id; }
|
||||
|
||||
abstract getEditorType(): string;
|
||||
abstract updateOptions(newOptions: IEditorOptions): void;
|
||||
|
|
|
@ -238,6 +238,11 @@ export interface IEditor {
|
|||
*/
|
||||
getId(): string;
|
||||
|
||||
/**
|
||||
* Get the id number for this editor instance.
|
||||
*/
|
||||
getIdNumber(): number;
|
||||
|
||||
/**
|
||||
* Get the editor type. Please see `EditorType`.
|
||||
* This is to avoid an instanceof check
|
||||
|
|
|
@ -1576,7 +1576,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
|
||||
//#region Decorations
|
||||
|
||||
private handleBeforeFireDecorationsChangedEvent(affectedInjectedTextLines: Set<number> | null, specialLineHeights: Set<number> | null): void {
|
||||
private handleBeforeFireDecorationsChangedEvent(affectedInjectedTextLines: Set<number> | null, specialLineHeights: Set<{ ownerId: number; lineNumber: number }> | null): void {
|
||||
// This is called before the decoration changed event is fired.
|
||||
|
||||
if (affectedInjectedTextLines && affectedInjectedTextLines.size > 0) {
|
||||
|
@ -1586,7 +1586,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
}
|
||||
if (specialLineHeights && specialLineHeights.size > 0) {
|
||||
const affectedLinesByLineHeightChange = Array.from(specialLineHeights);
|
||||
const lineHeightChangeEvent = affectedLinesByLineHeightChange.map(lineNumber => new ModelLineHeightChanged(lineNumber, this._getLineHeightForLine(lineNumber)));
|
||||
const lineHeightChangeEvent = affectedLinesByLineHeightChange.map(specialLineHeightChange => new ModelLineHeightChanged(specialLineHeightChange.ownerId, specialLineHeightChange.lineNumber, this._getLineHeightForLine(specialLineHeightChange.lineNumber)));
|
||||
this._onDidChangeSpecialLineHeight.fire(new ModelLineHeightChangedEvent(lineHeightChangeEvent));
|
||||
}
|
||||
}
|
||||
|
@ -1608,10 +1608,10 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
return this._deltaDecorationsImpl(ownerId, [], [{ range: range, options: options }])[0];
|
||||
},
|
||||
changeDecoration: (id: string, newRange: IRange): void => {
|
||||
this._changeDecorationImpl(id, newRange);
|
||||
this._changeDecorationImpl(ownerId, id, newRange);
|
||||
},
|
||||
changeDecorationOptions: (id: string, options: model.IModelDecorationOptions) => {
|
||||
this._changeDecorationOptionsImpl(id, _normalizeOptions(options));
|
||||
this._changeDecorationOptionsImpl(ownerId, id, _normalizeOptions(options));
|
||||
},
|
||||
removeDecoration: (id: string): void => {
|
||||
this._deltaDecorationsImpl(ownerId, [id], []);
|
||||
|
@ -1797,7 +1797,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
return this._buffer.getRangeAt(start, end - start);
|
||||
}
|
||||
|
||||
private _changeDecorationImpl(decorationId: string, _range: IRange): void {
|
||||
private _changeDecorationImpl(ownerId: number, decorationId: string, _range: IRange): void {
|
||||
const node = this._decorations[decorationId];
|
||||
if (!node) {
|
||||
return;
|
||||
|
@ -1814,7 +1814,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
if (node.options.lineHeight) {
|
||||
const oldRange = this.getDecorationRange(decorationId);
|
||||
for (let lineNumber = oldRange!.startLineNumber; lineNumber <= oldRange!.endLineNumber; lineNumber++) {
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(lineNumber);
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(ownerId, lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1835,12 +1835,12 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
}
|
||||
if (node.options.lineHeight) {
|
||||
for (let lineNumber = range.startLineNumber; lineNumber <= range.endLineNumber; lineNumber++) {
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(lineNumber);
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(ownerId, lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _changeDecorationOptionsImpl(decorationId: string, options: ModelDecorationOptions): void {
|
||||
private _changeDecorationOptionsImpl(ownerId: number, decorationId: string, options: ModelDecorationOptions): void {
|
||||
const node = this._decorations[decorationId];
|
||||
if (!node) {
|
||||
return;
|
||||
|
@ -1863,7 +1863,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
if (node.options.lineHeight) {
|
||||
const nodeRange = this._decorationsTree.getNodeRange(this, node);
|
||||
for (let lineNumber = nodeRange.startLineNumber; lineNumber <= nodeRange.endLineNumber; lineNumber++) {
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(lineNumber);
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(ownerId, lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1913,7 +1913,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
if (node.options.lineHeight) {
|
||||
const nodeRange = this._decorationsTree.getNodeRange(this, node);
|
||||
for (let lineNumber = nodeRange.startLineNumber; lineNumber <= nodeRange.endLineNumber; lineNumber++) {
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(lineNumber);
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(ownerId, lineNumber);
|
||||
}
|
||||
}
|
||||
this._decorationsTree.delete(node);
|
||||
|
@ -1952,7 +1952,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
|
|||
}
|
||||
if (node.options.lineHeight) {
|
||||
for (let lineNumber = range.startLineNumber; lineNumber <= range.endLineNumber; lineNumber++) {
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(lineNumber);
|
||||
this._onDidChangeDecorations.recordLineAffectedByLineHeightChange(ownerId, lineNumber);
|
||||
}
|
||||
}
|
||||
if (!suppressEvents) {
|
||||
|
@ -2446,11 +2446,11 @@ class DidChangeDecorationsEmitter extends Disposable {
|
|||
private _affectsMinimap: boolean;
|
||||
private _affectsOverviewRuler: boolean;
|
||||
private _affectedInjectedTextLines: Set<number> | null = null;
|
||||
private _specialLineHeights: Set<{ ownerId: number; lineNumber: number }> | null = null;
|
||||
private _affectsGlyphMargin: boolean;
|
||||
private _affectsLineNumber: boolean;
|
||||
private _specialLineHeights: Set<number> | null = null;
|
||||
|
||||
constructor(private readonly handleBeforeFire: (affectedInjectedTextLines: Set<number> | null, specialLineHeights: Set<number> | null) => void) {
|
||||
constructor(private readonly handleBeforeFire: (affectedInjectedTextLines: Set<number> | null, specialLineHeights: Set<{ ownerId: number; lineNumber: number }> | null) => void) {
|
||||
super();
|
||||
this._deferredCnt = 0;
|
||||
this._shouldFireDeferred = false;
|
||||
|
@ -2477,6 +2477,8 @@ class DidChangeDecorationsEmitter extends Disposable {
|
|||
|
||||
this._affectedInjectedTextLines?.clear();
|
||||
this._affectedInjectedTextLines = null;
|
||||
this._specialLineHeights?.clear();
|
||||
this._specialLineHeights = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2487,11 +2489,11 @@ class DidChangeDecorationsEmitter extends Disposable {
|
|||
this._affectedInjectedTextLines.add(lineNumber);
|
||||
}
|
||||
|
||||
public recordLineAffectedByLineHeightChange(lineNumber: number): void {
|
||||
public recordLineAffectedByLineHeightChange(ownerId: number, lineNumber: number): void {
|
||||
if (!this._specialLineHeights) {
|
||||
this._specialLineHeights = new Set();
|
||||
}
|
||||
this._specialLineHeights.add(lineNumber);
|
||||
this._specialLineHeights.add({ ownerId, lineNumber });
|
||||
}
|
||||
|
||||
public checkAffectedAndFire(options: ModelDecorationOptions): void {
|
||||
|
|
|
@ -240,6 +240,10 @@ export class ModelRawLineChanged {
|
|||
* @internal
|
||||
*/
|
||||
export class ModelLineHeightChanged {
|
||||
/**
|
||||
* Editor owner ID
|
||||
*/
|
||||
public readonly ownerId: number;
|
||||
/**
|
||||
* The line that has changed.
|
||||
*/
|
||||
|
@ -249,7 +253,8 @@ export class ModelLineHeightChanged {
|
|||
*/
|
||||
public readonly lineHeight: number | null;
|
||||
|
||||
constructor(lineNumber: number, lineHeight: number | null) {
|
||||
constructor(ownerId: number, lineNumber: number, lineHeight: number | null) {
|
||||
this.ownerId = ownerId;
|
||||
this.lineNumber = lineNumber;
|
||||
this.lineHeight = lineHeight;
|
||||
}
|
||||
|
|
|
@ -203,10 +203,12 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
|||
}
|
||||
|
||||
public addSpecialLineHeight(lineNumber: number, height: number): void {
|
||||
console.log('addSpecialLineHeight ' + lineNumber + ' ' + height);
|
||||
this._linesLayout.addSpecialLineHeight(lineNumber, height);
|
||||
}
|
||||
|
||||
public removeSpecialLineHeight(lineNumber: number): void {
|
||||
console.log('removeSpecialLineHeight ' + lineNumber);
|
||||
this._linesLayout.removeSpecialLineHeight(lineNumber);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,9 @@ export class ViewModel extends Disposable implements IViewModel {
|
|||
this._decorations = new ViewModelDecorations(this._editorId, this.model, this._configuration, this._lines, this.coordinatesConverter);
|
||||
this._register(this.model.onDidChangeSpecialLineHeight((e) => {
|
||||
e.changes.forEach((change) => {
|
||||
if (change.ownerId !== this._editorId) {
|
||||
return;
|
||||
}
|
||||
const lineNumber = change.lineNumber;
|
||||
const lineHeight = change.lineHeight;
|
||||
if (lineHeight !== null) {
|
||||
|
|
|
@ -135,6 +135,9 @@ export class StickyScrollController extends Disposable implements IEditorContrib
|
|||
if (model) {
|
||||
this._register(model.onDidChangeSpecialLineHeight((e) => {
|
||||
e.changes.forEach((change) => {
|
||||
if (change.ownerId !== this._editor.getIdNumber()) {
|
||||
return;
|
||||
}
|
||||
const lineNumber = change.lineNumber;
|
||||
const lineHeight = change.lineHeight;
|
||||
if (lineHeight !== null) {
|
||||
|
|
|
@ -72,6 +72,9 @@ export class StickyLineCandidateProvider extends Disposable implements IStickyLi
|
|||
if (model) {
|
||||
this._register(model.onDidChangeSpecialLineHeight((e) => {
|
||||
e.changes.forEach((change) => {
|
||||
if (change.ownerId !== this._editor.getIdNumber()) {
|
||||
return;
|
||||
}
|
||||
const lineNumber = change.lineNumber;
|
||||
const lineHeight = change.lineHeight;
|
||||
if (lineHeight !== null) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import { IPosition, Position } from '../../../common/core/position.js';
|
|||
import { IRange, Range } from '../../../common/core/range.js';
|
||||
import { IEditorDecorationsCollection, ScrollType } from '../../../common/editorCommon.js';
|
||||
import { TrackedRangeStickiness } from '../../../common/model.js';
|
||||
import { ModelDecorationOptions } from '../../../common/model/textModel.js';
|
||||
|
||||
export interface IOptions {
|
||||
showFrame?: boolean;
|
||||
|
@ -319,7 +318,12 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
|
|||
this._isShowing = true;
|
||||
this._showImpl(range, heightInLines);
|
||||
this._isShowing = false;
|
||||
this._positionMarkerId.set([{ range, options: ModelDecorationOptions.EMPTY }]);
|
||||
this._positionMarkerId.set([{
|
||||
range, options: {
|
||||
lineHeight: 100,
|
||||
description: 'zone-widget-position',
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
updatePositionAndHeight(rangeOrPos: IRange | IPosition, heightInLines?: number): void {
|
||||
|
@ -334,7 +338,10 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
|
|||
});
|
||||
this._positionMarkerId.set([{
|
||||
range: Range.isIRange(rangeOrPos) ? rangeOrPos : Range.fromPositions(rangeOrPos),
|
||||
options: ModelDecorationOptions.EMPTY
|
||||
options: {
|
||||
lineHeight: 100,
|
||||
description: 'zone-widget-position',
|
||||
}
|
||||
}]);
|
||||
this._updateSashEnablement();
|
||||
}
|
||||
|
|
|
@ -2615,6 +2615,10 @@ declare namespace monaco.editor {
|
|||
* Get a unique id for this editor instance.
|
||||
*/
|
||||
getId(): string;
|
||||
/**
|
||||
* Get the id number for this editor instance.
|
||||
*/
|
||||
getIdNumber(): number;
|
||||
/**
|
||||
* Get the editor type. Please see `EditorType`.
|
||||
* This is to avoid an instanceof check
|
||||
|
|
Loading…
Reference in New Issue