Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何实现代码fold功能? #219

Open
PPixie opened this issue Jun 12, 2024 · 1 comment
Open

如何实现代码fold功能? #219

PPixie opened this issue Jun 12, 2024 · 1 comment

Comments

@PPixie
Copy link

PPixie commented Jun 12, 2024

如何实现代码fold功能?

@otakustay
Copy link
Owner

组件底下的数据模型就是那个hunks数组,实际上代码折叠之类的都是基于这个数组上的操作。比如把数组中隐藏一些东西,代码自然不显示出来了,然后再用Decoration这个组件加上“展开”之类的功能就行

具体的,你可以考虑看下原码中的site这个目录,它是一个功能比较全面的示例,里面的Unfold这个组件就是用来展开代码的,它会收一个叫onExpand的函数,这个函数定义在site/components/DiffView/index.tsx文件里的expandRange函数,用了react-diff-view直接提供的能力,应该比较容易看懂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants