Merge pull request #233837 from microsoft/tyriar/233835
Fix contentLeft not being respected after line numbers change
This commit is contained in:
Коммит
f986db372a
|
@ -5,25 +5,24 @@
|
|||
|
||||
import { getActiveWindow } from '../../../../base/browser/dom.js';
|
||||
import { BugIndicatingError } from '../../../../base/common/errors.js';
|
||||
import { autorun } from '../../../../base/common/observable.js';
|
||||
import { autorun, observableValue, runOnChange } from '../../../../base/common/observable.js';
|
||||
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { ILogService } from '../../../../platform/log/common/log.js';
|
||||
import { EditorOption } from '../../../common/config/editorOptions.js';
|
||||
import { Position } from '../../../common/core/position.js';
|
||||
import { Range } from '../../../common/core/range.js';
|
||||
import type { ViewConfigurationChangedEvent, ViewCursorStateChangedEvent, ViewDecorationsChangedEvent, ViewLinesChangedEvent, ViewLinesDeletedEvent, ViewScrollChangedEvent } from '../../../common/viewEvents.js';
|
||||
import type { ViewportData } from '../../../common/viewLayout/viewLinesViewportData.js';
|
||||
import type { ViewContext } from '../../../common/viewModel/viewContext.js';
|
||||
import { TextureAtlasPage } from '../../gpu/atlas/textureAtlasPage.js';
|
||||
import { FullFileRenderStrategy } from '../../gpu/fullFileRenderStrategy.js';
|
||||
import { BindingId, type IGpuRenderStrategy } from '../../gpu/gpu.js';
|
||||
import { GPULifecycle } from '../../gpu/gpuDisposable.js';
|
||||
import { observeDevicePixelDimensions, quadVertices } from '../../gpu/gpuUtils.js';
|
||||
import { quadVertices } from '../../gpu/gpuUtils.js';
|
||||
import { ViewGpuContext } from '../../gpu/viewGpuContext.js';
|
||||
import { FloatHorizontalRange, HorizontalPosition, HorizontalRange, IViewLines, LineVisibleRanges, RenderingContext, RestrictedRenderingContext, VisibleRanges } from '../../view/renderingContext.js';
|
||||
import { ViewPart } from '../../view/viewPart.js';
|
||||
import { ViewLineOptions } from '../viewLines/viewLineOptions.js';
|
||||
|
||||
import type * as viewEvents from '../../../common/viewEvents.js';
|
||||
|
||||
const enum GlyphStorageBufferInfo {
|
||||
FloatsPerEntry = 2 + 2 + 2,
|
||||
|
@ -60,6 +59,8 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
|
|||
|
||||
private _renderStrategy!: IGpuRenderStrategy;
|
||||
|
||||
private _contentLeftObs = observableValue('contentLeft', 0);
|
||||
|
||||
constructor(
|
||||
context: ViewContext,
|
||||
private readonly _viewGpuContext: ViewGpuContext,
|
||||
|
@ -154,8 +155,11 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
|
|||
size: Info.BytesPerEntry,
|
||||
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
||||
}, () => updateBufferValues())).object;
|
||||
this._register(observeDevicePixelDimensions(this.canvas, getActiveWindow(), (w, h) => {
|
||||
this._device.queue.writeBuffer(layoutInfoUniformBuffer, 0, updateBufferValues(w, h));
|
||||
this._register(runOnChange(this._viewGpuContext.canvasDevicePixelDimensions, ({ width, height }) => {
|
||||
this._device.queue.writeBuffer(layoutInfoUniformBuffer, 0, updateBufferValues(width, height));
|
||||
}));
|
||||
this._register(runOnChange(this._contentLeftObs, () => {
|
||||
this._device.queue.writeBuffer(layoutInfoUniformBuffer, 0, updateBufferValues());
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -373,32 +377,30 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
|
|||
// Since ViewLinesGpu currently coordinates rendering to the canvas, it must listen to all
|
||||
// changed events that any GPU part listens to. This is because any drawing to the canvas will
|
||||
// clear it for that frame, so all parts must be rendered every time.
|
||||
//
|
||||
// Additionally, since this is intrinsically linked to ViewLines, it must also listen to events
|
||||
// from that side. Luckily rendering is cheap, it's only when uploaded data changes does it
|
||||
// start to cost.
|
||||
|
||||
override onConfigurationChanged(e: ViewConfigurationChangedEvent): boolean {
|
||||
override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { return true; }
|
||||
override onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { return true; }
|
||||
override onFlushed(e: viewEvents.ViewFlushedEvent): boolean { return true; }
|
||||
override onLinesChanged(e: viewEvents.ViewLinesChangedEvent): boolean { return true; }
|
||||
override onLinesInserted(e: viewEvents.ViewLinesInsertedEvent): boolean { return true; }
|
||||
override onRevealRangeRequest(e: viewEvents.ViewRevealRangeRequestEvent): boolean { return true; }
|
||||
override onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { return true; }
|
||||
override onThemeChanged(e: viewEvents.ViewThemeChangedEvent): boolean { return true; }
|
||||
override onZonesChanged(e: viewEvents.ViewZonesChangedEvent): boolean { return true; }
|
||||
|
||||
override onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
this._contentLeftObs.set(this._context.configuration.options.get(EditorOption.layoutInfo).contentLeft, undefined);
|
||||
return true;
|
||||
}
|
||||
|
||||
override onDecorationsChanged(e: ViewDecorationsChangedEvent): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
override onLinesChanged(e: ViewLinesChangedEvent): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
override onLinesDeleted(e: ViewLinesDeletedEvent): boolean {
|
||||
override onLinesDeleted(e: viewEvents.ViewLinesDeletedEvent): boolean {
|
||||
this._renderStrategy.onLinesDeleted(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
override onScrollChanged(e: ViewScrollChangedEvent): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
override onCursorStateChanged(e: ViewCursorStateChangedEvent): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
public renderText(viewportData: ViewportData): void {
|
||||
|
|
Загрузка…
Ссылка в новой задаче