summaryrefslogtreecommitdiff
path: root/src/dged/syntax.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-05-06 22:42:39 +0200
committerAlbert Cervin <albert@acervin.com>2024-05-06 22:42:39 +0200
commitad0cd5c036f0080ee8d97db2e67b8d54186d1e33 (patch)
treeb85cc21acac6e1383dfa3b78494ce09c409b2f30 /src/dged/syntax.c
parentc42412e1643c88c81cf5b38404cc010881437fe9 (diff)
downloaddged-ad0cd5c036f0080ee8d97db2e67b8d54186d1e33.tar.gz
dged-ad0cd5c036f0080ee8d97db2e67b8d54186d1e33.tar.xz
dged-ad0cd5c036f0080ee8d97db2e67b8d54186d1e33.zip
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.
Diffstat (limited to 'src/dged/syntax.c')
-rw-r--r--src/dged/syntax.c4
1 files changed, 4 insertions, 0 deletions
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) {