adjust indentation when multiple lines are selected
@@ -648,6 +648,19 @@ impl Editor {
}
fn insert_tab(&mut self) {
+ let nb_regions = self.view.sel_regions().len();
+
+ let nb_lines = if nb_regions == 1 {
+ let mut region = self.view.sel_regions()[0];
+ let mut sel_text = self.text.slice(region.start, region.end);
+ sel_text.measure::<LinesMetric>() + 1
+ }
+ else{ 0 };
+
+ if nb_lines > 1 {
+ self.modify_indent(IndentDirection::In);
+ }
+ else {
let mut builder = delta::Builder::new(self.text.len());
for region in self.view.sel_regions() {
let iv = Interval::new_closed_open(region.min(), region.max());
@@ -663,6 +676,7 @@ impl Editor {
}
self.this_edit_type = EditType::InsertChars;
self.add_delta(builder.build());
+ }
// What follows is old indent code, retained because it will be useful for
// indent action (Sublime no longer does indent on non-caret selections).
