From 8bf32a557bb05d00aa124a34aea12d782bd366b2 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 9 Aug 2024 16:33:23 +0200 Subject: [PATCH] Debug memes --- .gitignore | 3 ++- build_file.cpp | 7 ++++--- src/text_editor/buffer_history.cpp | 6 ++++++ src/text_editor/title_bar.cpp | 3 --- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 749a9f3..3d1fd53 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ x64/Release src/external/SDL/ build/ -*.rdbg \ No newline at end of file +*.rdbg +*.spall \ No newline at end of file diff --git a/build_file.cpp b/build_file.cpp index e219db9..8b3b59f 100644 --- a/build_file.cpp +++ b/build_file.cpp @@ -24,9 +24,10 @@ void AddCommonFlags(Array *cmd) { if (Profile == PROFILE_DEBUG) { cmd->add("-DDEBUG_BUILD=1"); cmd->add("-DRELEASE_BUILD=0"); - // cmd->add("-fsanitize=address"); - // cmd->add("-DUSE_ADDRESS_SANITIZER"); - // cmd->add("-D_DEBUG /MDd"); + cmd->add("-fsanitize=address"); + cmd->add("-DUSE_ADDRESS_SANITIZER"); + cmd->add("-D_DEBUG"); + // cmd->add("/MDd"); } else { cmd->add("-DDEBUG_BUILD=0"); cmd->add("-DRELEASE_BUILD=1"); diff --git a/src/text_editor/buffer_history.cpp b/src/text_editor/buffer_history.cpp index e8ec77d..a40f9b9 100644 --- a/src/text_editor/buffer_history.cpp +++ b/src/text_editor/buffer_history.cpp @@ -145,6 +145,12 @@ void AdjustCarets(Array edits, Array *carets, bool kill_selection = carets->data[i].range.max = carets->data[i].range.min; } } + +#if DEBUG_BUILD + For(*carets) { + Assert(it.range.max >= it.range.min); + } +#endif } bool KILL_SELECTION = true; diff --git a/src/text_editor/title_bar.cpp b/src/text_editor/title_bar.cpp index 0ecc5b4..25f73b1 100644 --- a/src/text_editor/title_bar.cpp +++ b/src/text_editor/title_bar.cpp @@ -111,9 +111,6 @@ void ReplaceTitleBarData(Window *window) { Caret caret = last_view->carets[0]; XY xy = PosToXY(*last_buffer, GetFront(caret)); - // @todo: this is still not quite correct, the carets here are not offset by edits - // so there will some problems here. I need to think about this in the future, maybe - // Command_Replace should return the edits and then you can offset manually! Array caret_copy = Copy(GetSystemAllocator(), view->carets); defer { Dealloc(&view->carets);