patch 9.1.0218: Unnecessary multiplications in backspace code
Problem: Unnecessary multiplications in backspace code, as
"col / ts * ts" is the same as "col - col % ts".
Solution: Change "col / ts * ts" to "col - col % ts". Adjust the loop
and the comments ins_bs() to be easier to understand. Update
tests to reset 'smarttab' properly.
(zeertzjq)
closes: #14308
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/indent.c b/src/indent.c
index 56032fa..1dfde7d 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -163,7 +163,7 @@
int excess;
if (vts == NULL || vts[0] == 0)
- return (col / ts) * ts;
+ return col - col % ts;
tabcount = vts[0];
for (t = 1; t <= tabcount; ++t)
@@ -174,7 +174,7 @@
}
excess = tabcol % vts[tabcount];
- return excess + ((col - excess) / vts[tabcount]) * vts[tabcount];
+ return col - (col - excess) % vts[tabcount];
}
/*