在我正在开发的这个项目的源代码中,我们有大量的 JSX 来本地化字符串,所以不要使用例如:
<section>
lore impsum sit amet
</section>
我们有:
<section>
<SomeCustomWrapper props="X">
<AnotherWrapper
message="lorem impsum sit amet"
description={{
text: "description for lore impsum sit amet",
someMoreProps: "X"
}}
/>
</SomeCustomWrapper>
</section>
我想编写一个 VS code 插件来“折叠/展开”那些 SomeCustomWrappers,以便编辑器在折叠时显示这些标签,例如:
<section>
<string: "lorem impsum sit amet">
</section>
但是我不确定 VS Code API 是否可以实现,如果可以的话,您对如何实现它有任何提示吗?
FoldingRangeProvider
。
至于以编程方式切换提供的折叠区域,我认为您可以使用
editor.fold
命令(另请参阅 FoldingArguments
的定义)和 executeCommand
来完成此操作。
要渲染摘要文本,请使用文本编辑器装饰 API。