diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e8010ceceff..7634528927a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -956,60 +956,46 @@ void txt_move_right(Text *text, short sel) void txt_jump_left(Text *text, short sel) { - TextLine **linep, *oldl; - int *charp, oldc, oldflags; - unsigned char oldu; - + TextLine **linep; + int *charp, oldc; + if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - - oldflags = text->flags; - text->flags &= ~TXT_TABSTOSPACES; - - oldl = *linep; oldc = *charp; - oldu = undoing; - undoing = 1; /* Don't push individual moves to undo stack */ BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM); - - text->flags = oldflags; - - undoing = oldu; - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + + if (!sel) txt_pop_sel(text); + if (!undoing) { + int span = txt_get_span(text->lines.first, *linep); + txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); + } } void txt_jump_right(Text *text, short sel) { - TextLine **linep, *oldl; - int *charp, oldc, oldflags; - unsigned char oldu; - + TextLine **linep; + int *charp, oldc; + if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - - oldflags = text->flags; - text->flags &= ~TXT_TABSTOSPACES; - - oldl = *linep; oldc = *charp; - oldu = undoing; - undoing = 1; /* Don't push individual moves to undo stack */ - + BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM); - - text->flags = oldflags; - - undoing = oldu; - if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + + if (!sel) txt_pop_sel(text); + if (!undoing) { + int span = txt_get_span(text->lines.first, *linep); + txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); + } } void txt_move_bol(Text *text, short sel)