Pull tree_sitter_code_index_update_single_buffer out as it's own routine, and use it in tree_sitter_parse_asyn__inner to avoid setting the buffer_modified flag
This commit is contained in:
parent
5ccd6dd2ab
commit
18428ec90d
|
@ -269,14 +269,7 @@ tree_sitter_parse_async__inner(Async_Context* actx, Buffer_ID buffer_id)
|
|||
tree_data->tree = new_tree;
|
||||
system_mutex_acquire(tree_data->tree_mutex);
|
||||
|
||||
// TODO(PS): Just put the code index update call here
|
||||
// NOTE(jack): This feels kinda hacky, this is here to trigger
|
||||
// the code index update tick. The buffer is also makred by the
|
||||
// async lexer so we will update the index too frequently. We
|
||||
// should probably change the lexer to not mark as modified.
|
||||
// TODO(jack): Should we instead trigger another async task here to
|
||||
// update the code index once this is done?
|
||||
buffer_mark_as_modified(buffer_id);
|
||||
tree_sitter_code_index_update_single_buffer(app, buffer_id);
|
||||
|
||||
// Force a frame refresh by requesting another frame
|
||||
animate_in_n_milliseconds(app, 0);
|
||||
|
@ -329,17 +322,10 @@ code_index_new_note(Code_Index_File* index, Arena* arena, Code_Index_Note_Kind k
|
|||
}
|
||||
|
||||
function void
|
||||
tree_sitter_code_index_update_tick(Application_Links* app)
|
||||
tree_sitter_code_index_update_single_buffer(Application_Links* app, Buffer_ID buffer_id)
|
||||
{
|
||||
Scratch_Block scratch(app);
|
||||
|
||||
for (Buffer_Modified_Node* modified_node = global_buffer_modified_set.first;
|
||||
modified_node != 0;
|
||||
modified_node = modified_node->next
|
||||
){
|
||||
Temp_Memory_Block temp(scratch);
|
||||
|
||||
Buffer_ID buffer_id = modified_node->buffer;
|
||||
Arena arena = make_arena_system(KB(16));
|
||||
Code_Index_File* index = push_array_zero(&arena, Code_Index_File, 1);
|
||||
index->buffer = buffer_id;
|
||||
|
@ -347,7 +333,7 @@ tree_sitter_code_index_update_tick(Application_Links* app)
|
|||
String_Const_u8 buffer_contents = push_whole_buffer(app, scratch, buffer_id);
|
||||
|
||||
Tree_Sitter_Language_Definition* lang = tree_sitter_language_for_buffer(app, buffer_id);
|
||||
if (!lang) continue;
|
||||
if (!lang) return;
|
||||
|
||||
TSQuery* ts_query = lang->queries.ptr[Tree_Sitter_Language_Query_Tags];
|
||||
Tree_Sitter_Query_Cursor query = tree_sitter_query_init(
|
||||
|
@ -460,6 +446,16 @@ tree_sitter_code_index_update_tick(Application_Links* app)
|
|||
buffer_clear_layout_cache(app, buffer_id);
|
||||
|
||||
tree_sitter_query_end(&query);
|
||||
}
|
||||
|
||||
function void
|
||||
tree_sitter_code_index_update_tick(Application_Links* app)
|
||||
{
|
||||
for (Buffer_Modified_Node* modified_node = global_buffer_modified_set.first;
|
||||
modified_node != 0;
|
||||
modified_node = modified_node->next
|
||||
){
|
||||
tree_sitter_code_index_update_single_buffer(app, modified_node->buffer);
|
||||
}
|
||||
|
||||
buffer_modified_set_clear();
|
||||
|
|
|
@ -68,6 +68,7 @@ function void tree_sitter_register_language(String_Const_u8 ext, TSLanguage* lan
|
|||
|
||||
b8 use_tree_sitter_code_indexing = true;
|
||||
b8 use_tree_sitter_token_coloring = true;
|
||||
function void tree_sitter_code_index_update_single_buffer(Application_Links *app, Buffer_ID buffer_id);
|
||||
function void tree_sitter_code_index_update_tick(Application_Links *app);
|
||||
|
||||
#endif //FCODER_TREE_SITTER_H
|
||||
|
|
Loading…
Reference in New Issue