Add support for auto-closing of JSX tags (#25681)
Closes #4271 Implemented by kicking of a task on the main thread at the end of `Editor::handle_input` which waits for the buffer to be re-parsed before checking if JSX tag completion possible based on the recent edits, and if it is then it spawns a task on the background thread to generate the edits to be auto-applied to the buffer Release Notes: - Added support for auto-closing of JSX tags --------- Co-authored-by: Cole Miller <cole@zed.dev> Co-authored-by: Max Brunsfeld <max@zed.dev> Co-authored-by: Marshall Bowers <git@maxdeviant.com> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
parent
05df3d1bd6
commit
ff25fa24e7
15 changed files with 1207 additions and 149 deletions
|
|
@ -3080,6 +3080,25 @@ impl BufferSnapshot {
|
|||
.last()
|
||||
}
|
||||
|
||||
pub fn smallest_syntax_layer_containing<D: ToOffset>(
|
||||
&self,
|
||||
range: Range<D>,
|
||||
) -> Option<SyntaxLayer> {
|
||||
let range = range.to_offset(self);
|
||||
return self
|
||||
.syntax
|
||||
.layers_for_range(range, &self.text, false)
|
||||
.max_by(|a, b| {
|
||||
if a.depth != b.depth {
|
||||
a.depth.cmp(&b.depth)
|
||||
} else if a.offset.0 != b.offset.0 {
|
||||
a.offset.0.cmp(&b.offset.0)
|
||||
} else {
|
||||
a.node().end_byte().cmp(&b.node().end_byte()).reverse()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the main [`Language`].
|
||||
pub fn language(&self) -> Option<&Arc<Language>> {
|
||||
self.language.as_ref()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue