diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-08-09 21:25:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-08-09 21:48:59 +0300 |
commit | a571ff2c16c61baeb0cb55c0d6346adc0e958781 (patch) | |
tree | acb843bd7898e119c06b6dcd3698bd204e4ffa87 /source/blender | |
parent | d20d9aa3e89a0b2aabcba813f2d34ec499c1b67e (diff) |
Text: minor change to text prefix behavior
Don't keep the cursor at the start of the line,
this was creating a selection when adding a prefix without a selection.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 562e2814efa..1a3e42a7da2 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1933,7 +1933,7 @@ bool txt_replace_char(Text *text, unsigned int add) */ static void txt_select_prefix(Text *text, const char *add) { - int len, num, curc_old; + int len, num, curc_old, selc_old; char *tmp; const int indentlen = strlen(add); @@ -1941,6 +1941,7 @@ static void txt_select_prefix(Text *text, const char *add) BLI_assert(!ELEM(NULL, text->curl, text->sell)); curc_old = text->curc; + selc_old = text->selc; num = 0; while (true) { @@ -1978,19 +1979,24 @@ static void txt_select_prefix(Text *text, const char *add) num++; } } - if (!curc_old) { - text->curc = 0; - } - else { - text->curc = curc_old + indentlen; - } while (num > 0) { text->curl = text->curl->prev; num--; } - /* caller must handle undo */ + /* Keep the cursor left aligned if we don't have a selection. */ + if (curc_old == 0 && !(text->curl == text->sell && curc_old == selc_old)) { + if (text->curl == text->sell) { + if (text->curc == text->selc) { + text->selc = 0; + } + } + text->curc = 0; + } + else { + text->curc = curc_old + indentlen; + } } /** |