Skip to content

Commit 23e4f81

Browse files
committed
Don't draw canvas under the scroll bar
Fixes microsoft#234117
1 parent 16155ab commit 23e4f81

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vs/editor/browser/gpu/viewGpuContext.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { GPULifecycle } from './gpuDisposable.js';
1919
import { ensureNonNullable, observeDevicePixelDimensions } from './gpuUtils.js';
2020
import { RectangleRenderer } from './rectangleRenderer.js';
2121
import type { ViewContext } from '../../common/viewModel/viewContext.js';
22+
import { Event } from '../../../base/common/event.js';
23+
import type { IEditorOptions } from '../../common/config/editorOptions.js';
2224

2325
const enum GpuRenderLimits {
2426
maxGpuLines = 3000,
@@ -83,6 +85,15 @@ export class ViewGpuContext extends Disposable {
8385
this.canvas = createFastDomNode(document.createElement('canvas'));
8486
this.canvas.setClassName('editorCanvas');
8587

88+
// Adjust the canvas size to avoid drawing under the scroll bar
89+
this._register(Event.runAndSubscribe(configurationService.onDidChangeConfiguration, e => {
90+
if (!e || e.affectsConfiguration('editor.scrollbar.verticalScrollbarSize')) {
91+
const verticalScrollbarSize = configurationService.getValue<IEditorOptions>('editor').scrollbar?.verticalScrollbarSize ?? 14;
92+
this.canvas.domNode.style.boxSizing = 'border-box';
93+
this.canvas.domNode.style.paddingRight = `${verticalScrollbarSize}px`;
94+
}
95+
}));
96+
8697
this.ctx = ensureNonNullable(this.canvas.domNode.getContext('webgpu'));
8798

8899
this.device = GPULifecycle.requestDevice((message) => {

0 commit comments

Comments
 (0)