diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-14 20:09:04 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-14 20:09:04 +0100 |
commit | c9121f798f49fa71e814912cb186d89c164090c3 (patch) | |
tree | 7bf018b61ef5e6aff94c935e1638055a662ee2d3 /src/charset.c | |
parent | 0abd6cf62d65180dc2c40d67cd95f13b0691f7ea (diff) |
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'v9.0.0751
Problem: 'scrolloff' does not work well with 'smoothscroll'.
Solution: Make positioning the cursor a bit better. Rename functions.
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c index c4db9f8cae..0e930776c7 100644 --- a/src/charset.c +++ b/src/charset.c @@ -743,13 +743,13 @@ win_chartabsize(win_T *wp, char_u *p, colnr_T col) * Does not handle text properties, since "s" is not a buffer line. */ int -linetabsize(char_u *s) +linetabsize_str(char_u *s) { return linetabsize_col(0, s); } /* - * Like linetabsize(), but "s" starts at column "startcol". + * Like linetabsize_str(), but "s" starts at column "startcol". */ int linetabsize_col(int startcol, char_u *s) @@ -772,7 +772,7 @@ linetabsize_col(int startcol, char_u *s) } /* - * 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. */ int win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len) @@ -785,6 +785,17 @@ win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len) return (int)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. + */ + int +linetabsize(win_T *wp, linenr_T lnum) +{ + return win_linetabsize(wp, lnum, + ml_get_buf(wp->w_buffer, lnum, FALSE), (colnr_T)MAXCOL); +} + void win_linetabsize_cts(chartabsize_T *cts, colnr_T len) { |