mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +00:00
vim-patch:9.1.0218: Unnecessary multiplications in backspace code (#28075)
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: vim/vim#14308
8ede7a0694
This commit is contained in:
@@ -177,7 +177,7 @@ colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts)
|
||||
colnr_T tabcol = 0;
|
||||
|
||||
if (vts == NULL || vts[0] == 0) {
|
||||
return ((col / ts) * ts);
|
||||
return col - col % ts;
|
||||
}
|
||||
|
||||
const int tabcount = vts[0];
|
||||
@@ -189,7 +189,7 @@ colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts)
|
||||
}
|
||||
|
||||
const int excess = (tabcol % vts[tabcount]);
|
||||
return (excess + ((col - excess) / vts[tabcount]) * vts[tabcount]);
|
||||
return col - (col - excess) % vts[tabcount];
|
||||
}
|
||||
|
||||
/// Find the number of tabs and spaces necessary to get from one column
|
||||
|
Reference in New Issue
Block a user