diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-12-10 10:56:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 10:56:17 +0100 |
commit | 26eb6051528186270b924c7c806a3f434c233530 (patch) | |
tree | 7229d143d9ce52354cd35d105054bf47d206a5bc /src/nvim/memline.c | |
parent | ac2d140a33dfe88f882218e15a443b8300cca6b2 (diff) | |
parent | a59589ca018425f672eb70bf7d2b54d24df49326 (diff) | |
download | rneovim-26eb6051528186270b924c7c806a3f434c233530.tar.gz rneovim-26eb6051528186270b924c7c806a3f434c233530.tar.bz2 rneovim-26eb6051528186270b924c7c806a3f434c233530.zip |
Merge pull request #16597 from bfredl/nomisc1
refactor: move out some long-hanging fruit from misc1.c
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r-- | src/nvim/memline.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 08202a6d5c..40da4b48f8 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1841,6 +1841,17 @@ char_u *ml_get_pos(const pos_T *pos) return ml_get_buf(curbuf, pos->lnum, false) + pos->col; } +/// get codepoint at pos. pos must be either valid or have col set to MAXCOL! +int gchar_pos(pos_T *pos) + FUNC_ATTR_NONNULL_ARG(1) +{ + // When searching columns is sometimes put at the end of a line. + if (pos->col == MAXCOL) { + return NUL; + } + return utf_ptr2char(ml_get_pos(pos)); +} + /// Return a pointer to a line in a specific buffer /// /// @param will_change true mark the buffer dirty (chars in the line will be changed) |