Skip to content

Commit fb1382d

Browse files
committed
rename neares tab var and update comment
1 parent c725ca3 commit fb1382d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ impl<T: AsRef<str>> fmt::Display for Grid<T> {
355355
// * cursor = 0, \t moves to column 8;
356356
// * cursor = 5, \t moves to column 8 (3 spaces);
357357
// * cursor = 9, \t moves to column 16 (7 spaces).
358-
// Calculate first \t size.
359-
let first_tab = tab_size - (cursor % tab_size);
358+
// Calculate the nearest \t position in relation to cursor.
359+
let closest_tab = tab_size - (cursor % tab_size);
360360

361-
if first_tab > total_spaces {
361+
if closest_tab > total_spaces {
362362
f.write_str(&padding[..total_spaces])?;
363363
} else {
364-
let rest_spaces = total_spaces - first_tab;
364+
let rest_spaces = total_spaces - closest_tab;
365365
let tabs = 1 + (rest_spaces / tab_size);
366366
let spaces = rest_spaces % tab_size;
367367
f.write_str(&"\t".repeat(tabs))?;

0 commit comments

Comments
 (0)