This commit is contained in:
Antonio Scandurra 2021-05-11 12:41:38 +02:00
parent 07ef0d474e
commit d9e7547d95

View file

@ -1799,38 +1799,31 @@ impl BufferView {
let app = ctx.as_ref(); let app = ctx.as_ref();
let mut selections = self.selections(app).to_vec(); let mut selections = self.selections(app).to_vec();
let mut state = if let Some(state) = self.add_selections_state.take() { let mut state = self.add_selections_state.take().unwrap_or_else(|| {
state
} else {
let oldest_selection = selections.iter().min_by_key(|s| s.id).unwrap().clone(); let oldest_selection = selections.iter().min_by_key(|s| s.id).unwrap().clone();
let range = oldest_selection let range = oldest_selection
.display_range(&self.display_map, app) .display_range(&self.display_map, app)
.sorted(); .sorted();
let columns = cmp::min(range.start.column(), range.end.column())
..cmp::max(range.start.column(), range.end.column());
selections.clear(); selections.clear();
let mut stack = Vec::new(); let mut stack = Vec::new();
if range.start.row() == range.end.row() { for row in range.start.row()..=range.end.row() {
stack.push(oldest_selection.id); if let Some(selection) =
selections.push(oldest_selection); self.build_columnar_selection(row, &columns, oldest_selection.reversed, app)
} else { {
let columns = cmp::min(range.start.column(), range.end.column()) stack.push(selection.id);
..cmp::max(range.start.column(), range.end.column()); selections.push(selection);
for row in range.start.row()..=range.end.row() {
if let Some(selection) =
self.build_columnar_selection(row, &columns, oldest_selection.reversed, app)
{
stack.push(selection.id);
selections.push(selection);
}
}
if above {
stack.reverse();
} }
} }
if above {
stack.reverse();
}
AddSelectionsState { above, stack } AddSelectionsState { above, stack }
}; });
let last_added_selection = *state.stack.last().unwrap(); let last_added_selection = *state.stack.last().unwrap();
let mut new_selections = Vec::new(); let mut new_selections = Vec::new();