Skip to content

Commit ee128f3

Browse files
committed
Remember Trailing Semicolons
1 parent 2224a55 commit ee128f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,23 @@ fn apply_suggestion(suggestion: &rustfix::Suggestion) -> Result<(), ProgramError
200200
.take(max(suggestion.line_range.start.line - 1, 0) as usize)
201201
.collect::<Vec<_>>()
202202
.join("\n"));
203-
new_content.push_str("\n");
203+
204+
// Some suggestions seem to currently omit the trailing semicolon
205+
let remember_a_semicolon = new_content.ends_with(';');
204206

205207
// Indentation
208+
new_content.push_str("\n");
206209
new_content.push_str(&repeat(" ")
207210
.take(suggestion.line_range.start.column - 1 as usize)
208211
.collect::<String>());
209212

210213
// TODO(killercup): Replace sections of lines only
211214
new_content.push_str(suggestion.replacement.trim());
212215

216+
if remember_a_semicolon {
217+
new_content.push_str(";");
218+
}
219+
213220
// Add the lines after the section we want to replace
214221
new_content.push_str("\n");
215222
new_content.push_str(&file_content.lines()

0 commit comments

Comments
 (0)