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

Emit view zones changed through view model

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