Fix #2104: fmt incorrectly using 1-indexing for columns (#2106)

* Fix #2104: fmt incorrectly using 1-indexing for columns

* Clippy...
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-03-18 18:23:45 -07:00
1 parent 2dc6cecf2e
commit d8942a255b
17 files changed
+756 -40

No files matched your search

+2 -1
View File
@@ -27,12 +27,13 @@ impl Writer<'_> {
// If the expr is multiline, we want to collect all of its lines together and write them out properly
// This involves unshifting the first line if it's aligned
let first_line = &self.src[start.line - 1];
write!(self.out, "{}", &first_line[start.column - 1..].trim_start())?;
write!(self.out, "{}", &first_line[start.column..].trim_start())?;
let prev_block_indent_level = self.out.indent.count_indents(first_line);
for (id, line) in self.src[start.line..end.line].iter().enumerate() {
writeln!(self.out)?;
// check if this is the last line
let line = {
if id == (end.line - start.line) - 1 {