Implement get_token_array_from_buffer_no_wait to return an empty array if the lex task is currently running

This commit is contained in:
Peter Slattery 2025-07-14 11:19:27 -07:00
parent 9ecf49d278
commit 84b1b15fbb
1 changed files with 52 additions and 37 deletions

View File

@ -61,6 +61,21 @@ get_token_array_from_buffer(Application_Links *app, Buffer_ID buffer){
return(result); return(result);
} }
function Token_Array
get_token_array_from_buffer_no_wait(Application_Links *app, Buffer_ID buffer)
{
Token_Array result = {};
Managed_Scope scope = buffer_get_managed_scope(app, buffer);
Async_Task *lex_task_ptr = scope_attachment(app, scope, buffer_lex_task, Async_Task);
if (lex_task_ptr == 0){
Token_Array *ptr = scope_attachment(app, scope, attachment_tokens, Token_Array);
if (ptr != 0){
result = *ptr;
}
}
return(result);
}
//////////////////////////////// ////////////////////////////////
function Buffer_Seek function Buffer_Seek