patch 9.0.2022: getmousepos() returns wrong index for TAB char
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: #13321
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 029c08b..f621fc0 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -10376,6 +10376,8 @@
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.