未验证 提交 4ba9ad5d 编写于 作者: A Alex Dima

Emit view zones changed through view model

上级 5a1565ce
......@@ -450,10 +450,9 @@ export class View extends ViewEventHandler {
return new OverviewRuler(this._context, cssClassName);
}
public change(callback: (changeAccessor: IViewZoneChangeAccessor) => any): boolean {
const hadAChange = this.viewZones.changeViewZones(callback);
public change(callback: (changeAccessor: IViewZoneChangeAccessor) => any): void {
this.viewZones.changeViewZones(callback);
this._scheduleRender();
return hadAChange;
}
public render(now: boolean, everything: boolean): void {
......
......@@ -1385,10 +1385,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
if (!this._modelData || !this._modelData.hasRealView) {
return;
}
const hasChanges = this._modelData.view.change(callback);
if (hasChanges) {
this._onDidChangeViewZones.fire();
}
this._modelData.view.change(callback);
}
public getTargetAtClientPoint(clientX: number, clientY: number): editorBrowser.IMouseTarget | null {
......@@ -1521,6 +1518,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
case OutgoingViewModelEventKind.ScrollChanged:
this._onDidScrollChange.fire(e);
break;
case OutgoingViewModelEventKind.ViewZonesChanged:
this._onDidChangeViewZones.fire();
break;
}
}));
......
......@@ -148,6 +148,7 @@ export const enum OutgoingViewModelEventKind {
ContentSizeChanged,
FocusChanged,
ScrollChanged,
ViewZonesChanged,
}
export class ContentSizeChangedEvent implements IContentSizeChangedEvent {
......@@ -251,7 +252,6 @@ export class ScrollChangedEvent {
return (!this.scrollWidthChanged && !this.scrollLeftChanged && !this.scrollHeightChanged && !this.scrollTopChanged);
}
public merge(other: OutgoingViewModelEvent): ScrollChangedEvent {
if (other.kind !== OutgoingViewModelEventKind.ScrollChanged) {
return this;
......@@ -263,8 +263,25 @@ export class ScrollChangedEvent {
}
}
export class ViewZonesChangedEvent {
public readonly kind = OutgoingViewModelEventKind.ViewZonesChanged;
constructor() {
}
public isNoOp(): boolean {
return false;
}
public merge(other: OutgoingViewModelEvent): ViewZonesChangedEvent {
return this;
}
}
export type OutgoingViewModelEvent = (
ContentSizeChangedEvent
| FocusChangedEvent
| ScrollChangedEvent
| ViewZonesChangedEvent
);
......@@ -30,7 +30,7 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
import { PartialCursorState, CursorState, IColumnSelectData, EditOperationType, CursorConfiguration } from 'vs/editor/common/controller/cursorCommon';
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
import { IWhitespaceChangeAccessor } from 'vs/editor/common/viewLayout/linesLayout';
import { ViewModelEventDispatcher, OutgoingViewModelEvent, FocusChangedEvent, ScrollChangedEvent } from 'vs/editor/common/viewModel/viewModelEventDispatcher';
import { ViewModelEventDispatcher, OutgoingViewModelEvent, FocusChangedEvent, ScrollChangedEvent, ViewZonesChangedEvent } from 'vs/editor/common/viewModel/viewModelEventDispatcher';
import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler';
const USE_IDENTITY_LINES_COLLECTION = true;
......@@ -980,6 +980,7 @@ export class ViewModel extends Disposable implements IViewModel {
const hadAChange = this.viewLayout.changeWhitespace(callback);
if (hadAChange) {
this._eventDispatcher.emitSingleViewEvent(new viewEvents.ViewZonesChangedEvent());
this._eventDispatcher.emitOutgoingEvent(new ViewZonesChangedEvent());
}
}
public setMaxLineWidth(maxLineWidth: number): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册