don't crash on insertTextPortion returning empty reference

Change-Id: Id55ea26f1467fd160dab30b31327646240edabaf