没有明显的原因,星期一,我的VS2017开始在this SO post中突出显示错误,并且所有JS Intellisense和自动格式化都消失了。
设法通过关闭Enable the new JavaScript language service
来解决此问题,但是现在自动格式化功能忽略了我的设置;内部样式在设置了函数之后的换行符上设置了大括号,但是现在Ctrl-E-D重新格式化将所有大括号移动到与函数定义相同的行。
我该如何解决?
编辑:我发现这个旧线程存在相同的问题,但遗憾的是,新语言服务没有修复:https://developercommunity.visualstudio.com/content/problem/138728/if-statements-still-place-a-opening-brace-on-the-s.html
令人烦恼的是,它已经工作了好几个月,直到昨天才停止,而且没有任何设置更改。
编辑以添加Intellisense错误:
The JavaScript and TypeScript language service has been disabled due to an error. You may see reduced IntelliSense support for your project. Please try reloading your solution to reenable the language service.
Error processing request. Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:16674:110)
at Object.parseJsonText (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:16508:26)
at Object.parseJsonText (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:16330:23)
at ProjectService.loadConfiguredProject (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:120258:33)
at ProjectService.createAndLoadConfiguredProject (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:120247:22)
at ProjectService.createLoadAndUpdateConfiguredProject (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:120251:36)
at ProjectService.openClientFileWithNormalizedPath (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:120776:44)
at ProjectService.applyChangesInOpenFiles (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:120882:30)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:121548:46)
at C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:123063:88
at IOSession.Session.executeWithRequestId (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:123054:28)
at IOSession.Session.executeCommand (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:123063:33)
at IOSession.Session.onMessage (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:123083:35)
at Interface.<anonymous> (C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.1\tsserver.js:124346:27)
at Interface.emit (events.js:182:13)
at Interface._onLine (readline.js:290:10)
at Interface._normalWrite (readline.js:433:12)
at Socket.ondata (readline.js:149:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at Pipe.onread (net.js:638:20)
答案 0 :(得分:1)
禁用新语言服务。
1。禁用JavaScript Language Service
后,请使用以下Developer command prompt中的命令来设置选项:
CD %VSINSTALLDIR%
vsregedit set . HKCU "ApplicationPrivateSettings\TextEditor\JavaScript\Specific" "PlaceOpenBraceOnNewLineForControlBlocks" string "0*System.Int32*1"
请参见this。
启用新语言服务。
2。尝试创建一个新项目(也许您在node.js项目中?),以检查类似问题是否仍然存在,如果该问题消失,则可能是您的项目现在包含太多JS文件的原因。请在此处查看limitation。
如果问题仍然存在于新项目中,请修复VS或将VS2017更新至最新的15.9.16,以检查是否有帮助。我想您的环境中有些东西坏了。
另外,在关闭VS clean the VS cache后,尝试在解决方案目录中删除隐藏的.vs
文件夹,然后重新启动VS。