diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-28 18:20:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-28 18:20:38 +0800 |
commit | 08b8ccd733ca2a7888ad221d5cc6e1f1e994a02d (patch) | |
tree | 644e0a0eedb2fe8bc76d1065fd165e0754a3f940 /src/nvim/indent.c | |
parent | 6364fc617ded29100c1aa3103e189fd983dd5e64 (diff) | |
download | rneovim-08b8ccd733ca2a7888ad221d5cc6e1f1e994a02d.tar.gz rneovim-08b8ccd733ca2a7888ad221d5cc6e1f1e994a02d.tar.bz2 rneovim-08b8ccd733ca2a7888ad221d5cc6e1f1e994a02d.zip |
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
https://github.com/vim/vim/commit/8ede7a069419e0e01368c65a2d0c79d6332aa6cd
Diffstat (limited to 'src/nvim/indent.c')
-rw-r--r-- | src/nvim/indent.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c index d477b466d7..d635c7d7bf 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -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 |