patch 9.1.0088: TextChanged not triggered for :norm! commands

Problem:  TextChanged not triggered for :norm! commands
          (machakann, after v9.0.2031)
Solution: Only reset curbuf->b_last_changedtick if TextChangedI
          was triggered in insert mode (and not blocked)

Note: for unknown reasons, the test fails on Windows (but seems to work
fine when running interactively)

fixes: #13967
closes: #13984

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/edit.c b/src/edit.c
index e9a994f..5760b06 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -843,7 +843,12 @@
 		if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C)
 		    ins_apply_autocmds(EVENT_INSERTLEAVE);
 		did_cursorhold = FALSE;
-		curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
+
+		// ins_redraw() triggers TextChangedI only when no characters
+		// are in the typeahead buffer, so only reset curbuf->b_last_changedtick
+		// if the TextChangedI was not blocked by char_avail() (e.g. using :norm!)
+		if (!char_avail())
+		    curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
 		return (c == Ctrl_O);
 	    }
 	    continue;