From 95ab5a0da3a465351a781031698d6cc8a727584a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 13 Mar 2023 19:50:09 +0100 Subject: fix(help): force tree reparse after local addition insertion Problem: *local-additions* in `help.txt` are inserted via `ml_append`, which messes up treesitter highlighting of this file as the buffer becomes desynced from the tree. Solution: Add hack on top of hack by explicitly calling `mark_adjust` and `changed_lines_buf` after each insertion. --- src/nvim/help.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/nvim/help.c b/src/nvim/help.c index 968f0bc2f4..728c890da4 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -10,6 +10,7 @@ #include "nvim/ascii.h" #include "nvim/buffer.h" +#include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/ex_cmds.h" @@ -699,6 +700,8 @@ void fix_help_buffer(void) continue; } + int lnum_start = lnum; + // Go through all directories in 'runtimepath', skipping // $VIMRUNTIME. char *p = p_rtp; @@ -829,6 +832,11 @@ void fix_help_buffer(void) } xfree(rt); } + linenr_T appended = lnum - lnum_start; + if (appended) { + mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0L, kExtmarkUndo); + changed_lines_buf(curbuf, lnum_start + 1, lnum_start + 1, appended); + } break; } } -- cgit From 9ab814eafad4e7d3f34ef9e1f518339dddedfac2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 13 Mar 2023 20:01:49 +0100 Subject: docs(help): consistent headers for local additions --- runtime/doc/help.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 68c886887f..a1550d5c8b 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -169,8 +169,8 @@ DEVELOPING NVIM |dev-style| Development style guidelines |debug.txt| Debugging Vim itself - *standard-plugin-list* Standard plugins ~ + *standard-plugin-list* |matchit.txt| Extended |%| matching |pi_gzip.txt| Reading and writing compressed files |pi_health.txt| Healthcheck framework @@ -181,7 +181,8 @@ Standard plugins ~ |pi_tar.txt| Tar file explorer |pi_zip.txt| Zip archive explorer -LOCAL ADDITIONS: *local-additions* +Local additions ~ + *local-additions* ------------------------------------------------------------------------------ *bars* Bars example -- cgit