diff --git a/opentasks/src/main/java/org/dmfs/tasks/widget/DescriptionFieldView.java b/opentasks/src/main/java/org/dmfs/tasks/widget/DescriptionFieldView.java index 93e41f79..a1eea171 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/widget/DescriptionFieldView.java +++ b/opentasks/src/main/java/org/dmfs/tasks/widget/DescriptionFieldView.java @@ -332,9 +332,10 @@ private void bindItemView(final View itemView, final DescriptionItem item) return true; } // split current - int sel = text.getSelectionStart(); - String newText = text.getText().toString().substring(sel); - item.text = text.getText().toString().substring(0, sel); + String current = text.getText().toString(); + int sel = Math.max(0, Math.min(current.length(), text.getSelectionStart())); + String newText = current.substring(sel); + item.text = current.substring(0, sel); text.setText(item.text); text.clearFocus(); // create new item with new test