Insert an extra newline between brackets

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Nathan Sobo 2021-10-19 13:17:16 +02:00
parent 561857fdf2
commit 5558d553bb
5 changed files with 245 additions and 60 deletions

View file

@ -16,7 +16,7 @@ use clock::ReplicaId;
use gpui::{AppContext, Entity, ModelContext, MutableAppContext, Task};
pub use highlight_map::{HighlightId, HighlightMap};
use language::Tree;
pub use language::{AutoclosePair, Language, LanguageConfig, LanguageRegistry};
pub use language::{BracketPair, Language, LanguageConfig, LanguageRegistry};
use lazy_static::lazy_static;
use operation_queue::OperationQueue;
use parking_lot::Mutex;
@ -1337,6 +1337,13 @@ impl Buffer {
self.content().chars_at(position)
}
pub fn reversed_chars_at<'a, T: 'a + ToOffset>(
&'a self,
position: T,
) -> impl Iterator<Item = char> + 'a {
self.content().reversed_chars_at(position)
}
pub fn chars_for_range<T: ToOffset>(&self, range: Range<T>) -> impl Iterator<Item = char> + '_ {
self.text_for_range(range).flat_map(str::chars)
}
@ -2794,6 +2801,11 @@ impl<'a> Content<'a> {
self.visible_text.chars_at(offset)
}
pub fn reversed_chars_at<T: ToOffset>(&self, position: T) -> impl Iterator<Item = char> + 'a {
let offset = position.to_offset(self);
self.visible_text.reversed_chars_at(offset)
}
pub fn text_for_range<T: ToOffset>(&self, range: Range<T>) -> Chunks<'a> {
let start = range.start.to_offset(self);
let end = range.end.to_offset(self);