Skip to content

Commit

Permalink
patch 9.1.0394: Cannot get a list of positions describing a region
Browse files Browse the repository at this point in the history
Problem:  Cannot get a list of positions describing a region
          (Justin M. Keyes, after v9.1.0120)
Solution: Add the getregionpos() function
          (Shougo Matsushita)

fixes: #14609
closes: #14617

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
  • Loading branch information
2 people authored and chrisbra committed May 7, 2024
1 parent c5def65 commit b4757e6
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 91 deletions.
24 changes: 23 additions & 1 deletion runtime/doc/builtin.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*builtin.txt* For Vim version 9.1. Last change: 2024 May 05
*builtin.txt* For Vim version 9.1. Last change: 2024 May 07


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -265,6 +265,8 @@ getreg([{regname} [, 1 [, {list}]]])
getreginfo([{regname}]) Dict information about a register
getregion({pos1}, {pos2} [, {opts}])
List get the text from {pos1} to {pos2}
getregionpos({pos1}, {pos2} [, {opts}])
List get a list of positions for a region
getregtype([{regname}]) String type of a register
getscriptinfo([{opts}]) List list of sourced scripts
gettabinfo([{expr}]) List list of tab pages
Expand Down Expand Up @@ -4327,6 +4329,26 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()*
Can also be used as a |method|: >
getpos('.')->getregion(getpos("'a"))
<
getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
Same as |getregion()|, but returns a list of positions
describing the buffer text segments bound by {pos1} and
{pos2}.
The segments are a pair of positions for every line: >
[[{start_pos}, {end_pos}], ...]
<
The position is a |List| with four numbers:
[bufnum, lnum, col, off]
"bufnum" is the buffer number.
"lnum" and "col" are the position in the buffer. The first
column is 1.
The "off" number is zero, unless 'virtualedit' is used. Then
it is the offset in screen columns from the start of the
character. E.g., a position within a <Tab> or after the last
character.

Can also be used as a |method|: >
getpos('.')->getregionpos(getpos("'a"))
<
getregtype([{regname}]) *getregtype()*
The result is a String, which is type of register {regname}.
The value will be one of:
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -7799,6 +7799,7 @@ getreg() builtin.txt /*getreg()*
getreginfo() builtin.txt /*getreginfo()*
getregion() builtin.txt /*getregion()*
getregion-notes builtin.txt /*getregion-notes*
getregionpos() builtin.txt /*getregionpos()*
getregtype() builtin.txt /*getregtype()*
getscript pi_getscript.txt /*getscript*
getscript-autoinstall pi_getscript.txt /*getscript-autoinstall*
Expand Down
3 changes: 2 additions & 1 deletion runtime/doc/usr_41.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*usr_41.txt* For Vim version 9.1. Last change: 2024 Apr 26
*usr_41.txt* For Vim version 9.1. Last change: 2024 May 07

VIM USER MANUAL - by Bram Moolenaar

Expand Down Expand Up @@ -930,6 +930,7 @@ Cursor and mark position: *cursor-functions* *mark-functions*
Working with text in the current buffer: *text-functions*
getline() get a line or list of lines from the buffer
getregion() get a region of text from the buffer
getregionpos() get a list of positions for a region
setline() replace a line in the buffer
append() append line or list of lines in the buffer
indent() indent of a specific line
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/version9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41574,6 +41574,7 @@ Functions: ~
|matchbufline()| all the matches of a pattern in a buffer
|matchstrlist()| all the matches of a pattern in a List of strings
|getregion()| get a region of text from a buffer
|getregionpos()| get a list of positions for a region


Autocommands: ~
Expand Down
Loading

0 comments on commit b4757e6

Please sign in to comment.