From 9de2633f516aa1c2511775cbeadbd80ad1c283fd Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 29 Oct 2016 15:51:59 -0400 Subject: [PATCH] fixed binary search impossible to find' --- 4coder_default_bindings.cpp | 2 +- buffer/4coder_buffer_abstract.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 57de388b..55409c2b 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -217,7 +217,7 @@ OPEN_FILE_HOOK_SIG(my_file_settings){ buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width); buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file)); - if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 20)){ + if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 18)){ // NOTE(allen|a4.0.12): There is a little bit of grossness going on here. // If we set BufferSetting_Lex to true, it will launch a lexing job. // If a lexing job is active when we set BufferSetting_VirtualWhitespace on diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index 8a2ff23f..38cca6d6 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -599,6 +599,10 @@ binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){ i32 start = l_bound, end = u_bound; i32 i = 0; + if (value < 0){ + value = 0; + } + for (;;){ i = (start + end) >> 1; if (array[i] < value){