From bcda800933f6de09392c3c91e290077952989722 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Oct 2023 19:18:25 +0800 Subject: vim-patch:9.0.2022: getmousepos() returns wrong index for TAB char (#25636) Problem: When clicking in the middle of a TAB, getmousepos() returns the column of the next char instead of the TAB. Solution: Break out of the loop when the vcol to find is inside current char. Fix invalid memory access when calling virtcol2col() on an empty line. closes: vim/vim#13321 https://github.com/vim/vim/commit/b583eda7031b1f6a3469a2537d0c10ca5fa5568e --- runtime/doc/builtin.txt | 2 ++ runtime/lua/vim/_meta/vimfn.lua | 2 ++ 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 48fa953954..c09c0d552e 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -8509,6 +8509,8 @@ virtcol2col({winid}, {lnum}, {col}) *virtcol2col()* character in window {winid} at buffer line {lnum} and virtual column {col}. + If buffer line {lnum} is an empty line, 0 is returned. + If {col} is greater than the last virtual column in line {lnum}, then the byte index of the character at the last virtual column is returned. diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 481ffd1831..a2d9ce5bc4 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -10099,6 +10099,8 @@ function vim.fn.virtcol(expr, list, winid) end --- character in window {winid} at buffer line {lnum} and virtual --- column {col}. --- +--- If buffer line {lnum} is an empty line, 0 is returned. +--- --- If {col} is greater than the last virtual column in line --- {lnum}, then the byte index of the character at the last --- virtual column is returned. -- cgit