Skip to content

Commit feec448

Browse files
committed
ls: simplify dired helpers
1 parent 9889c05 commit feec448

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/uu/ls/src/dired.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn print_dired_output(
108108
}
109109

110110
/// Helper function to print positions with a given prefix.
111-
fn print_positions(prefix: &str, positions: &Vec<BytePosition>) {
111+
fn print_positions(prefix: &str, positions: &[BytePosition]) {
112112
print!("{prefix}");
113113
for c in positions {
114114
print!(" {c}");
@@ -117,16 +117,9 @@ fn print_positions(prefix: &str, positions: &Vec<BytePosition>) {
117117
}
118118

119119
pub fn add_total(dired: &mut DiredOutput, total_len: usize) {
120-
if dired.padding == 0 {
121-
// when dealing with " total: xx", it isn't part of the //DIRED//
122-
// so, we just keep the size line to add it to the position of the next file
123-
dired.padding = total_len + DIRED_TRAILING_OFFSET;
124-
} else {
125-
// += because if we are in -R, we have " dir:\n total X". So, we need to take the
126-
// previous padding too.
127-
// and we already have the previous position in mind
128-
dired.padding += total_len + DIRED_TRAILING_OFFSET;
129-
}
120+
// += because if we are in -R, we have " dir:\n total X". So, we need to take the
121+
// previous padding too.
122+
dired.padding += total_len + DIRED_TRAILING_OFFSET;
130123
}
131124

132125
// when using -R, we have the dirname. we need to add it to the padding
@@ -156,7 +149,7 @@ pub fn update_positions(dired: &mut DiredOutput, start: usize, end: usize, line_
156149
start: start + padding,
157150
end: end + padding,
158151
});
159-
dired.line_offset = dired.line_offset + padding + line_len;
152+
dired.line_offset += padding + line_len;
160153
// Remove the previous padding
161154
dired.padding = 0;
162155
}

0 commit comments

Comments
 (0)