aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/indent.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2020-04-13 11:06:23 -0400
committerGitHub <noreply@github.com>2020-04-13 11:06:23 -0400
commit13b4a6fd4fa67794e76892cb362121a33a756f58 (patch)
tree31bd8bca21028be79e3111a53725144e854d92f5 /src/nvim/indent.c
parent46fdad255ead9ca484a6e512efe13b379b8fc8ab (diff)
parenta122f6c6d4d64ab6a3bcd55bde220dc115acd73c (diff)
downloadrneovim-13b4a6fd4fa67794e76892cb362121a33a756f58.tar.gz
rneovim-13b4a6fd4fa67794e76892cb362121a33a756f58.tar.bz2
rneovim-13b4a6fd4fa67794e76892cb362121a33a756f58.zip
Merge pull request #12073 from janlazo/vim-8.2.0027
vim-patch:8.1.{2366,2378,2387,2387},8.2.{27,560}
Diffstat (limited to 'src/nvim/indent.c')
-rw-r--r--src/nvim/indent.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index f8018c039d..7f17fb0035 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -56,7 +56,8 @@ int get_indent_buf(buf_T *buf, linenr_T lnum)
// Count the size (in window cells) of the indent in line "ptr", with
// 'tabstop' at "ts".
// If @param list is TRUE, count only screen size for tabs.
-int get_indent_str(char_u *ptr, int ts, int list)
+int get_indent_str(const char_u *ptr, int ts, int list)
+ FUNC_ATTR_NONNULL_ALL
{
int count = 0;
@@ -375,12 +376,12 @@ int get_number_indent(linenr_T lnum)
* parameters into account. Window must be specified, since it is not
* necessarily always the current one.
*/
-int get_breakindent_win(win_T *wp, char_u *line)
- FUNC_ATTR_NONNULL_ARG(1)
+int get_breakindent_win(win_T *wp, const char_u *line)
+ FUNC_ATTR_NONNULL_ALL
{
static int prev_indent = 0; // Cached indent value.
static long prev_ts = 0; // Cached tabstop value.
- static char_u *prev_line = NULL; // cached pointer to line.
+ static const char_u *prev_line = NULL; // cached pointer to line.
static varnumber_T prev_tick = 0; // Changedtick of cached value.
int bri = 0;
// window width minus window margin space, i.e. what rests for text
@@ -389,7 +390,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
- /* used cached indent, unless pointer or 'tabstop' changed */
+ // used cached indent, unless pointer or 'tabstop' changed
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != buf_get_changedtick(wp->w_buffer)) {
prev_line = line;
@@ -399,21 +400,22 @@ int get_breakindent_win(win_T *wp, char_u *line)
}
bri = prev_indent + wp->w_p_brishift;
- /* indent minus the length of the showbreak string */
- if (wp->w_p_brisbr)
+ // indent minus the length of the showbreak string
+ if (wp->w_p_brisbr) {
bri -= vim_strsize(p_sbr);
-
- /* Add offset for number column, if 'n' is in 'cpoptions' */
+ }
+ // Add offset for number column, if 'n' is in 'cpoptions'
bri += win_col_off2(wp);
- /* never indent past left window margin */
- if (bri < 0)
+ // never indent past left window margin
+ if (bri < 0) {
bri = 0;
- /* always leave at least bri_min characters on the left,
- * if text width is sufficient */
- else if (bri > eff_wwidth - wp->w_p_brimin)
+ } else if (bri > eff_wwidth - wp->w_p_brimin) {
+ // always leave at least bri_min characters on the left,
+ // if text width is sufficient
bri = (eff_wwidth - wp->w_p_brimin < 0)
? 0 : eff_wwidth - wp->w_p_brimin;
+ }
return bri;
}