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

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

问题描述

在Google脚本编辑器中



函数foo(){



//超过100行


}



单击{或}突出显示红色

是绿色的。



它是否影响代码,或者它只是在那里让我们感到困惑。

解决方案

我自己尝试过,并使用Windows Vista上的Chrome再现了您的结果。 paren的匹配变成了红色,在开始和结束括号之间有100条空行。



对非信徒来说,尝试的步骤:


  1. 在Drive / Docs中,为空白项目创建一个新脚本。 将光标放在打开或关闭大括号旁边,并注意大括号与绿色相匹配。

  2. 现在在函数体中输入空行,直到右大括号在第101行。
  3. >
  4. 将光标放在大括号旁边,观察它是红色的。

  5. 删除一行,再次检查...现在是绿色。 >

因此,CONFIRMED,paren匹配已停止,而不是因为代码格式错误。为什么?那么,我的猜测是,一些限制是必要的,100是一个不错的整数。

编辑:帕伦aka括号,括号,或大括号。

它会影响你的代码吗?没有 - 在保存操作过程中,代码正确解析。 (如果没有,你会得到一些错误,可能会或可能无法找出你的错误。)



但是为什么不把这100行限制当作一个提示,并重构你的代码?

in google script editor

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

clicking on { or } highlights both in red

with less than 100 lines both are green.

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

解决方案

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.

Steps to try, for the non-believers:

  1. In Drive / Docs, create a new script for a blank project.
  2. Start with the template for "myFunction()". Place the cursor next to the opening or closing brace, and observe that the brace matches green.
  3. Now enter blank lines in the function body until the closing brace is on line 101.
  4. Place the cursor next to the brace, and observe that it's red.
  5. Delete one line, and check again... now it's green.

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.

Edit: 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.)

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

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

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