@@ -45,7 +45,7 @@ fn find_line_comment(
4545
4646 // determine margin of 0 or 1 for uncommenting; if any comment token is not followed by a space,
4747 // a margin of 0 is used for all lines.
48− if matches!(line_slice.get_char(pos + token_len), Some(c) if c != ' ') {
48+ if !matches!(line_slice.get_char(pos + token_len), Some(c) if c == ' ') {
4949 margin = 0;
5050 }
5151
@@ -108,8 +108,8 @@ mod test {
108108 let text = doc.slice(..);
109109
110110 let res = find_line_comment("//", text, 0..3);
111− // (commented = true, to_change = [line 0, line 2], min = col 2, margin = 1)
112− assert_eq!(res, (false, vec![0, 2], 2, 1));
111+ // (commented = true, to_change = [line 0, line 2], min = col 2, margin = 0)
112+ assert_eq!(res, (false, vec![0, 2], 2, 0));
113113
114114 // comment
115115 let transaction = toggle_line_comments(&doc, &selection, None);
@@ -136,6 +136,17 @@ mod test {
136136 assert_eq!(doc, " 1\n\n 2\n 3");
137137 assert!(selection.len() == 1); // to ignore the selection unused warning
138138
139+ // 0 margin comments, with no space
140+ doc = Rope::from("//");
141+ // reset the selection.
142+ selection = Selection::single(0, doc.len_chars() - 1);
143+
144+ let transaction = toggle_line_comments(&doc, &selection, None);
145+ transaction.apply(&mut doc);
146+ selection = selection.map(transaction.changes());
147+ assert_eq!(doc, "");
148+ assert!(selection.len() == 1); // to ignore the selection unused warning
149+
139150 // TODO: account for uncommenting with uneven comment indentation
140151 }
141152}