Skip to content

Commit

Permalink
core: fix TreeWidget#applyFontStyles
Browse files Browse the repository at this point in the history
Fix wrong logic, most likely a typo.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
paul-marechal committed Jan 12, 2021
1 parent 5db308f commit db4b2e7
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}".`);
}
});
}
Expand Down

0 comments on commit db4b2e7

Please sign in to comment.