Skip to content

Commit

Permalink
Update contentLeft in buffer when changed
Browse files Browse the repository at this point in the history
Fixes #233835
  • Loading branch information
Tyriar committed Nov 14, 2024
1 parent 43b8cbd commit 3ab8e3f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/vs/editor/browser/viewParts/viewLinesGpu/viewLinesGpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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';
Expand All @@ -17,7 +17,7 @@ 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';
Expand Down Expand Up @@ -59,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,
Expand Down Expand Up @@ -153,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());
}));
}

Expand Down Expand Up @@ -377,7 +382,10 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
// from that side. Luckily rendering is cheap, it's only when uploaded data changes does it
// start to cost.

override onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { return true; }
override onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
this._contentLeftObs.set(this._context.configuration.options.get(EditorOption.layoutInfo).contentLeft, undefined);
return true;
}
override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { return true; }
override onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { return true; }
override onFlushed(e: viewEvents.ViewFlushedEvent): boolean { return true; }
Expand Down

0 comments on commit 3ab8e3f

Please sign in to comment.