diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 7660093fc2..c9ae4c3ed3 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -302,9 +302,9 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) } #endif - // Help buffer is filtered. + // Help buffer: populate *local-additions* in help.txt if (bt_help(curbuf)) { - fix_help_buffer(); + get_local_additions(); } } else if (read_stdin) { int save_bin = curbuf->b_p_bin; diff --git a/src/nvim/help.c b/src/nvim/help.c index 28b95b2346..b1b53bc0c3 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -642,46 +642,9 @@ void prepare_help_buffer(void) set_buflisted(false); } -/// After reading a help file: May cleanup a help buffer when syntax -/// highlighting is not used. -void fix_help_buffer(void) +/// After reading a help file: if help.txt, populate *local-additions* +void get_local_additions(void) { - // Set filetype to "help". - if (strcmp(curbuf->b_p_ft, "help") != 0) { - curbuf->b_ro_locked++; - set_option_value_give_err(kOptFiletype, STATIC_CSTR_AS_OPTVAL("help"), OPT_LOCAL); - curbuf->b_ro_locked--; - } - - if (!syntax_present(curwin)) { - bool in_example = false; - for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - char *line = ml_get_buf(curbuf, lnum); - const size_t len = strlen(line); - if (in_example && len > 0 && !ascii_iswhite(line[0])) { - // End of example: non-white or '<' in first column. - if (line[0] == '<') { - // blank-out a '<' in the first column - line = ml_get_buf_mut(curbuf, lnum); - line[0] = ' '; - } - in_example = false; - } - if (!in_example && len > 0) { - if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { - // blank-out a '>' in the last column (start of example) - line = ml_get_buf_mut(curbuf, lnum); - line[len - 1] = ' '; - in_example = true; - } else if (line[len - 1] == '~') { - // blank-out a '~' at the end of line (header marker) - line = ml_get_buf_mut(curbuf, lnum); - line[len - 1] = ' '; - } - } - } - } - // In the "help.txt" and "help.abx" file, add the locally added help // files. This uses the very first line in the help file. char *const fname = path_tail(curbuf->b_fname);