admin管理员组文章数量:1287584
I'm experiencing an issue where "unreachable code" in a Vue/TypeScript file is automatically deleted on save. (A pretty shocking behaviour, often I'm temporarily adding a "return false" early in a function during debugging, I'd never expect the rest of the function body to be deleted!)
Through a process of elimination I have discovered that disabling either the "Vue - Official" or built-in "TypeScript and JavaScript Language Server" extension disables the behaviour, so presumably they are collectively the culprit.
I have found a way to prevent this by adding this to my settings.json
:
"editor.codeActionsOnSave": {
"source.fixAll": "false"
},
But this is a big hammer to use. I would like to disable this just for the Vue extension.
I can't find any proper documentation on editor.codeActionsOnSave
but from various references around the place, I'd expect this to work:
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.vue": "never",
},
or
"source.fixAll.typescript": "never",
however, it does not. The source.fixAll
setting by itself works, but source.fixAll.vue
does not seem to have any effect, whether or not source.fixAll
is present (and same for typescript
).
How can I achieve this?
Also, ideally, how can I disable just this one specific behaviour, without disabling other code fixes from the Vue extension?
EDIT
Hmm, "source.fixAll.ts": "never"
does work, but I'm still wondering: is it the TypeScript extension itself that is doing the heavy-handed "fixing", or something else? How can I find the real culprit?
By enabling logging for the TS Server, I see this:
Info 790 [11:36:27.518] response:
{"seq":0,"type":"response","command":"getCodeFixes","request_seq":20,"success":true,"body":[{"fixName":"fixUnreachableCode","description":"Remove unreachable code","changes":[{"fileName":"[redacted]]","textChanges":[{"start":{"line":86,"offset":1},"end":{"line":89,"offset":1},"newText":""}]}]}]}
Info 791 [11:36:27.624] request:
{
"seq": 21,
"type": "request",
"command": "updateOpen",
"arguments": {
"changedFiles": [
{
"fileName": "[redacted]]",
"textChanges": [
{
"newText": "",
"start": {
"line": 86,
"offset": 1
},
"end": {
"line": 89,
"offset": 1
}
}
]
}
],
"closedFiles": [],
"openFiles": []
}
}
I think this means the TS extension itself is the one doing the "fixing"?
本文标签: vuejsHow to prevent Vue extension from quotfixingquot my codeStack Overflow
版权声明:本文标题:vue.js - How to prevent Vue extension from "fixing" my code? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741298928a2370977.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论