Add FoldFunctionBodies editor action (#21504)
Related to #19424 This uses the new text object support, so will only work for languages that have `textobjects.scm`. It does not integrate with indentation-based folding for now, and the syntax-based folds don't have matching fold markers in the gutter (unless they are folded). Release Notes: - Add an editor action to fold all function bodies Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
ce5f492404
commit
c5d15fd065
4 changed files with 27 additions and 0 deletions
|
@ -3355,6 +3355,14 @@ impl BufferSnapshot {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn function_body_fold_ranges<T: ToOffset>(
|
||||
&self,
|
||||
within: Range<T>,
|
||||
) -> impl Iterator<Item = Range<usize>> + '_ {
|
||||
self.text_object_ranges(within, TreeSitterOptions::default())
|
||||
.filter_map(|(range, obj)| (obj == TextObject::InsideFunction).then_some(range))
|
||||
}
|
||||
|
||||
/// For each grammar in the language, runs the provided
|
||||
/// [`tree_sitter::Query`] against the given range.
|
||||
pub fn matches(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue