From 1a35eb9b568e1d916cf86dfb27c723e788254923 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 6 Mar 2025 08:24:13 +0800 Subject: vim-patch:9.1.1175: inconsistent behaviour with exclusive selection and motion commands (#32745) Problem: inconsistent behaviour with exclusive selection and motion commands (aidancz) Solution: adjust cursor position when selection is exclusive (Jim Zhou) fixes: vim/vim#16278 closes: vim/vim#16784 https://github.com/vim/vim/commit/c8cce711dde2d8abcf0929b3b12c4bfc5547a89d Co-authored-by: Jim Zhou Co-authored-by: Hirohito Higashi --- src/nvim/textobject.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index e3b3bba7c1..fda8b45e21 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -19,6 +19,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/move.h" +#include "nvim/normal.h" #include "nvim/option_vars.h" #include "nvim/pos_defs.h" #include "nvim/search.h" @@ -427,6 +428,13 @@ int end_word(int count, bool bigword, bool stop, bool empty) curwin->w_cursor.coladd = 0; cls_bigword = bigword; + + // If adjusted cursor position previously, unadjust it. + if (*p_sel == 'e' && VIsual_active && VIsual_mode == 'v' + && VIsual_select_exclu_adj) { + unadjust_for_sel(); + } + while (--count >= 0) { // When inside a range of folded lines, move to the last char of the // last line. -- cgit