fixed auto indent on save bug caused by reorganizing custom layer, fixed lexer crash bug

This commit is contained in:
Allen Webster 2018-05-12 00:20:37 -07:00
parent 537f83ab69
commit ce3c06d908
2 changed files with 26 additions and 25 deletions

View File

@ -320,14 +320,13 @@ OPEN_FILE_HOOK_SIG(default_file_save){
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll); Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
Assert(buffer.exists); Assert(buffer.exists);
#if defined(FCODER_AUTO_INDENT_CPP)
int32_t is_virtual = 0; int32_t is_virtual = 0;
if (automatically_indent_text_on_save && buffer_get_setting(app, &buffer, BufferSetting_VirtualWhitespace, &is_virtual)){ if (global_config.automatically_indent_text_on_save &&
buffer_get_setting(app, &buffer, BufferSetting_VirtualWhitespace, &is_virtual)){
if (is_virtual){ if (is_virtual){
buffer_auto_indent(app, &global_part, &buffer, 0, buffer.size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); buffer_auto_indent(app, &global_part, &buffer, 0, buffer.size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens);
} }
} }
#endif
// no meaning for return // no meaning for return
return(0); return(0);

View File

@ -283,28 +283,30 @@ cpp__table_match(Cpp_Keyword_Table *table, char *s, u32_4tech s_len, u32_4tech *
b32_4tech result = false; b32_4tech result = false;
u32_4tech max = table->max; u32_4tech max = table->max;
u32_4tech first_index = hash % max; if (max > 0){
u32_4tech index = first_index; u32_4tech first_index = hash % max;
for (;;){ u32_4tech index = first_index;
u64_4tech *keyword_ptr = keywords + index; for (;;){
if (*keyword_ptr == 0){ u64_4tech *keyword_ptr = keywords + index;
break; if (*keyword_ptr == 0){
} break;
}
u32_4tech *str_len = (u32_4tech*)(*keyword_ptr + base); u32_4tech *str_len = (u32_4tech*)(*keyword_ptr + base);
char *str = (char*)(str_len + 2); char *str = (char*)(str_len + 2);
if (cpp__match(str, *str_len, s, s_len)){ if (cpp__match(str, *str_len, s, s_len)){
*item_ptr_out = (u32_4tech*)(*keyword_ptr + base); *item_ptr_out = (u32_4tech*)(*keyword_ptr + base);
result = true; result = true;
break; break;
} }
++index; ++index;
if (index >= max){ if (index >= max){
index = 0; index = 0;
} }
if (index == first_index){ if (index == first_index){
break; break;
}
} }
} }