From 50672e3850ddd0ddacfcdcd536922440fb719093 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 05:55:07 +0800 Subject: vim-patch:8.2.5013: after text formatting cursor may be in an invalid position Problem: After text formatting the cursor may be in an invalid position. Solution: Correct the cursor position after formatting. https://github.com/vim/vim/commit/78d52883e10d71f23ab72a3d8b9733b00da8c9ad --- src/nvim/ops.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/ops.c') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index cc67b0d0c1..0bcc5ecd0e 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4349,6 +4349,9 @@ static void op_format(oparg_T *oap, int keep_cursor) if (keep_cursor) { curwin->w_cursor = saved_cursor; saved_cursor.lnum = 0; + + // formatting may have made the cursor position invalid + check_cursor(); } if (oap->is_VIsual) { -- cgit