aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/indent.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-08-09 08:28:36 -0400
committerGitHub <noreply@github.com>2021-08-09 08:28:36 -0400
commit9ef7003c38c3be31e47732256fd591b5884613d1 (patch)
tree77b1224ff6ed6066b3b867085e694071dc4e0b03 /src/nvim/indent.c
parent68f61b167e71ca8dd42157b10b3096571c06f39d (diff)
parent292148b08b56476af0dc688e8a82df7d8e33f699 (diff)
downloadrneovim-9ef7003c38c3be31e47732256fd591b5884613d1.tar.gz
rneovim-9ef7003c38c3be31e47732256fd591b5884613d1.tar.bz2
rneovim-9ef7003c38c3be31e47732256fd591b5884613d1.zip
Merge pull request #15312 from janlazo/vim-8.2.2639
vim-patch:8.1.{1818},8.2.{1464,2639,2814,2947,2976,2986,3114,3141,3160,3198}
Diffstat (limited to 'src/nvim/indent.c')
-rw-r--r--src/nvim/indent.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index c1f9c1e172..bfb77688b0 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -432,7 +432,7 @@ int get_number_indent(linenr_T lnum)
// Return appropriate space number for breakindent, taking influencing
// parameters into account. Window must be specified, since it is not
// necessarily always the current one.
-int get_breakindent_win(win_T *wp, const char_u *line)
+int get_breakindent_win(win_T *wp, char_u *line)
FUNC_ATTR_NONNULL_ALL
{
static int prev_indent = 0; // Cached indent value.
@@ -462,12 +462,32 @@ int get_breakindent_win(win_T *wp, const char_u *line)
}
bri = prev_indent + wp->w_briopt_shift;
+ // Add offset for number column, if 'n' is in 'cpoptions'
+ bri += win_col_off2(wp);
+
+ // add additional indent for numbered lists
+ if (wp->w_briopt_list != 0) {
+ regmatch_T regmatch = {
+ .regprog = vim_regcomp(curbuf->b_p_flp,
+ RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT),
+ };
+
+ if (regmatch.regprog != NULL) {
+ if (vim_regexec(&regmatch, line, 0)) {
+ if (wp->w_briopt_list > 0) {
+ bri += wp->w_briopt_list;
+ } else {
+ bri = (int)(*regmatch.endp - *regmatch.startp);
+ }
+ }
+ vim_regfree(regmatch.regprog);
+ }
+ }
+
// indent minus the length of the showbreak string
if (wp->w_briopt_sbr) {
- bri -= vim_strsize(p_sbr);
+ bri -= vim_strsize(get_showbreak_value(wp));
}
- // Add offset for number column, if 'n' is in 'cpoptions'
- bri += win_col_off2(wp);
// never indent past left window margin
if (bri < 0) {