@@ -1873,14 +1873,17 @@ pub fn indent(cx: &mut Context) {
18731873}
18741874
18751875pub fn unindent(cx: &mut Context) {
1876+ let count = cx.count;
18761877 let (view, doc) = cx.current();
18771878 let lines = get_lines(doc, view.id);
18781879 let mut changes = Vec::with_capacity(lines.len());
18791880 let tab_width = doc.tab_width();
1881+ let indent_width = count * tab_width;
18801882
18811883 for line_idx in lines {
18821884 let line = doc.text().line(line_idx);
18831885 let mut width = 0;
1886+ let mut pos = 0;
18841887
18851888 for ch in line.chars() {
18861889 match ch {
@@ -1889,14 +1892,17 @@ pub fn unindent(cx: &mut Context) {
18891892 _ => break,
18901893 }
18911894
1892− if width >= tab_width {
1895+ pos += 1;
1896+
1897+ if width >= indent_width {
18931898 break;
18941899 }
18951900 }
18961901
1897− if width > 0 {
1902+ // now delete from start to first non-blank
1903+ if pos > 0 {
18981904 let start = doc.text().line_to_char(line_idx);
1899− changes.push((start, start + width, None))
1905+ changes.push((start, start + pos, None))
19001906 }
19011907 }
19021908