mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 18:41:48 +00:00
vim-patch:9.0.1728: missing winid argument for virtcol() (#24770)
Problem: missing winid argument for virtcol()
Solution: Add a {winid} argument to virtcol()
Other functions col(), charcol() and virtcol2col() support a {winid}
argument, so it makes sense for virtcol() to also support than.
Also add test for virtcol2col() with 'showbreak' and {winid}.
closes: vim/vim#12633
825cf813fa
This commit is contained in:
13
runtime/doc/builtin.txt
generated
13
runtime/doc/builtin.txt
generated
@@ -8399,7 +8399,7 @@ values({dict}) *values()*
|
||||
in arbitrary order. Also see |items()| and |keys()|.
|
||||
Returns zero if {dict} is not a |Dict|.
|
||||
|
||||
virtcol({expr} [, {list}]) *virtcol()*
|
||||
virtcol({expr} [, {list} [, {winid}]]) *virtcol()*
|
||||
The result is a Number, which is the screen column of the file
|
||||
position given with {expr}. That is, the last screen position
|
||||
occupied by the character at that position, when the screen
|
||||
@@ -8431,10 +8431,13 @@ virtcol({expr} [, {list}]) *virtcol()*
|
||||
returns the cursor position. Differs from |'<| in
|
||||
that it's updated right away.
|
||||
|
||||
If {list} is present and non-zero then virtcol() returns a List
|
||||
with the first and last screen position occupied by the
|
||||
If {list} is present and non-zero then virtcol() returns a
|
||||
List with the first and last screen position occupied by the
|
||||
character.
|
||||
|
||||
With the optional {winid} argument the values are obtained for
|
||||
that window instead of the current window.
|
||||
|
||||
Note that only marks in the current file can be used.
|
||||
Examples: >vim
|
||||
" With text "foo^Lbar" and cursor on the "^L":
|
||||
@@ -8446,8 +8449,8 @@ virtcol({expr} [, {list}]) *virtcol()*
|
||||
" With text " there", with 't at 'h':
|
||||
|
||||
echo virtcol("'t") " returns 6
|
||||
< Techo he first column is 1. 0 is returned for an error.
|
||||
A echo more advanced example that echoes the maximum length of
|
||||
< The first column is 1. 0 or [0, 0] is returned for an error.
|
||||
A more advanced example that echoes the maximum length of
|
||||
all lines: >vim
|
||||
echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
|
||||
|
||||
|
||||
14
runtime/lua/vim/_meta/vimfn.lua
generated
14
runtime/lua/vim/_meta/vimfn.lua
generated
@@ -10013,10 +10013,13 @@ function vim.fn.values(dict) end
|
||||
--- returns the cursor position. Differs from |'<| in
|
||||
--- that it's updated right away.
|
||||
---
|
||||
--- If {list} is present and non-zero then virtcol() returns a List
|
||||
--- with the first and last screen position occupied by the
|
||||
--- If {list} is present and non-zero then virtcol() returns a
|
||||
--- List with the first and last screen position occupied by the
|
||||
--- character.
|
||||
---
|
||||
--- With the optional {winid} argument the values are obtained for
|
||||
--- that window instead of the current window.
|
||||
---
|
||||
--- Note that only marks in the current file can be used.
|
||||
--- Examples: >vim
|
||||
--- " With text "foo^Lbar" and cursor on the "^L":
|
||||
@@ -10028,15 +10031,16 @@ function vim.fn.values(dict) end
|
||||
--- " With text " there", with 't at 'h':
|
||||
---
|
||||
--- echo virtcol("'t") " returns 6
|
||||
--- <Techo he first column is 1. 0 is returned for an error.
|
||||
--- A echo more advanced example that echoes the maximum length of
|
||||
--- <The first column is 1. 0 or [0, 0] is returned for an error.
|
||||
--- A more advanced example that echoes the maximum length of
|
||||
--- all lines: >vim
|
||||
--- echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
|
||||
---
|
||||
--- @param expr any
|
||||
--- @param list? any
|
||||
--- @param winid? integer
|
||||
--- @return any
|
||||
function vim.fn.virtcol(expr, list) end
|
||||
function vim.fn.virtcol(expr, list, winid) end
|
||||
|
||||
--- The result is a Number, which is the byte index of the
|
||||
--- character in window {winid} at buffer line {lnum} and virtual
|
||||
|
||||
Reference in New Issue
Block a user