Jelajahi Sumber

修复`lambda`格式化不兼容`->`的问题

mxd 3 tahun lalu
induk
melakukan
4279c238a3

+ 1 - 1
magic-editor/src/console/src/scripts/beautifier/javascript/beautifier.js

@@ -696,7 +696,7 @@ Beautifier.prototype.handle_start_block = function(current_token) {
     } else {
       this.set_mode(MODE.BlockStatement);
     }
-  } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') {
+  } else if (this._flags.last_token.type === TOKEN.OPERATOR && (this._flags.last_token.text === '=>' || this._flags.last_token.text === '->')) {
     // arrow function: (param1, paramN) => { statements }
     this.set_mode(MODE.BlockStatement);
   } else if (in_array(this._flags.last_token.type, [TOKEN.EQUALS, TOKEN.START_EXPR, TOKEN.COMMA, TOKEN.OPERATOR]) ||

+ 1 - 1
magic-editor/src/console/src/scripts/beautifier/javascript/tokenizer.js

@@ -83,7 +83,7 @@ var positionable_operators = (
 var punct =
   ">>>= " +
   "... >>= <<= === >>> !== **= " +
-  "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
+  "=> -> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
   "= ! ? > < : / ^ - + * & % ~ |";
 
 punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");