Fixed 2 text editing bugs.
Hopefully without regressions.
This commit is contained in:
parent
b0406bb180
commit
425e538e83
@ -1645,7 +1645,7 @@ void TBStyleEdit::InsertText(const char *text, int32 len, bool after_last, bool
|
||||
else
|
||||
undoredo.Commit(this, caret.GetGlobalOfs(), len_inserted, text, true);
|
||||
|
||||
caret.Place(caret.pos.block, caret.pos.ofs + len);
|
||||
caret.Place(caret.pos.block, caret.pos.ofs + len, false);
|
||||
caret.UpdatePos();
|
||||
caret.UpdateWantedX();
|
||||
}
|
||||
@ -2071,7 +2071,7 @@ void TBUndoRedoStack::Apply(TBStyleEdit *styledit, TBUndoEvent *e, bool reverse)
|
||||
else
|
||||
{
|
||||
styledit->selection.SelectNothing();
|
||||
styledit->caret.SetGlobalOfs(e->gofs, false);
|
||||
styledit->caret.SetGlobalOfs(e->gofs, true, true);
|
||||
styledit->InsertText(e->text);
|
||||
int text_len = e->text.Length();
|
||||
if (text_len > 1)
|
||||
|
@ -195,6 +195,41 @@ TB_TEST_GROUP(tb_editfield)
|
||||
TB_VERIFY_STR(edit->GetText(), "ONE\r\n\r\n");
|
||||
}
|
||||
|
||||
TB_TEST(settext_undoredo_bugfix1)
|
||||
{
|
||||
// Make sure we use the test dummy font (ID 0), so we're not dependant on
|
||||
// the available fonts & font backend in this test.
|
||||
TBFontDescription fd;
|
||||
const int font_size = 48;
|
||||
fd.SetSize(font_size);
|
||||
edit->SetFontDescription(fd);
|
||||
|
||||
sedit->InsertBreak();
|
||||
sedit->InsertText("A");
|
||||
TB_VERIFY_STR(edit->GetText(), "\r\nA\r\n");
|
||||
TB_VERIFY(sedit->GetContentHeight() == font_size * 2);
|
||||
|
||||
sedit->KeyDown(0, TB_KEY_BACKSPACE, TB_MODIFIER_NONE);
|
||||
TB_VERIFY_STR(edit->GetText(), "\r\n\r\n");
|
||||
TB_VERIFY(sedit->GetContentHeight() == font_size * 2);
|
||||
|
||||
sedit->Undo();
|
||||
TB_VERIFY_STR(edit->GetText(), "\r\nA\r\n");
|
||||
TB_VERIFY(sedit->GetContentHeight() == font_size * 2);
|
||||
|
||||
sedit->Redo();
|
||||
TB_VERIFY_STR(edit->GetText(), "\r\n\r\n");
|
||||
TB_VERIFY(sedit->GetContentHeight() == font_size * 2);
|
||||
}
|
||||
|
||||
TB_TEST(settext_insert_linebreaks_move)
|
||||
{
|
||||
sedit->InsertText("Foo\n");
|
||||
sedit->InsertText("Foo\n");
|
||||
sedit->InsertText("Foo\n");
|
||||
TB_VERIFY_STR(edit->GetText(), "Foo\nFoo\nFoo\n");
|
||||
}
|
||||
|
||||
TB_TEST(multiline_overflow_1)
|
||||
{
|
||||
// Make sure we use the test dummy font (ID 0), so we're not dependant on
|
||||
|
Loading…
Reference in New Issue
Block a user