From 9c653adad32d5eb8761562d66dac91cbf3d7de96 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 7 Dec 2018 11:26:23 -0800 Subject: [PATCH] Avoid accessing style in treeview if we don't need to (#64577) Fixes #64576 We compute the style of an element to access its left padding. However this value is only used when `horizontalScrolling` is enabled. With this change, we only compute the style when `horizontalScrolling` is true --- src/vs/base/parts/tree/browser/treeView.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vs/base/parts/tree/browser/treeView.ts b/src/vs/base/parts/tree/browser/treeView.ts index c85df8c07ac..1ccb257ae35 100644 --- a/src/vs/base/parts/tree/browser/treeView.ts +++ b/src/vs/base/parts/tree/browser/treeView.ts @@ -260,8 +260,11 @@ export class ViewItem implements IViewItem { } if (!skipUserRender && this.element) { - const style = window.getComputedStyle(this.element); - const paddingLeft = parseFloat(style.paddingLeft); + let paddingLeft: number | undefined; + if (this.context.horizontalScrolling) { + const style = window.getComputedStyle(this.element); + paddingLeft = parseFloat(style.paddingLeft); + } if (this.context.horizontalScrolling) { this.element.style.width = 'fit-content'; -- GitLab