From db4b2e7159aa68f09577dfc212909d97f3e2d1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Mar=C3=A9chal?= Date: Mon, 11 Jan 2021 20:07:59 -0500 Subject: [PATCH] core: fix TreeWidget#applyFontStyles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix wrong logic, most likely a typo. Signed-off-by: Paul Maréchal --- .../core/src/browser/tree/tree-widget.tsx | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/packages/core/src/browser/tree/tree-widget.tsx b/packages/core/src/browser/tree/tree-widget.tsx index 50bd01b616a6f..4408fab712f57 100644 --- a/packages/core/src/browser/tree/tree-widget.tsx +++ b/packages/core/src/browser/tree/tree-widget.tsx @@ -658,40 +658,28 @@ export class TreeWidget extends ReactWidget implements StatefulWidget { if (fontData === undefined) { return original; } - let modified = original; + const modified = { ...original }; // make a copy to mutate const { color, style } = fontData; if (color) { - modified = { - ...modified, - color - }; + modified.color = color; } if (style) { (Array.isArray(style) ? style : [style]).forEach(s => { - switch (style) { + switch (s) { case 'bold': - modified = { - ...modified, - fontWeight: style - }; + modified.fontWeight = s; break; - case 'normal': // Fall through. - case 'oblique': // Fall through. + case 'normal': + case 'oblique': case 'italic': - modified = { - ...modified, - fontStyle: style - }; + modified.fontStyle = s; break; - case 'underline': // Fall through. + case 'underline': case 'line-through': - modified = { - ...modified, - textDecoration: style - }; + modified.textDecoration = s; break; default: - throw new Error(`Unexpected font style: ${style}.`); + throw new Error(`Unexpected font style: "${s}".`); } }); }