Add basic support for ruby
Co-authored-by: Kay Simmons <kay@zed.dev>
This commit is contained in:
parent
9f3ea0c87f
commit
d222904471
13 changed files with 349 additions and 7 deletions
|
@ -1764,6 +1764,7 @@ impl BufferSnapshot {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
let mut indent_ranges = Vec::<Range<Point>>::new();
|
||||
let mut outdent_positions = Vec::<Point>::new();
|
||||
while let Some(mat) = matches.peek() {
|
||||
let mut start: Option<Point> = None;
|
||||
let mut end: Option<Point> = None;
|
||||
|
@ -1777,6 +1778,8 @@ impl BufferSnapshot {
|
|||
start = Some(Point::from_ts_point(capture.node.end_position()));
|
||||
} else if Some(capture.index) == config.end_capture_ix {
|
||||
end = Some(Point::from_ts_point(capture.node.start_position()));
|
||||
} else if Some(capture.index) == config.outdent_capture_ix {
|
||||
outdent_positions.push(Point::from_ts_point(capture.node.start_position()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1797,6 +1800,19 @@ impl BufferSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
outdent_positions.sort();
|
||||
for outdent_position in outdent_positions {
|
||||
// find the innermost indent range containing this outdent_position
|
||||
// set its end to the outdent position
|
||||
if let Some(range_to_truncate) = indent_ranges
|
||||
.iter_mut()
|
||||
.filter(|indent_range| indent_range.contains(&outdent_position))
|
||||
.last()
|
||||
{
|
||||
range_to_truncate.end = outdent_position;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the suggested indentation increases and decreased based on regexes.
|
||||
let mut indent_change_rows = Vec::<(u32, Ordering)>::new();
|
||||
self.for_each_line(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue