RubyMine ( IntelliJ 通用 ) 编辑 Slim + Vue.js 遇到文件无法打开的坑

in develop •  6 years ago  (edited)

一. 状况说明

使用的环境是 Rails + Vue.js.
前端用的是 Slim + CoffeeScript + Sass
(确实比较小众啊, 公司用的环境没办法).
IDE 用的 IntelliJRubyMine
偶尔会发生.slim文件写着写着就崩溃, 现象是文件无法录入任何字符,
有时文件内部不对键盘做出任何反应, 上下移动光标都不可以.

在重启RubyMine后, 出问题的文件无论如何也打不开.

二. 找原因

第一次发生这种现象的时候不知道怎么折腾着就又好了, 所以就没深究, 但第三次就有点恼人了.
在重启/清内存/清缓存 不好使之后开始针对各种plugin 进行排查,
总算找到闹事的家伙:
Ruby Slim Support Integration

问题的来源是找到了, 但是原因呢?

Ruby Slim Support Integration这个插件是用来分析Slim的语法的.
可能是代码中哪个Slim语法它分析不出来, 导致运行时错误.
抱着这个可能性, 用逐行删除代码的方式排查了一上午, 终于被我找到一句:

#'[]' 用来包裹多个属性, 用于在元素属性过多的时候折行, 提高代码可读性
img.feed_img.feed_thumb [:id="feed.id" 
    :
    :large="feed.nodes[0][2]" 
    v-lazy="feed.thumbs[4]" 
    v-if="feed.error == 0"]

代码里[]用来包裹多个属性.
问题出在, 在[ 开始后的第一个新行里由冒号:开始时, 插件会无法分析语义.
这里我是准备输入Vue的 bind语法途中程序崩溃的.

三.解决方法 / 总结

解决方法就是小心不要在[下一行用:起头儿.
或者尽量不使用属性包裹[]
当然也不排除插件还有其他语义分析问题, 如果担心这种情况再次发生, 也可以索性吧插件关掉.
Preference => Plugin里关掉 Ruby Slim Support Integration 后面的对号:

以上!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello @super.marrimo! This is a friendly reminder that you have 3000 Partiko Points unclaimed in your Partiko account!

Partiko is a fast and beautiful mobile app for Steem, and it’s the most popular Steem mobile app out there! Download Partiko using the link below and login using SteemConnect to claim your 3000 Partiko points! You can easily convert them into Steem token!

https://partiko.app/referral/partiko

Congratulations @super.marrimo! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Valentine's day challenge - Give a badge to your beloved!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!