aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libeditor/src/typing.rs4
-rw-r--r--crates/libeditor/tests/test.rs8
2 files changed, 11 insertions, 1 deletions
diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs
index 918f2325c..04021d164 100644
--- a/crates/libeditor/src/typing.rs
+++ b/crates/libeditor/src/typing.rs
@@ -72,9 +72,11 @@ fn remove_newline(
72 if node.kind() == WHITESPACE && node_text.bytes().filter(|&b| b == b'\n').count() == 1 { 72 if node.kind() == WHITESPACE && node_text.bytes().filter(|&b| b == b'\n').count() == 1 {
73 match (node.prev_sibling(), node.next_sibling()) { 73 match (node.prev_sibling(), node.next_sibling()) {
74 (Some(prev), Some(next)) => { 74 (Some(prev), Some(next)) => {
75 let range = TextRange::from_to(prev.range().start(), node.range().end());
75 if prev.kind() == COMMA && (next.kind() == R_PAREN || next.kind() == R_BRACK) { 76 if prev.kind() == COMMA && (next.kind() == R_PAREN || next.kind() == R_BRACK) {
76 let range = TextRange::from_to(prev.range().start(), node.range().end());
77 edit.delete(range); 77 edit.delete(range);
78 } else if prev.kind() == COMMA && next.kind() == R_CURLY {
79 edit.replace(range, " ".to_string());
78 } else { 80 } else {
79 edit.replace( 81 edit.replace(
80 node.range(), 82 node.range(),
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs
index e5088ad27..858c6c4a6 100644
--- a/crates/libeditor/tests/test.rs
+++ b/crates/libeditor/tests/test.rs
@@ -224,6 +224,14 @@ fn foo() {
224 foo(1, 2, 3) 224 foo(1, 2, 3)
225} 225}
226"); 226");
227
228 do_check(r"
229struct Foo <|>{
230 f: u32,
231}<|>
232", r"
233struct Foo { f: u32 }
234");
227} 235}
228 236
229fn file(text: &str) -> ParsedFile { 237fn file(text: &str) -> ParsedFile {