aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/plines.c
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-04-27 00:03:46 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2023-05-02 13:11:47 +0200
commitc426f7a6228cb82af0f75ac4f2421543408ff091 (patch)
tree261fb3c753c16a2b36f1b1a50c84602aaa34b79e /src/nvim/plines.c
parent223c7173eea2a4abec75611bd70051ea0b4c5d20 (diff)
downloadrneovim-c426f7a6228cb82af0f75ac4f2421543408ff091.tar.gz
rneovim-c426f7a6228cb82af0f75ac4f2421543408ff091.tar.bz2
rneovim-c426f7a6228cb82af0f75ac4f2421543408ff091.zip
vim-patch:9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Problem: 'scrolloff' does not work well with 'smoothscroll'. Solution: Make positioning the cursor a bit better. Rename functions. https://github.com/vim/vim/commit/c9121f798f49fa71e814912cb186d89c164090c3 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/plines.c')
-rw-r--r--src/nvim/plines.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index b2a4ac710d..3c8ee7d66d 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -243,12 +243,12 @@ int win_chartabsize(win_T *wp, char *p, colnr_T col)
/// @param s
///
/// @return Number of characters the string will take on the screen.
-int linetabsize(char *s)
+int linetabsize_str(char *s)
{
return linetabsize_col(0, s);
}
-/// Like linetabsize(), but "s" starts at column "startcol".
+/// Like linetabsize_str(), but "s" starts at column "startcol".
///
/// @param startcol
/// @param s
@@ -265,7 +265,7 @@ int linetabsize_col(int startcol, char *s)
return cts.cts_vcol;
}
-/// Like linetabsize(), but for a given window instead of the current one.
+/// Like linetabsize_str(), but for a given window instead of the current one.
///
/// @param wp
/// @param line
@@ -284,6 +284,13 @@ unsigned win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
return (unsigned)cts.cts_vcol;
}
+/// Return the number of cells line "lnum" of window "wp" will take on the
+/// screen, taking into account the size of a tab and text properties.
+unsigned linetabsize(win_T *wp, linenr_T lnum)
+{
+ return win_linetabsize(wp, lnum, ml_get_buf(wp->w_buffer, lnum, false), (colnr_T)MAXCOL);
+}
+
/// Prepare the structure passed to chartabsize functions.
///
/// "line" is the start of the line, "ptr" is the first relevant character.