From 5561704e2e2b1d1e238f6f2e1712bf6da6ddb50c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 1 May 2020 06:52:22 -0700 Subject: [PATCH] Notepad-like mode crash bug fixes --- custom/4coder_auto_indent.cpp | 25 ++++++++++++++++++------- ship_files/changes.txt | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/custom/4coder_auto_indent.cpp b/custom/4coder_auto_indent.cpp index bf2e0317..0fbb3d8c 100644 --- a/custom/4coder_auto_indent.cpp +++ b/custom/4coder_auto_indent.cpp @@ -281,11 +281,11 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra } #define EMIT(N) \ - Stmnt(if (lines.first <= line_it){shifted_indentations[line_it]=N;} \ - if (line_it == lines.end){goto finished;} \ - actual_indent = N; ) - - i64 line_it = line_last_indented; +Stmnt(if (lines.first <= line_it){shifted_indentations[line_it]=N;} \ +if (line_it == lines.end){goto finished;} \ +actual_indent = N; ) + + i64 line_it = line_last_indented; if (lines.first <= line_cache.where_token_starts){ for (;line_it < line_cache.where_token_starts;){ line_it += 1; @@ -454,10 +454,21 @@ CUSTOM_DOC("Inserts text and auto-indents the line on which the cursor sits if a if (do_auto_indent){ View_ID view = get_active_view(app, Access_ReadWriteVisible); Buffer_ID buffer = view_get_buffer(app, view, Access_ReadWriteVisible); + Range_i64 pos = {}; - pos.min = view_get_cursor_pos(app, view); + if (view_has_highlighted_range(app, view)){ + pos = get_view_range(app, view); + } + else{ + pos.min = pos.max = view_get_cursor_pos(app, view); + } + write_text_input(app); - pos.max= view_get_cursor_pos(app, view); + + i64 end_pos = view_get_cursor_pos(app, view); + pos.min = Min(pos.min, end_pos); + pos.max = Max(pos.max, end_pos); + auto_indent_buffer(app, buffer, pos, 0); move_past_lead_whitespace(app, view, buffer); } diff --git a/ship_files/changes.txt b/ship_files/changes.txt index e587f29e..69f7973d 100644 --- a/ship_files/changes.txt +++ b/ship_files/changes.txt @@ -5,6 +5,7 @@ + Fix: when generated/metadata* files are missing buildsuper still succeeds + Fix: mac does not hang opening multiple files + Fix: line number margin performance + + Fix: crash in notepade like mode when replacing a highlighted range in a parsed file 4.1.4 + MAJOR: The clipboard history is now a fully custom layer implemented system. Users maintaining a customization layer should try to update their call sites to the old clipboard API. #define FCODER_TRANSITION_TO 4001004 to disable the transitional function wrappers when you are ready to make the transition.