Преглед изворни кода

Check if `delta` arg is a number.

Raffaele De Feo пре 6 година
родитељ
комит
dcee725b7a
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      packages/fileeditor-extension/src/index.ts

+ 7 - 1
packages/fileeditor-extension/src/index.ts

@@ -210,7 +210,13 @@ function activate(
   // Add a command to change font size.
   commands.addCommand(CommandIDs.changeFontSize, {
     execute: args => {
-      const delta = args['delta'] as number;
+      const delta = Number(args['delta']);
+      if (Number.isNaN(delta)) {
+        console.error(
+          `${CommandIDs.changeFontSize}: delta arg must be a number`
+        );
+        return;
+      }
       const style = window.getComputedStyle(document.documentElement);
       const cssSize = parseInt(
         style.getPropertyValue('--jp-code-font-size'),