“格式选择”用漂亮的扩展名中的整个文档格式化整个文档

发布于 2025-02-09 14:30:12 字数 224 浏览 0 评论 0原文

我正在研究一个打字稿项目,并且有VS代码最新版本(版本:1.68.1(Universal))。我在VS代码中安装了更漂亮的,并且当我尝试格式化选定的代码时,我会出现问题。它不是格式化选择,而是格式化整个文档,这使得由于较大数量的git diffs而变得困难。

我尝试编辑设置。正如少数帖子中提到的那样,但无济于事,似乎被弃用了。当右键单击VS代码中时,我也不会看到“格式选择”选项。

为什么会发生这种情况?

I am working on a typescript project and i have VS code latest version (Version: 1.68.1 (Universal)).I have prettier installed in VS code and i am having issue when i try to format a selected code. rather than formatting the selection, it format the entire document which makes it hard while code review because of the larger number of git diffs.

I tried editing the settings.json as mentioned in few of the posts but did not help and seems to be deprecated. I also don't see the "Format Selection with" option when in right click in VS code.

Why does this happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪推晚风 2025-02-16 14:30:12

很长一段时间以来,更漂亮, 建立VS代码的扩展名,存在与范围格式相关的问题。过去(固定)有它们,仍然有它们(不是固定),并且可能会继续被发现。维护者自己这样说在这里。您可以通过浏览 httpps:// htttps:// github.com/prettier/prettier/issues?q = is%3aissue+is%3aopen+range+

有关esbenp.prettier-vscode扩展名单中的发行票证的示例(我只是通过谷歌搜索找到的“ 网站:github.com/prettier/prettier/prettier-vscode/issues format /code>“),请参见#134 (2017年6月),#137 (2017年6月),#2041 (2021年6月),#3145 (2023年9月)。

即使从历史上看,esbenp.prettier-vscode也有某些设置将其视为已知问题。前任。 <

改进的范围formater
@JosephFrazier在这里将他的作品带到了Prettier的范围Formater上。现在,我们的范围Formater改善了工作。
⚠️通过Eslint的集成,它将格式化整个文档。但这仍然比以前更好!

For a long time, Prettier itself, which the esbenp.prettier-vscode extension for VS Code is built on, has had issues related to range formatting. It's had them in the past (fixed), still has them (not fixed), and more will probably keep being discovered. The maintainers say so themselves here. You can find a list by going through https://github.com/prettier/prettier/issues?q=is%3Aissue+is%3Aopen+range+.

For examples for issue tickets in the esbenp.prettier-vscode extension's repo (which I found just by googling "site:github.com/prettier/prettier-vscode/issues format selection whole document"), see #134 (June 2017), #137 (June 2017), #2041 (June 2021), #3145 (Sept 2023).

Even historically, there have been releases of esbenp.prettier-vscode where certain setups would treat this as a known issue. Ex. 1.18.0:

Improved range formater
@josephfrazier brought his work on prettier's range formater here. Our range formater is now improved working.
⚠️ With eslint's integration it will format the entire document. But it still is waaaaaaaay better than before !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文