aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/indent.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-08-08 17:44:56 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-08-08 22:22:34 -0400
commitf89a275e32110a63e8ee1fc6ca75e0cf09194185 (patch)
tree9a9a18a357f50d6cc114e034af4ba317fcd906ed /src/nvim/indent.c
parent68f61b167e71ca8dd42157b10b3096571c06f39d (diff)
downloadrneovim-f89a275e32110a63e8ee1fc6ca75e0cf09194185.tar.gz
rneovim-f89a275e32110a63e8ee1fc6ca75e0cf09194185.tar.bz2
rneovim-f89a275e32110a63e8ee1fc6ca75e0cf09194185.zip
vim-patch:8.2.3160: 'breakindent' does not work well for bulleted lists
Problem: 'breakindent' does not work well for bulleted and numbered lists. Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt, closes vim/vim#8564, closes vim/vim#1661) https://github.com/vim/vim/commit/4a0b85ad0193ac162e2d8458e4b1c5ad2e2b0193
Diffstat (limited to 'src/nvim/indent.c')
-rw-r--r--src/nvim/indent.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index c1f9c1e172..4e734421a4 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.
@@ -469,6 +469,22 @@ int get_breakindent_win(win_T *wp, const char_u *line)
// 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)) {
+ bri += wp->w_briopt_list;
+ }
+ vim_regfree(regmatch.regprog);
+ }
+ }
+
+
// never indent past left window margin
if (bri < 0) {
bri = 0;