Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit a30af09

Browse files
committed
Delete obsolete code
1 parent 9eaa419 commit a30af09

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

src/lib.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -177,48 +177,6 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(diagnostic: &Diagnostic,
177177
}
178178
}
179179

180-
pub fn apply_suggestion(file_content: &mut String, suggestion: &Replacement) -> String {
181-
use std::cmp::max;
182-
183-
let mut new_content = String::new();
184-
185-
// Add the lines before the section we want to replace
186-
new_content.push_str(&file_content.lines()
187-
.take(max(suggestion.snippet.line_range.start.line - 1, 0) as usize)
188-
.collect::<Vec<_>>()
189-
.join("\n"));
190-
new_content.push_str("\n");
191-
192-
// Parts of line before replacement
193-
new_content.push_str(&file_content.lines()
194-
.nth(suggestion.snippet.line_range.start.line - 1)
195-
.unwrap_or("")
196-
.chars()
197-
.take(suggestion.snippet.line_range.start.column - 1)
198-
.collect::<String>());
199-
200-
// Insert new content! Finally!
201-
new_content.push_str(&suggestion.replacement);
202-
203-
// Parts of line after replacement
204-
new_content.push_str(&file_content.lines()
205-
.nth(suggestion.snippet.line_range.end.line - 1)
206-
.unwrap_or("")
207-
.chars()
208-
.skip(suggestion.snippet.line_range.end.column - 1)
209-
.collect::<String>());
210-
211-
// Add the lines after the section we want to replace
212-
new_content.push_str("\n");
213-
new_content.push_str(&file_content.lines()
214-
.skip(suggestion.snippet.line_range.end.line as usize)
215-
.collect::<Vec<_>>()
216-
.join("\n"));
217-
new_content.push_str("\n");
218-
219-
new_content
220-
}
221-
222180
pub fn apply_suggestions(code: &str, suggestions: &[Suggestion]) -> Result<String, Error> {
223181
use replace::Data;
224182

0 commit comments

Comments
 (0)