From b56bd7caa8831e762fe70afe84839132fb51ce45 Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Wed, 16 Jul 2025 11:24:23 -0700 Subject: [PATCH] Move code index updating to happen to modified buffers on the tick hook. This will unify the separate paths for updating the code index. --- code/custom/4coder_custom_hooks.cpp | 5 ++++- code/custom/4coder_tree_sitter.cpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/code/custom/4coder_custom_hooks.cpp b/code/custom/4coder_custom_hooks.cpp index d79a04f7..91581f27 100644 --- a/code/custom/4coder_custom_hooks.cpp +++ b/code/custom/4coder_custom_hooks.cpp @@ -99,6 +99,7 @@ BUFFER_EDIT_RANGE_SIG(custom_buffer_edit_range){ Range_i64 old_range = Ii64(old_cursor_range.min.pos, old_cursor_range.max.pos); + b8 trigger_code_index_update = false; { // Tree Sitter Buffer_Tree_Sitter_Data* tree_data = scope_attachment(app, scope, buffer_tree_sitter_data_id, Buffer_Tree_Sitter_Data); @@ -131,7 +132,7 @@ BUFFER_EDIT_RANGE_SIG(custom_buffer_edit_range){ ts_tree_edit(tree_data->tree, &edit); tree_sitter_parse_incremental(app, buffer_id); - tree_sitter_code_index_update_full_file(app, buffer_id); // TODO(PS): This should become incremental + trigger_code_index_update = true; } } @@ -244,6 +245,8 @@ BUFFER_EDIT_RANGE_SIG(custom_buffer_edit_range){ loco_on_buffer_edit(app, buffer_id, old_range, new_range); + if (trigger_code_index_update) buffer_mark_as_modified(buffer_id); + // no meaning for return return(0); } diff --git a/code/custom/4coder_tree_sitter.cpp b/code/custom/4coder_tree_sitter.cpp index 6a7828de..591e502d 100644 --- a/code/custom/4coder_tree_sitter.cpp +++ b/code/custom/4coder_tree_sitter.cpp @@ -589,8 +589,9 @@ tree_sitter_code_index_update_tick(Application_Links* app) modified_node = modified_node->next ){ Buffer_ID buffer_id = modified_node->buffer; - String_Const_u8 buffer_name = push_buffer_unique_name(app, scratch, buffer_id); - printf("%.*s was modified\n", string_expand(buffer_name)); + + // TODO(PS): This should become incremental + tree_sitter_code_index_update_full_file(app, buffer_id); } buffer_modified_set_clear(); }