diff --git a/source/blender/editors/space_text/text_header.cc b/source/blender/editors/space_text/text_header.cc index 36387346370..cc19b75eb18 100644 --- a/source/blender/editors/space_text/text_header.cc +++ b/source/blender/editors/space_text/text_header.cc @@ -69,20 +69,16 @@ static int text_text_search_exec(bContext *C, wmOperator * /*op*/) SpaceText *st = CTX_wm_space_text(C); if (region) { - ARegion *active_region = CTX_wm_region(C); Text *text = st->text; /* Use active text selection as search query, if selection is on a single line. */ - if (active_region->regiontype == RGN_TYPE_WINDOW && text && text->curl == text->sell && - text->curc != text->selc) - { - const char *sel_start = text->curl->line + - (text->curc < text->selc ? text->curc : text->selc); - - const int sel_len = std::abs(text->curc - text->selc) + 1; - const int max_copy = sel_len < ST_MAX_FIND_STR ? sel_len : ST_MAX_FIND_STR; - - BLI_strncpy(st->findstr, sel_start, max_copy); + if (text && (text->curl == text->sell) && (text->curc != text->selc)) { + const ARegion *active_region = CTX_wm_region(C); + if (active_region && active_region->regiontype == RGN_TYPE_WINDOW) { + const char *sel_start = text->curl->line + std::min(text->curc, text->selc); + const int sel_len = std::abs(text->curc - text->selc); + BLI_strncpy(st->findstr, sel_start, std::min(sel_len + 1, ST_MAX_FIND_STR)); + } } bool draw = false; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d920e91fd8e..7ba0483b6b0 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1474,6 +1474,8 @@ typedef enum eSpaceText_Flags { ST_SHOW_MARGIN = (1 << 7), ST_MATCH_CASE = (1 << 8), + ST_FLAG_UNUSED_9 = (1 << 9), /* Dirty. */ + } eSpaceText_Flags; /* SpaceText.findstr/replacestr */