comparison src/ops.c @ 20822:8e5f991db3b4 v8.2.0963

patch 8.2.0963: number increment/decrement does not work with 'virtualedit' Commit: https://github.com/vim/vim/commit/6c6be9e88d72a60ee279ccad73d018c534b71d66 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 12 20:19:44 2020 +0200 patch 8.2.0963: number increment/decrement does not work with 'virtualedit' Problem: Number increment/decrement does not work with 'virtualedit'. Solution: Handle coladd changing. (Christian Brabandt, closes https://github.com/vim/vim/issues/6240, closes #923)
author Bram Moolenaar <Bram@vim.org>
date Fri, 12 Jun 2020 20:30:04 +0200
parents cea8ae407452
children 9064044fd4f6
comparison
equal deleted inserted replaced
20821:08f9e9d3726b 20822:8e5f991db3b4
2444 int did_change = FALSE; 2444 int did_change = FALSE;
2445 pos_T save_cursor = curwin->w_cursor; 2445 pos_T save_cursor = curwin->w_cursor;
2446 int maxlen = 0; 2446 int maxlen = 0;
2447 pos_T startpos; 2447 pos_T startpos;
2448 pos_T endpos; 2448 pos_T endpos;
2449 colnr_T save_coladd = 0;
2449 2450
2450 do_hex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX" 2451 do_hex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
2451 do_oct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal" 2452 do_oct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
2452 do_bin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); // "Bin" 2453 do_bin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); // "Bin"
2453 do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha" 2454 do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha"
2454 do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL); // "Unsigned" 2455 do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL); // "Unsigned"
2455 2456
2457 if (virtual_active())
2458 {
2459 save_coladd = pos->coladd;
2460 pos->coladd = 0;
2461 }
2462
2456 curwin->w_cursor = *pos; 2463 curwin->w_cursor = *pos;
2457 ptr = ml_get(pos->lnum); 2464 ptr = ml_get(pos->lnum);
2458 col = pos->col; 2465 col = pos->col;
2459 2466
2460 if (*ptr == NUL) 2467 if (*ptr == NUL || col + !!save_coladd >= (int)STRLEN(ptr))
2461 goto theend; 2468 goto theend;
2462 2469
2463 /* 2470 /*
2464 * First check if we are on a hexadecimal number, after the "0x". 2471 * First check if we are on a hexadecimal number, after the "0x".
2465 */ 2472 */
2822 theend: 2829 theend:
2823 if (visual) 2830 if (visual)
2824 curwin->w_cursor = save_cursor; 2831 curwin->w_cursor = save_cursor;
2825 else if (did_change) 2832 else if (did_change)
2826 curwin->w_set_curswant = TRUE; 2833 curwin->w_set_curswant = TRUE;
2834 else if (virtual_active())
2835 curwin->w_cursor.coladd = save_coladd;
2827 2836
2828 return did_change; 2837 return did_change;
2829 } 2838 }
2830 2839
2831 void 2840 void