From ad0cd5c036f0080ee8d97db2e67b8d54186d1e33 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Mon, 6 May 2024 22:42:39 +0200 Subject: Fix slow buffer paste Was caused by updating all buffer hooks on every char insert. Particularily, the syntax update takes a little bit too long to call on every char. Now the keyboard parsing routine compresses all consecutive self-inserting chars into one "key press". Also fix some small issues with timers and update them with a min and max. --- src/dged/syntax.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/dged/syntax.c') diff --git a/src/dged/syntax.c b/src/dged/syntax.c index f5c80d5..8d0fd1a 100644 --- a/src/dged/syntax.c +++ b/src/dged/syntax.c @@ -20,6 +20,7 @@ #include "s8.h" #include "settings.h" #include "text.h" +#include "timers.h" #include "vec.h" static char *treesitter_path[256] = {0}; @@ -481,6 +482,7 @@ static void buffer_reloaded(struct buffer *buffer, void *userdata) { static void text_inserted(struct buffer *buffer, struct region inserted, uint32_t begin_idx, uint32_t end_idx, void *userdata) { + struct timer *text_inserted = timer_start("syntax.txt-inserted"); struct highlight *h = (struct highlight *)userdata; TSPoint begin = {.row = inserted.begin.line, @@ -512,6 +514,8 @@ static void text_inserted(struct buffer *buffer, struct region inserted, ts_tree_delete(h->tree); h->tree = new_tree; } + + timer_stop(text_inserted); } static void create_parser(struct buffer *buffer, void *userdata) { -- cgit v1.2.3