为什么 google 脚本编辑器在函数中的 100 行后停止括号匹配,它会影响代码吗? [英] Why does google script editor stop paren matching after 100 lines in a function and does it affect the code?

查看:19
本文介绍了为什么 google 脚本编辑器在函数中的 100 行后停止括号匹配,它会影响代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌脚本编辑器中

函数 foo(){...//超过 100 行..}

function foo(){ . . . // more than 100 lines . . }

点击 { 或 } 突出显示红色

clicking on { or } highlights both in red

少于 100 行的都是绿色的.

with less than 100 lines both are green.

它会影响代码还是只是为了让我们感到困惑.

Does it affect the code or is it just there to confuse us.

推荐答案

我自己尝试过,并在 Windows Vista 上使用 Chrome 重现了您的结果.括号匹配变为红色,左括号和右括号之间正好有 100 行空行.

I've tried this myself, and reproduced your results, using Chrome on Windows Vista. The paren matching went Red with exactly 100 blank lines between the opening and closing braces.

非信徒尝试的步骤:

  1. 在云端硬盘/文档中,为空白项目创建一个新脚本.
  2. 从myFunction()"的模板开始.将光标放在左大括号或右大括号旁边,并观察大括号是否与绿色匹配.
  3. 现在在函数体中输入空行,直到右大括号在第 101 行.
  4. 将光标放在大括号旁边,观察它是红色的.
  5. 删除一行,然后再次检查...现在它是绿色的.

所以,确认,括号匹配停止,并不是因为代码格式错误.为什么?好吧,我的猜测是一些限制是必要的,而 100 是一个不错的整数.

So, CONFIRMED, paren matching stopped, and not because the code was malformed. Why? Well, my guess would be that some limit was necessary, and 100 was a nice, round number.

Paren 又名圆括号、方括号或大括号.

Paren aka parentheses, brackets, or braces.

它会影响您的代码吗?不 - 在保存操作期间,代码正确解析.(如果没有,您会得到一些错误,这些错误可能有助于也可能无济于事.)

Does it affect your code? Nope - during the save operation, the code parses correctly. (If it didn't, you'd get some error that might or might not help figure out your mistake.)

但为什么不把 100 行限制作为提示,重构你的代码呢?

But why not take that 100-line limit as a hint, and refactor your code?

这篇关于为什么 google 脚本编辑器在函数中的 100 行后停止括号匹配,它会影响代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆