From 222b3d5021f171d916d2dd3722eb1f49e82d0147 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 3 Jun 2025 07:54:29 +0800 Subject: [PATCH] vim-patch:bfeefc4: runtime(doc): clarify the effect of exclusive single char selections (#34289) closes: vim/vim#17410 https://github.com/vim/vim/commit/bfeefc474a3ed25852491a93e1e5610774f4de8c Co-authored-by: Christian Brabandt (cherry picked from commit aa4fa2496387c962ee8b4cbd7720396ec7596dbd) --- runtime/doc/options.txt | 11 ++++++++--- runtime/doc/vimfn.txt | 4 ++++ runtime/lua/vim/_meta/options.lua | 11 ++++++++--- runtime/lua/vim/_meta/vimfn.lua | 4 ++++ src/nvim/eval.lua | 4 ++++ src/nvim/options.lua | 11 ++++++++--- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6dc9c6a9bd..2b0a91f413 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5010,9 +5010,14 @@ A jump table for the options with a short description can be found at |Q_op|. the end of line the line break still isn't included. When "exclusive" is used, cursor position in visual mode will be adjusted for inclusive motions |inclusive-motion-selection-exclusive|. - Note that when "exclusive" is used and selecting from the end - backwards, you cannot include the last character of a line, when - starting in Normal mode and 'virtualedit' empty. + + Note: + - When "exclusive" is used and selecting from the end backwards, you + cannot include the last character of a line, when starting in Normal + mode and 'virtualedit' empty. + - when "exclusive" is used with a single character visual selection, + Vim will behave as if the 'selection' is inclusive (in other words, + you cannot visually select an empty region). *'selectmode'* *'slm'* 'selectmode' 'slm' string (default "") diff --git a/runtime/doc/vimfn.txt b/runtime/doc/vimfn.txt index a6007c678b..b2bc1327a9 100644 --- a/runtime/doc/vimfn.txt +++ b/runtime/doc/vimfn.txt @@ -4093,6 +4093,10 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()* - It is evaluated in current window context, which makes a difference if the buffer is displayed in a window with different 'virtualedit' or 'list' values. + - When specifying an exclusive selection and {pos1} and {pos2} + are equal, the returned list contains a single character as + if selection is inclusive, to match the behavior of an empty + exclusive selection in Visual mode. Examples: >vim xnoremap diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index 210aab5ac3..41d06187da 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -5248,9 +5248,14 @@ vim.go.sect = vim.go.sections --- the end of line the line break still isn't included. --- When "exclusive" is used, cursor position in visual mode will be --- adjusted for inclusive motions `inclusive-motion-selection-exclusive`. ---- Note that when "exclusive" is used and selecting from the end ---- backwards, you cannot include the last character of a line, when ---- starting in Normal mode and 'virtualedit' empty. +--- +--- Note: +--- - When "exclusive" is used and selecting from the end backwards, you +--- cannot include the last character of a line, when starting in Normal +--- mode and 'virtualedit' empty. +--- - when "exclusive" is used with a single character visual selection, +--- Vim will behave as if the 'selection' is inclusive (in other words, +--- you cannot visually select an empty region). --- --- @type 'inclusive'|'exclusive'|'old' vim.o.selection = "inclusive" diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index fc802f36e8..318aa4a85a 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -3692,6 +3692,10 @@ function vim.fn.getreginfo(regname) end --- - It is evaluated in current window context, which makes a --- difference if the buffer is displayed in a window with --- different 'virtualedit' or 'list' values. +--- - When specifying an exclusive selection and {pos1} and {pos2} +--- are equal, the returned list contains a single character as +--- if selection is inclusive, to match the behavior of an empty +--- exclusive selection in Visual mode. --- --- Examples: >vim --- xnoremap diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 866711c2b1..022948faf1 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4578,6 +4578,10 @@ M.funcs = { - It is evaluated in current window context, which makes a difference if the buffer is displayed in a window with different 'virtualedit' or 'list' values. + - When specifying an exclusive selection and {pos1} and {pos2} + are equal, the returned list contains a single character as + if selection is inclusive, to match the behavior of an empty + exclusive selection in Visual mode. Examples: >vim xnoremap diff --git a/src/nvim/options.lua b/src/nvim/options.lua index eb56ffd928..bf66f307da 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7027,9 +7027,14 @@ local options = { the end of line the line break still isn't included. When "exclusive" is used, cursor position in visual mode will be adjusted for inclusive motions |inclusive-motion-selection-exclusive|. - Note that when "exclusive" is used and selecting from the end - backwards, you cannot include the last character of a line, when - starting in Normal mode and 'virtualedit' empty. + + Note: + - When "exclusive" is used and selecting from the end backwards, you + cannot include the last character of a line, when starting in Normal + mode and 'virtualedit' empty. + - when "exclusive" is used with a single character visual selection, + Vim will behave as if the 'selection' is inclusive (in other words, + you cannot visually select an empty region). ]=], full_name = 'selection', scope = { 'global' },